18 #ifndef VRX_GAZEBO_SCORING_PLUGIN_HH_ 19 #define VRX_GAZEBO_SCORING_PLUGIN_HH_ 22 #include <gazebo/msgs/gz_string.pb.h> 26 #include <gazebo/common/Events.hh> 27 #include <gazebo/common/Plugin.hh> 28 #include <gazebo/common/Time.hh> 29 #include <gazebo/physics/World.hh> 31 #include <gazebo/transport/transport.hh> 32 #include "vrx_gazebo/Task.h" 33 #include "vrx_gazebo/Contact.h" 122 protected:
void Load(gazebo::physics::WorldPtr _world,
123 sdf::ElementPtr _sdf);
127 protected:
double Score()
const;
131 protected:
void SetScore(
double _newScore);
135 protected: std::string
TaskName()
const;
139 protected: std::string
TaskState()
const;
143 protected: gazebo::common::Time
ElapsedTime()
const;
181 private:
virtual void OnReady();
207 protected: gazebo::physics::WorldPtr
world;
222 private: gazebo::transport::NodePtr
gzNode;
246 private: sdf::ElementPtr
sdf;
306 private: std::unique_ptr<ros::NodeHandle>
rosNode;
void UpdateTime()
Update all time-related variables.
std::string TaskName() const
Get the task name.
gazebo::common::Time lastCollisionTime
Last collision time.
double Score() const
Get the current score.
void SetTimeoutScore(double _timeoutScore)
Set the score in case of timeout.
virtual void ReleaseVehicle()
Tries to release the vehicle in case is locked.
std::vector< std::string > lockJointNames
The name of the joints to be dettached during ReleaseVehicle().
float CollisionBuffer
Collision buffer.
std::string contactDebugTopic
Topic where debug collision is published.
gazebo::common::Time currentTime
Current time (simulation).
bool debug
Bool flag for debug.
void UpdateTaskMessage()
Update the task stats message.
std::vector< gazebo::common::Time > collisionTimestamps
Collisions timestamps.
std::string TaskState() const
Get the task state.
gazebo::common::Time remainingTime
Remaining time since the start of the task (running state).
double timeoutScore
Score in case of timeout - added for Navigation task.
void Load(gazebo::physics::WorldPtr _world, sdf::ElementPtr _sdf)
double runningStateDuration
Duration (seconds) of the running state (max task time).
void Exit()
Shutdown Gazebo and ROS.
void Finish()
Finish the current task. This will set the "finished" flag in the task message to true...
ros::Publisher taskPub
Publisher for the task state.
virtual void OnRunning()
Callback executed when the task state transition into "running".
void UpdateTaskState()
Update the state of the current task.
std::vector< std::string > collisionList
Collision list.
gazebo::common::Time ElapsedTime() const
Elapsed time in the running state.
bool ParseSDFParameters()
Parse all SDF parameters.
std::string taskState
The task state.
gazebo::common::Time elapsedTime
void PublishStats()
Publish the task stats over a ROS topic.
gazebo::transport::NodePtr gzNode
gazebo node pointer
std::unique_ptr< ros::NodeHandle > rosNode
ROS node handle.
vrx_gazebo::Contact contactMsg
ROS Contact Msg.
void Update()
Callback executed at every world update.
vrx_gazebo::Task taskMsg
The next task message to be published.
gazebo::common::Time runningTime
Absolute time specifying the start of the running state.
gazebo::common::Time readyTime
Absolute time specifying the start of the ready state.
A plugin that provides common functionality to any scoring plugin. This plugin defines four different...
gazebo::physics::WorldPtr world
A world pointer.
gazebo::common::Time finishTime
Absolute time specifying the start of the finish state.
gazebo::physics::ModelPtr vehicleModel
Pointer to the vehicle to score.
sdf::ElementPtr sdf
Pointer to the SDF plugin element.
double initialStateDuration
Duration (seconds) of the initial state.
gazebo::common::Time lastStatsSent
Time at which the last message was sent.
double GetTimeoutScore()
Get the timeoutScore.
gazebo::event::ConnectionPtr updateConnection
Pointer to the update event connection.
gazebo::common::Time RemainingTime() const
Remaining time in the running state.
gazebo::transport::SubscriberPtr collisionSub
Collision detection node subscriber.
void OnCollisionMsg(ConstContactsPtr &_contacts)
Callback function when collision occurs in the world.
double readyStateDuration
Duration (seconds) of the ready state.
std::string taskName
The name of the task.
std::string taskInfoTopic
Topic where the task stats are published.
virtual void OnFinished()
Callback executed when the task state transition into "finished".
bool timedOut
Whether the current task has timed out or not.
ros::Publisher contactPub
Publisher for the collision.
ScoringPlugin()
Class constructor.
bool ParseJoints()
Parse the joints section of the SDF block.
gazebo::transport::PublisherPtr serverControlPub
gazebo server control publisher
int collisionCounter
Collisions counter.
void SetScore(double _newScore)
Set the score.
virtual void OnReady()
Callback executed when the task state transition into "ready".
std::string vehicleName
The name of the vehicle to score.
virtual void OnCollision()
Callback executed when a collision is detected for the WAMV.
double GetRunningStateDuration()
Get running duration.