26 GZ_ASSERT(_parent !=
nullptr,
"Received NULL model pointer");
32 "has not been initialized, unable to load plugin. " <<
"Load the Gazebo " 33 "system plugin 'libgazebo_ros_api_plugin.so' in the gazebo_ros package)");
38 std::string modelName = _parent->GetName();
39 auto delim = modelName.find(
":");
40 if (delim != std::string::npos)
41 modelName = modelName.substr(0, delim);
43 std::string ns = modelName;
44 if (_sdf->HasElement(
"robotNamespace"))
45 ns = _sdf->GetElement(
"robotNamespace")->Get<std::string>();
49 "missing <robotNamespace>, defaulting to %s", ns.c_str());
53 std::string topicName =
"color";
54 if (_sdf->HasElement(
"topicName"))
55 topicName = _sdf->GetElement(
"topicName")->Get<std::string>();
59 "missing <topicName>, defaulting to %s", topicName.c_str());
75 gazebo::common::Color gazebo_color(_msg->r, _msg->g, _msg->b, _msg->a);
78 this->
visual->SetAmbient(gazebo_color);
79 this->
visual->SetDiffuse(gazebo_color);
#define ROS_INFO_NAMED(name,...)
ros::Subscriber colorSub
Subscriber to accept color change requests.
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL bool isInitialized()
void ColorCallback(const std_msgs::ColorRGBAConstPtr &_msg)
gazebo::rendering::VisualPtr visual
Pointer to the visual element to modify.
#define ROS_DEBUG_NAMED(name,...)
Visual plugin for changing the color of some visual elements using ROS messages. This plugin accepts ...
#define ROS_FATAL_STREAM_NAMED(name, args)
void Load(gazebo::rendering::VisualPtr _parent, sdf::ElementPtr _sdf)
GZ_REGISTER_VISUAL_PLUGIN(GazeboRosVideo)
ros::NodeHandle nh
ROS Node handle.