18 #ifndef VMRC_GAZEBO_LIGHT_BUOY_PLUGIN_HH_ 19 #define VMRC_GAZEBO_LIGHT_BUOY_PLUGIN_HH_ 22 #include <std_msgs/ColorRGBA.h> 23 #include <std_srvs/Trigger.h> 31 #include <gazebo/gazebo.hh> 67 public:
void Load(gazebo::rendering::VisualPtr _parent,
68 sdf::ElementPtr _sdf);
76 private:
static std_msgs::ColorRGBA
CreateColor(
const double _r,
88 private:
bool ParseSDF(sdf::ElementPtr _sdf);
96 std_srvs::Trigger::Response &_res);
110 private:
using Colors_t = std::pair<std_msgs::ColorRGBA, std::string>;
118 private:
static const std::array<Colors_t, 5>
kColors;
124 private: std::vector<gazebo::rendering::VisualPtr>
visuals;
143 private: std::string
ns;
149 private: gazebo::rendering::ScenePtr
scene;
155 private: gazebo::common::Timer
timer;
static std_msgs::ColorRGBA CreateColor(const double _r, const double _g, const double _b, const double _a)
Creates a std_msgs::ColorRGBA message from 4 doubles.
std::vector< gazebo::rendering::VisualPtr > visuals
Pointer to the visual elements to modify.
void Load(gazebo::rendering::VisualPtr _parent, sdf::ElementPtr _sdf)
bool shuffleEnabled
Whether shuffle is enabled via a ROS topic or not.
Visual plugin for changing the color of some visual elements using ROS messages. This plugin accepts ...
std::vector< std::string > visualNames
Collection of visual names.
bool ParseSDF(sdf::ElementPtr _sdf)
Parse all SDF parameters.
gazebo::common::Timer timer
Timer used to switch colors every second.
ros::NodeHandle nh
ROS Node handle.
static uint8_t IndexFromColor(const std::string &_color)
Return the index of the color from its string.
std::string ns
ROS namespace.
std::pair< std_msgs::ColorRGBA, std::string > Colors_t
void Update()
Display the next color in the sequence, or start over if at the end.
static const std::array< Colors_t, 5 > kColors
List of the color options (red, green, blue, yellow and no color) with their string name for logging...
Pattern_t pattern
The color pattern.
gazebo::rendering::ScenePtr scene
Pointer to the scene node.
std::string topic
ROS topic.
std::mutex mutex
Locks state and pattern member variables.
std::array< uint8_t, 4 > Pattern_t
bool ChangePattern(std_srvs::Trigger::Request &_req, std_srvs::Trigger::Response &_res)
Callback for change pattern service, calls other changePattern internaly.
uint8_t state
Track current index in pattern.
gazebo::event::ConnectionPtr updateConnection
Connects to rendering update event.
ros::ServiceServer changePatternServer
Service to generate and display a new color sequence.