@@ -49,6 +49,7 @@ void FreeGaitPreviewVisual::setEnabledModul(Modul modul, bool enable)
4949
5050void FreeGaitPreviewVisual::showEnabled ()
5151{
52+ ROS_DEBUG (" FreeGaitPreviewVisual::showEnabled()" );
5253 for (const auto & modul : enabledModuls_) {
5354 switch (modul) {
5455 case Modul::EndEffectorTrajectories:
@@ -75,36 +76,37 @@ void FreeGaitPreviewVisual::hideEnabled()
7576
7677void FreeGaitPreviewVisual::showEndEffectorTrajectories (const float width, const Ogre::ColourValue& color)
7778{
79+ ROS_DEBUG (" Rendering end effector trajectories." );
7880 if (!stateBatchPtr_) return ;
7981
8082 // Define size.
8183 const size_t nEndEffectors (stateBatchPtr_->getEndEffectorPositions ().size ());
8284 const size_t nStates (stateBatchPtr_->getStates ().size ());
8385
8486 // Cleanup.
85- // TODO Segfaults. Whats the problem?
86- // if (endEffectorTrajectories_.size() != nEndEffectors) {
87- // endEffectorTrajectories_.clear();
88- // for (size_t i; i < nEndEffectors; ++i) {
89- // endEffectorTrajectories_.push_back(std::unique_ptr<rviz::BillboardLine>(new rviz::BillboardLine(sceneManager_, frameNode_)));
90- // }
91- // }
87+ if (endEffectorTrajectories_.size () != nEndEffectors) {
88+ endEffectorTrajectories_.clear ();
89+ for (size_t i = 0 ; i < nEndEffectors; ++i) {
90+ endEffectorTrajectories_.push_back (std::unique_ptr<rviz::BillboardLine>(new rviz::BillboardLine (sceneManager_, frameNode_)));
91+ }
92+ }
9293
93- for (size_t i; i < nEndEffectors; ++i) {
94+ for (size_t i = 0 ; i < nEndEffectors; ++i) {
95+ auto & trajectory = endEffectorTrajectories_[i];
9496 // For each foot trajectory.
95- endEffectorTrajectories_.push_back (std::unique_ptr<rviz::BillboardLine>(new rviz::BillboardLine (sceneManager_, frameNode_)));
96- endEffectorTrajectories_[i]->clear ();
97- endEffectorTrajectories_[i]->setLineWidth (width);
98- endEffectorTrajectories_[i]->setColor (color.r , color.g , color.b , color.a );
99- endEffectorTrajectories_[i]->setNumLines (1 );
100- endEffectorTrajectories_[i]->setMaxPointsPerLine (nStates);
97+ trajectory->clear ();
98+ trajectory->setLineWidth (width);
99+ trajectory->setColor (color.r , color.g , color.b , color.a );
100+ trajectory->setNumLines (1 );
101+ trajectory->setMaxPointsPerLine (nStates);
101102
102- free_gait::Position previousPosition;
103+ free_gait::Position previousPosition ( free_gait::Position::Zero ()) ;
103104 for (const auto & positionElement : stateBatchPtr_->getEndEffectorPositions ()[i]) {
104- auto & position = positionElement.second ;
105- if ((position - previousPosition).norm () < 0.01 ) continue ;
105+ const auto & position = positionElement.second ;
106+ if ((position - previousPosition).norm () < 0.01 ) continue ; // TODO Set as parameter.
107+ previousPosition = position;
106108 const auto point = Ogre::Vector3 (position.x (), position.y (), position.z ());
107- endEffectorTrajectories_[i] ->addPoint (point);
109+ trajectory ->addPoint (point);
108110 }
109111 }
110112}
0 commit comments