54 #include <OgreSceneManager.h> 55 #include <OgreSceneNode.h> 65 "Robot Description",
"robot_description",
"The name of the ROS parameter where the URDF for the robot is loaded",
69 "Robot State Topic",
"display_robot_state", ros::message_traits::datatype<moveit_msgs::DisplayRobotState>(),
70 "The topic on which the moveit_msgs::RobotState messages are received",
this, SLOT(
changedRobotStateTopic()),
75 new rviz::StringProperty(
"Robot Root Link",
"",
"Shows the name of the root link for the robot model",
this,
85 new rviz::ColorProperty(
"Attached Body Color", QColor(150, 50, 150),
"The color for the attached bodies",
this,
89 new rviz::BoolProperty(
"Show Highlights",
true,
"Specifies whether link highlighting is enabled",
this,
92 new rviz::BoolProperty(
"Visual Enabled",
true,
"Whether to display the visual representation of the robot.",
this,
95 "Whether to display the collision representation of the robot.",
111 Display::onInitialize();
115 robot_->setVisible(
false);
132 for (
int i = 0; i < links_prop->numChildren(); ++i)
134 Property* link_prop = links_prop->childAt(i);
135 link_prop->setValue(
value);
144 link->
setColor(color.r, color.g, color.b);
163 for (std::map<std::string, std_msgs::ColorRGBA>::iterator it =
highlights_.begin(); it !=
highlights_.end(); ++it)
170 for (std::map<std::string, std_msgs::ColorRGBA>::iterator it =
highlights_.begin(); it !=
highlights_.end(); ++it)
187 static bool operator!=(
const std_msgs::ColorRGBA& a,
const std_msgs::ColorRGBA& b)
189 return a.r != b.r || a.g != b.g || a.b != b.b || a.a != b.a;
194 if (highlight_links.empty() &&
highlights_.empty())
197 std::map<std::string, std_msgs::ColorRGBA> highlights;
198 for (moveit_msgs::DisplayRobotState::_highlight_links_type::const_iterator it = highlight_links.begin();
199 it != highlight_links.end(); ++it)
201 highlights[it->id] = it->color;
206 std::map<std::string, std_msgs::ColorRGBA>::iterator ho =
highlights_.begin();
207 std::map<std::string, std_msgs::ColorRGBA>::iterator hn = highlights.begin();
208 while (ho !=
highlights_.end() || hn != highlights.end())
215 else if (hn == highlights.end())
220 else if (hn->first < ho->first)
225 else if (hn->first > ho->first)
230 else if (hn->second != ho->second)
252 std_msgs::ColorRGBA color_msg;
253 color_msg.r = color.redF();
254 color_msg.g = color.greenF();
255 color_msg.b = color.blueF();
257 robot_->setDefaultAttachedObjectColor(color_msg);
278 std_msgs::ColorRGBA color_msg;
279 color_msg.r = color.redF();
280 color_msg.g = color.greenF();
281 color_msg.b = color.blueF();
283 robot_->setDefaultAttachedObjectColor(color_msg);
293 if (static_cast<bool>(
kstate_))
308 robot_state::robotStateMsgToRobotState(state_msg->state, *
kstate_);
329 link->
setColor(color.redF(), color.greenF(), color.blueF());
388 robot_->setVisible(
false);
389 Display::onDisable();
394 Display::update(wall_dt, ros_dt);
419 Ogre::Vector3 position;
420 Ogre::Quaternion orientation;
430 Display::fixedFrameChanged();
virtual QColor getColor() const
rviz::BoolProperty * enable_link_highlight_
void unsetLinkColor(const std::string &link_name)
rviz::StringProperty * root_link_name_property_
Update the links of an rviz::Robot using a robot_state::RobotState.
void changedEnableCollisionVisible()
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
DisplayContext * context_
rviz::BoolProperty * enable_visual_visible_
virtual void onInitialize()
void calculateOffsetPosition()
Set the scene node's position, given the target frame and the planning frame.
void changedRootLinkName()
virtual float getFloat() const
void changedRobotSceneAlpha()
virtual void update(float wall_dt, float ros_dt)
RobotLink * getLink(const std::string &name)
Ogre::SceneNode * scene_node_
rviz::BoolProperty * enable_collision_visible_
void setRobotHighlights(const moveit_msgs::DisplayRobotState::_highlight_links_type &highlight_links)
std::string getStdString()
virtual ~RobotStateDisplay()
void changedAttachedBodyColor()
virtual bool getBool() const
virtual Property * subProp(const QString &sub_name)
void setColor(float red, float green, float blue)
RobotStateVisualizationPtr robot_
void unsetHighlight(const std::string &link_name)
void setHighlight(const std::string &link_name, const std_msgs::ColorRGBA &color)
ros::Subscriber robot_state_subscriber_
rdf_loader::RDFLoaderPtr rdf_loader_
const robot_model::RobotModelConstPtr & getRobotModel() const
rviz::StringProperty * robot_description_property_
virtual FrameManager * getFrameManager() const =0
boost::shared_ptr< Model > ModelSharedPtr
void changedEnableLinkHighlight()
rviz::RosTopicProperty * robot_state_topic_property_
std::map< std::string, std_msgs::ColorRGBA > highlights_
rviz::ColorProperty * attached_body_color_property_
virtual void setRobotAlpha(float a)
Property(const QString &name=QString(), const QVariant default_value=QVariant(), const QString &description=QString(), Property *parent=0, const char *changed_slot=0, QObject *receiver=0)
bool getTransform(const Header &header, Ogre::Vector3 &position, Ogre::Quaternion &orientation)
robot_model::RobotModelConstPtr kmodel_
static bool operator!=(const std_msgs::ColorRGBA &a, const std_msgs::ColorRGBA &b)
void setLinkColor(const std::string &link_name, const QColor &color)
void newRobotStateCallback(const moveit_msgs::DisplayRobotState::ConstPtr &state)
void changedRobotDescription()
rviz::BoolProperty * show_all_links_
robot_state::RobotStatePtr kstate_
virtual void setReadOnly(bool read_only)
bool setStdString(const std::string &std_str)
virtual void setStatus(StatusProperty::Level level, const QString &name, const QString &text)
virtual void fixedFrameChanged()
rviz::FloatProperty * robot_alpha_property_
void changedRobotStateTopic()
void changedEnableVisualVisible()