Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wireless receiver sensor #27

Open
wants to merge 20 commits into
base: indigo-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e9fac3d
add wireless receiver, still doesn't work
libing64 Mar 3, 2016
25b73a2
add wireless receiver and wireless transmitter to the platform, but t…
libing64 Mar 4, 2016
7b0381d
add transmitter model to the world and add the receiver as a sensor t…
libing64 Mar 5, 2016
ee59fd1
fix bug of wireless receiver, -B + A and -(B-A) is not the same, -(B-…
libing64 Mar 6, 2016
93f14f1
add gaussNoise to the measurement of wireless
libing64 Mar 6, 2016
d0fa7da
update wireless_router world, and update the channel information in w…
libing64 Mar 7, 2016
3c71c9a
change the texture for the outdoor environment
libing64 Mar 7, 2016
c3543c8
fix bug of channel id of wireless receiver msg
libing64 Mar 10, 2016
0a6dba4
fix bug of the id of the wireless receiver
libing64 Mar 11, 2016
50d4400
modify plane.world
libing64 Mar 11, 2016
8fb48f9
add house2d world and add transmitter_count for wireless receiver
libing64 Mar 13, 2016
ae1435f
add irobot_create plugin
libing64 Mar 13, 2016
0839df0
add white line to the world, can be used for localization with white …
libing64 Mar 14, 2016
941cad2
add more plane world for stereo testing
libing64 Mar 16, 2016
dc82883
renmae world file
libing64 Mar 16, 2016
3f6bf73
add gas_station world for frontward camera testing
libing64 Mar 16, 2016
163c123
add more world for test
libing64 Mar 25, 2016
741ca64
add velodyne plugin
libing64 Mar 25, 2016
c5c8763
optimize the velodyne plugin to make it faster
libing64 Mar 26, 2016
541384d
optimize the speed for the velodyne plugin
libing64 Mar 26, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
14 changes: 14 additions & 0 deletions hector_gazebo_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ add_dependencies(hector_gazebo_ros_sonar ${PROJECT_NAME}_gencfg)
add_library(hector_servo_plugin src/servo_plugin.cpp)
target_link_libraries(hector_servo_plugin ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${catkin_LIBRARIES})

add_library(hector_gazebo_ros_wireless_receiver src/gazebo_ros_wireless_receiver.cpp)
target_link_libraries(hector_gazebo_ros_wireless_receiver ${GAZEBO_LIBRARIES} ${catkin_LIBRARIES})
add_dependencies(hector_gazebo_ros_wireless_receiver ${PROJECT_NAME}_gencfg)

add_library(hector_gazebo_ros_velodyne src/gazebo_ros_velodyne.cpp)
target_link_libraries(hector_gazebo_ros_velodyne ${GAZEBO_LIBRARIES} ${catkin_LIBRARIES})
add_dependencies(hector_gazebo_ros_velodyne ${PROJECT_NAME}_gencfg)


add_library(gazebo_ros_create src/gazebo_ros_create.cpp)
target_link_libraries(gazebo_ros_create ${catkin_LIBRARIES} ${GAZEBO_LIBRARIES})
add_dependencies(gazebo_ros_create ${PROJECT_NAME}_gencfg)


#############
## Install ##
#############
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#ifndef GAZEBO_ROS_CREATE_H
#define GAZEBO_ROS_CREATE_H

#include <gazebo/msgs/msgs.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/physics/PhysicsTypes.hh>
#include <gazebo/sensors/SensorTypes.hh>
#include <gazebo/transport/TransportTypes.hh>
#include <gazebo/transport/transport.hh>
#include <gazebo/common/Time.hh>
#include <gazebo/common/Plugin.hh>
#include <gazebo/common/Events.hh>

#include <nav_msgs/Odometry.h>
#include <geometry_msgs/TwistWithCovariance.h>
#include <geometry_msgs/PoseWithCovariance.h>
#include <tf/transform_broadcaster.h>
#include <ros/ros.h>

namespace gazebo
{
class GazeboRosCreate : public ModelPlugin
{
public:
GazeboRosCreate();
virtual ~GazeboRosCreate();

virtual void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf );

virtual void UpdateChild();

private:

void UpdateSensors();
void OnContact(ConstContactsPtr &contact);
void OnCmdVel( const geometry_msgs::TwistConstPtr &msg);


/// Parameters
std::string node_namespace_;
std::string left_wheel_joint_name_;
std::string right_wheel_joint_name_;
std::string front_castor_joint_name_;
std::string rear_castor_joint_name_;
std::string base_geom_name_;

/// Separation between the wheels
float wheel_sep_;

/// Diameter of the wheels
float wheel_diam_;

///Torque applied to the wheels
float torque_;


ros::NodeHandle *rosnode_;
//ros::Service operating_mode_srv_;
//ros::Service digital_output_srv_;

ros::Publisher sensor_state_pub_;
ros::Publisher odom_pub_;
ros::Publisher joint_state_pub_;

ros::Subscriber cmd_vel_sub_;

physics::WorldPtr my_world_;
physics::ModelPtr my_parent_;

/// Speeds of the wheels
float *wheel_speed_;

// Simulation time of the last update
common::Time prev_update_time_;
common::Time last_cmd_vel_time_;

float odom_pose_[3];
float odom_vel_[3];

bool set_joints_[4];
physics::JointPtr joints_[4];
physics::CollisionPtr base_geom_;

sensors::RaySensorPtr left_cliff_sensor_;
sensors::RaySensorPtr leftfront_cliff_sensor_;
sensors::RaySensorPtr rightfront_cliff_sensor_;
sensors::RaySensorPtr right_cliff_sensor_;
sensors::RaySensorPtr wall_sensor_;

tf::TransformBroadcaster transform_broadcaster_;
sensor_msgs::JointState js_;

create_node::TurtlebotSensorState sensor_state_;

void spin();
boost::thread *spinner_thread_;

//event::ConnectionPtr contact_event_;
transport::NodePtr gazebo_node_;
transport::SubscriberPtr contact_sub_;

// Pointer to the update event connection
event::ConnectionPtr updateConnection;
};
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//=================================================================================================
// Copyright (c) 2012, Johannes Meyer, TU Darmstadt
// All rights reserved.

// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Flight Systems and Automatic Control group,
// TU Darmstadt, nor the names of its contributors may be used to
// endorse or promote products derived from this software without
// specific prior written permission.

// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//=================================================================================================

#ifndef HECTOR_GAZEBO_PLUGINS_GAZEBO_ROS_VELODYNE_H
#define HECTOR_GAZEBO_PLUGINS_GAZEBO_ROS_VELODYNE_H

#include <gazebo/common/Plugin.hh>

#include <ros/callback_queue.h>
#include <ros/ros.h>

#include <sensor_msgs/PointCloud2.h>
#include <hector_gazebo_plugins/sensor_model.h>
#include <hector_gazebo_plugins/update_timer.h>
#include <gazebo/plugins/RayPlugin.hh>

#include <dynamic_reconfigure/server.h>

namespace gazebo
{

class GazeboRosVelodyne : public SensorPlugin
{
public:
GazeboRosVelodyne();
virtual ~GazeboRosVelodyne();

protected:
virtual void Load(sensors::SensorPtr _sensor, sdf::ElementPtr _sdf);
virtual void Reset();
virtual void Update();

private:
/// \brief The parent World
physics::WorldPtr world;

sensors::RaySensorPtr sensor_;

ros::NodeHandle* node_handle_;
ros::Publisher publisher_;

sensor_msgs::PointCloud2 cloud_msg_;

std::string namespace_;
std::string topic_;
std::string frame_id_;
int updateRate_;
int point_step;
SensorModel sensor_model_;

UpdateTimer updateTimer;
event::ConnectionPtr updateConnection;

boost::shared_ptr<dynamic_reconfigure::Server<SensorModelConfig> > dynamic_reconfigure_server_;
};

} // namespace gazebo

#endif // HECTOR_GAZEBO_PLUGINS_GAZEBO_ROS_SONAR_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//=================================================================================================
// Copyright (c) 2012, Johannes Meyer, TU Darmstadt
// All rights reserved.

// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Flight Systems and Automatic Control group,
// TU Darmstadt, nor the names of its contributors may be used to
// endorse or promote products derived from this software without
// specific prior written permission.

// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//=================================================================================================

#ifndef HECTOR_GAZEBO_PLUGINS_GAZEBO_ROS_WIRELESS_RECEIVER_H
#define HECTOR_GAZEBO_PLUGINS_GAZEBO_ROS_WIRELESS_RECEIVER_H

#include <gazebo/common/Plugin.hh>

#include <ros/callback_queue.h>
#include <ros/ros.h>

#include <sensor_msgs/PointCloud.h>
#include <geometry_msgs/PoseStamped.h>
#include <hector_gazebo_plugins/sensor_model.h>
#include <hector_gazebo_plugins/update_timer.h>


#include <dynamic_reconfigure/server.h>
#include <gazebo/sensors/Sensor.hh>

namespace gazebo
{

class GazeboRosWirelessReceiver : public SensorPlugin
{
public:
GazeboRosWirelessReceiver();
virtual ~GazeboRosWirelessReceiver();

protected:
virtual void Load(sensors::SensorPtr _sensor, sdf::ElementPtr _sdf);
virtual void Reset();
virtual void Update();

private:
/// \brief The parent World
physics::WorldPtr world;

sensors::SensorPtr sensor_;

ros::NodeHandle* node_handle_;

ros::Publisher transmitter_pub_;
ros::Publisher rss_pub_;
ros::Publisher AoA_pub_;
ros::Publisher receiver_pub_;
int transmitter_count_;


/// \brief Parent entity of this sensor
physics::EntityPtr parentEntity;

std::string namespace_;
std::string topic_;
std::string frame_id_;

SensorModel rss_sensor_model_;
SensorModel3 AoA_sensor_model_;

UpdateTimer updateTimer;
event::ConnectionPtr updateConnection;

boost::shared_ptr<dynamic_reconfigure::Server<SensorModelConfig> > dynamic_reconfigure_server_;
};

} // namespace gazebo

#endif // HECTOR_GAZEBO_PLUGINS_GAZEBO_ROS_SONAR_H
Loading