66 #include <OgreSceneNode.h>
68 #include <boost/algorithm/string/replace.hpp>
69 #include <boost/algorithm/string/trim.hpp>
76 "Immediately show newly planned trajectory, "
77 "interrupting the currently displayed one.",
81 "Loop Animation",
false,
"Indicates whether the last received path is to be animated in a loop", parent,
82 SLOT(changedLoopDisplay()),
this);
84 trail_display_property_ =
85 new rviz::BoolProperty(
"Show Trail",
false,
"Show a path trail", parent, SLOT(changedTrail()),
this);
87 state_display_time_property_ =
89 "The amount of wall-time to wait in between displaying "
90 "states along a received trajectory path",
92 state_display_time_property_->addOptionStd(
"REALTIME");
93 state_display_time_property_->addOptionStd(
"0.05 s");
94 state_display_time_property_->addOptionStd(
"0.1 s");
95 state_display_time_property_->addOptionStd(
"0.5 s");
98 "Trail Step Size", 1,
"Specifies the step size of the samples shown in the trajectory trail.", parent,
99 SLOT(changedTrail()),
this);
100 trail_step_size_property_->setMin(1);
103 robot_property_ =
new rviz::Property(
"Robot", QString(), QString(), parent);
105 "Indicates whether the geometry of the robot as defined for "
106 "visualisation purposes should be displayed",
107 robot_property_, SLOT(changedRobotVisualEnabled()),
this);
109 robot_collision_enabled_property_ =
111 "Indicates whether the geometry of the robot as defined "
112 "for collision detection purposes should be displayed",
113 robot_property_, SLOT(changedRobotCollisionEnabled()),
this);
115 robot_alpha_property_ =
new rviz::FloatProperty(
"Robot Alpha", 0.5f,
"Specifies the alpha for the robot links",
116 robot_property_, SLOT(changedRobotAlpha()),
this);
117 robot_alpha_property_->setMin(0.0);
118 robot_alpha_property_->setMax(1.0);
120 robot_color_property_ =
121 new rviz::ColorProperty(
"Fixed Robot Color", QColor(150, 50, 150),
"The color of the animated robot",
122 robot_property_, SLOT(changedRobotColor()),
this);
125 "Specifies whether the fixed robot color should be used."
126 " If not, the original color is used.",
127 robot_property_, SLOT(enabledRobotColor()),
this);
130 scene_enabled_property_ =
131 new rviz::BoolProperty(
"Scene",
true,
"Show Planning Scene", parent, SLOT(changedSceneEnabled()),
this);
133 scene_alpha_property_ =
new rviz::FloatProperty(
"Scene Alpha", 0.9f,
"Specifies the alpha for the scene geometry",
134 scene_enabled_property_, SLOT(renderCurrentScene()),
this);
135 scene_alpha_property_->setMin(0.0);
136 scene_alpha_property_->setMax(1.0);
139 "Scene Color", QColor(50, 230, 50),
"The color for the planning scene obstacles (if a color is not defined)",
140 scene_enabled_property_, SLOT(renderCurrentScene()),
this);
142 attached_body_color_property_ =
143 new rviz::ColorProperty(
"Attached Body Color", QColor(150, 50, 150),
"The color for the attached bodies",
144 scene_enabled_property_, SLOT(changedAttachedBodyColor()),
this);
146 octree_render_property_ =
new rviz::EnumProperty(
"Voxel Rendering",
"Occupied Voxels",
"Select voxel type.",
147 scene_enabled_property_, SLOT(renderCurrentScene()),
this);
153 octree_coloring_property_ =
new rviz::EnumProperty(
"Voxel Coloring",
"Z-Axis",
"Select voxel coloring mode",
154 scene_enabled_property_, SLOT(renderCurrentScene()),
this);
160 connect(marker_visual_, SIGNAL(allAtOnceChanged(
bool)),
this, SLOT(onAllAtOnceChanged(
bool)));
198 if (window_context) {
268 trail_.resize(
t->getWayPointCount() / stepsize);
269 for (std::size_t i = 0; i <
trail_.size(); i++) {
270 int waypoint_i = std::min(i * stepsize,
t->getWayPointCount() - 1);
294 for (
auto& waypoint :
trail_)
301 for (
auto& waypoint :
trail_)
342 if (tm ==
"REALTIME")
345 boost::replace_all(tm,
"s",
"");
349 t = boost::lexical_cast<float>(tm);
350 }
catch (
const boost::bad_lexical_cast& ex) {
390 int max_state_index = std::max<int>(1, waypoint_count);
408 }
else if (tm < 0.0) {
441 int start = std::max(0, previous_state / stepsize);
443 bool show =
start <= end;
445 std::swap(start, end);
446 end = std::min<int>(end,
trail_.size());
448 trail_[start]->setVisible(show);
460 moveit::core::RobotStateConstPtr robot_state;
461 planning_scene::PlanningSceneConstPtr scene;
462 if (index + 1 >= waypoint_count) {
463 if (index == 0 && waypoint_count == 0)
474 if (previous_index < 0 || previous_index >=
static_cast<int>(waypoint_count) ||
489 std_msgs::ColorRGBA color;
490 color.r = attached_color.redF();
491 color.g = attached_color.greenF();
492 color.b = attached_color.blueF();
496 scene->getKnownObjectColors(color_map);
509 rviz::Color env_color(color.redF(), color.greenF(), color.blueF());
511 rviz::Color attached_color(color.redF(), color.greenF(), color.blueF());
519 DisplaySolutionPtr
s(
new DisplaySolution);
520 s->setFromMessage(
scene_, msg);
525 if (lock_display || !
s->empty()) {
547 for (
size_t i = 0, end =
s->numSubSolutions(); i != end; ++i) {
569 for (
auto& link : robot->
getLinks())
570 link.second->unsetColor();
574 for (
auto& link : robot->
getLinks())
575 link.second->setColor(color.redF(), color.greenF(), color.blueF());
607 if (visible && node->getParent() != parent) {
608 parent->addChild(node);
615 }
else if (!visible && node->getParent())
616 node->getParent()->removeChild(node);