1 #include <OgreVector3.h> 2 #include <OgreSceneNode.h> 3 #include <OgreSceneManager.h> 17 Ogre::SceneNode* parent_node,
36 for (std::map<std::string, urdf::JointSharedPtr>::iterator it =
urdf_model_->joints_.begin();
39 if (it->second->type == urdf::Joint::REVOLUTE)
41 std::string joint_name = it->first;
50 for (std::map<std::string, rviz::BillboardLine*>::iterator it =
effort_circle_.begin();
55 for (std::map<std::string, rviz::Arrow*>::iterator it =
effort_arrow_.begin();
68 value = std::min(value, 1.0
f);
69 value = std::max(value, 0.0
f);
71 float h = value * 5.0f + 1.0f;
79 color[0] = n, color[1] = 0, color[2] = 1;
81 color[0] = 0, color[1] = n, color[2] = 1;
83 color[0] = 0, color[1] = 1, color[2] = n;
85 color[0] = n, color[1] = 1, color[2] = 0;
87 color[0] = 1, color[1] = n, color[2] = 0;
93 int joint_num = msg->name.size();
94 for (
int i = 0; i < joint_num; i++)
96 std::string joint_name = msg->name[i];
97 double effort = msg->effort[i];
100 ROS_WARN_STREAM(
"Invalid effort for joint '" << joint_name <<
"': " << effort);
103 const urdf::Joint* joint =
urdf_model_->getJoint(joint_name).get();
104 int joint_type = joint->type;
105 if (joint_type == urdf::Joint::REVOLUTE)
127 urdf::JointLimitsSharedPtr
limit = joint->limits;
128 double max_effort = limit->effort, effort_value = 0.05;
130 if (max_effort != 0.0)
132 effort_value = std::min(fabs(effort) / max_effort, 1.0) + 0.05;
136 effort_value = fabs(effort) + 0.05;
153 for (
int i = 0; i < 30; i++)
155 Ogre::Vector3 point =
156 Ogre::Vector3((0.05 + effort_value * scale_ * 0.5) *
sin(i * 2 * M_PI / 32),
157 (0.05 + effort_value * scale_ * 0.5) *
cos(i * 2 * M_PI / 32), 0);
162 Ogre::ColourValue color;
164 effort_arrow_[joint_name]->setColor(color.r, color.g, color.b, color.a);
165 effort_circle_[joint_name]->setColor(color.r, color.g, color.b, color.a);
std::map< std::string, Ogre::Quaternion > orientation_
void getRainbowColor(float value, Ogre::ColourValue &color)
void setMessage(const sensor_msgs::JointStateConstPtr &msg)
An object that displays a multi-segment line strip rendered as billboards.
void setFramePosition(const Ogre::Vector3 &position)
std::map< std::string, rviz::Arrow * > effort_arrow_
Ogre::SceneNode * frame_node_
std::map< std::string, Ogre::Vector3 > position_
bool validateFloats(const sensor_msgs::CameraInfo &msg)
std::map< std::string, rviz::BillboardLine * > effort_circle_
Ogre::SceneManager * scene_manager_
#define ROS_WARN_STREAM(args)
std::map< std::string, bool > effort_enabled_
EffortVisual(Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node, boost::shared_ptr< urdf::Model > urdf_model)
void setFrameEnabled(const std::string joint_name, const bool e)
void setFrameOrientation(const Ogre::Quaternion &orientation)
An arrow consisting of a cylinder and a cone.
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
boost::shared_ptr< urdf::Model > urdf_model_
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)