16 #ifndef __ROS_BASE_PLUGIN_HH__ 17 #define __ROS_BASE_PLUGIN_HH__ 19 #include <gazebo/common/common.hh> 20 #include <gazebo/physics/physics.hh> 23 #include <std_msgs/Bool.h> 24 #include <uuv_sensor_ros_plugins_msgs/ChangeSensorState.h> 25 #include <geometry_msgs/TransformStamped.h> 26 #include <gazebo/sensors/Noise.hh> 27 #include <boost/shared_ptr.hpp> 28 #include <boost/bind.hpp> 29 #include <tf/tfMessage.h> 51 public:
virtual bool OnUpdate(
const common::UpdateInfo&) = 0;
63 protected: physics::WorldPtr
world;
86 protected: std::default_random_engine
rndGen;
89 protected: std::map<std::string, std::normal_distribution<double>>
93 protected: std_msgs::Bool
isOn;
129 protected:
bool IsOn();
136 uuv_sensor_ros_plugins_msgs::ChangeSensorState::Request& _req,
137 uuv_sensor_ros_plugins_msgs::ChangeSensorState::Response& _res);
140 protected:
void GetTFMessage(
const tf::tfMessage::ConstPtr &_msg);
159 #endif // __ROS_BASE_PLUGIN_HH__ physics::LinkPtr referenceLink
Reference link.
double updateRate
Sensor update rate.
double GetGaussianNoise(double _amp)
Returns noise value for a function with zero mean from the default Gaussian noise model...
bool EnableMeasurement(const common::UpdateInfo &_info) const
Enables generation of simulated measurement if the timeout since the last update has been reached...
ignition::math::Pose3d referenceFrame
Pose of the reference frame wrt world frame.
physics::WorldPtr world
Pointer to the world.
ROSBasePlugin()
Class constructor.
common::Time lastMeasurementTime
(Simulation) time when the last sensor measurement was generated.
double noiseAmp
Noise amplitude.
std::map< std::string, std::normal_distribution< double > > noiseModels
Normal distribution describing the noise models.
event::ConnectionPtr updateConnection
Pointer to the update event connection.
bool ChangeSensorState(uuv_sensor_ros_plugins_msgs::ChangeSensorState::Request &_req, uuv_sensor_ros_plugins_msgs::ChangeSensorState::Response &_res)
Change sensor state (ON/OFF)
void UpdateReferenceFramePose()
Updates the pose of the reference frame wrt the world frame.
bool AddNoiseModel(std::string _name, double _sigma)
Add noise normal distribution to the list.
transport::NodePtr gazeboNode
Gazebo's node handle for transporting measurement messages.
virtual bool OnUpdate(const common::UpdateInfo &)=0
Update callback from simulation.
bool InitBasePlugin(sdf::ElementPtr _sdf)
Initialize base plugin.
double noiseSigma
Noise standard deviation.
std_msgs::Bool isOn
Flag to control the generation of output messages.
transport::PublisherPtr gazeboSensorOutputPub
Gazebo's publisher for transporting measurement messages.
std::string referenceFrameID
Frame ID of the reference frame.
virtual ~ROSBasePlugin()
Class destructor.
ros::ServiceServer changeSensorSrv
Service server object.
std::default_random_engine rndGen
Pseudo random number generator.
std::string sensorOutputTopic
Name of the sensor's output topic.
ros::Publisher rosSensorOutputPub
Gazebo's publisher for transporting measurement messages.
boost::shared_ptr< ros::NodeHandle > rosNode
ROS node handle for communication with ROS.
ros::Publisher pluginStatePub
ROS publisher for the switchable sensor data.
std::string robotNamespace
Robot namespace.
bool isReferenceInit
Flag set to true if reference frame initialized.
ros::Subscriber tfStaticSub
ROS subscriber for the TF static reference frame.
bool gazeboMsgEnabled
Flag set to true if the Gazebo sensors messages are supposed to be published as well (it can avoid un...
void PublishState()
Publish the current state of the plugin.
bool IsOn()
Returns true if the plugin is activated.
void GetTFMessage(const tf::tfMessage::ConstPtr &_msg)
Callback function for the static TF message.