18 #ifndef VMRC_GAZEBO_SCORING_PLUGIN_HH_ 19 #define VMRC_GAZEBO_SCORING_PLUGIN_HH_ 25 #include <gazebo/common/Events.hh> 26 #include <gazebo/common/Plugin.hh> 27 #include <gazebo/common/Time.hh> 28 #include <gazebo/physics/World.hh> 30 #include "vmrc_gazebo/Task.h" 105 protected:
void Load(gazebo::physics::WorldPtr _world,
106 sdf::ElementPtr _sdf);
110 protected:
double Score()
const;
114 protected:
void SetScore(
double _newScore);
118 protected: std::string
TaskName()
const;
122 protected: std::string
TaskState()
const;
126 protected: gazebo::common::Time
ElapsedTime()
const;
155 private:
virtual void OnReady();
174 protected: gazebo::physics::WorldPtr
world;
183 protected: std::string
topic =
"/vmrc/task/info";
195 private: sdf::ElementPtr
sdf;
240 private: std::unique_ptr<ros::NodeHandle>
rosNode;
void UpdateTime()
Update all time-related variables.
std::string TaskName() const
Get the task name.
double Score() const
Get the current score.
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().
ScoringPlugin()=default
Class constructor.
gazebo::common::Time currentTime
Current time (simulation).
void UpdateTaskMessage()
Update the task stats message.
std::string TaskState() const
Get the task state.
gazebo::common::Time remainingTime
Remaining time since the start of the task (running state).
vmrc_gazebo::Task taskMsg
The next task message to be published.
void Load(gazebo::physics::WorldPtr _world, sdf::ElementPtr _sdf)
double runningStateDuration
Duration (seconds) of the running state (max task time).
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.
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.
std::unique_ptr< ros::NodeHandle > rosNode
ROS node handle.
void Update()
Callback executed at every world update.
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.
gazebo::event::ConnectionPtr updateConnection
Pointer to the update event connection.
gazebo::common::Time RemainingTime() const
Remaining time in the running state.
std::string topic
Topic where the task stats are published.
double readyStateDuration
Duration (seconds) of the ready state.
std::string taskName
The name of the task.
virtual void OnFinished()
Callback executed when the task state transition into "finished".
bool timedOut
Whether the current task has timed out or not.
bool ParseJoints()
Parse the joints section of the SDF block.
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.