33 #include <OGRE/OgreVector3.h> 34 #include <OGRE/OgreSceneNode.h> 35 #include <OGRE/OgreSceneManager.h> 38 #include <eigen3/unsupported/Eigen/Splines> 70 static double timeOld_;
71 if( timeOld_ == msg->header.stamp.toSec() ){
return; }
72 timeOld_ = msg->header.stamp.toSec();
74 Eigen::MatrixXd vKnots(1, msg->knots.size() );
75 Eigen::MatrixXd mCtrls(msg->ctrls.size(), msg->ctrls[0].val.size() );
76 for(
int i = 0; i < vKnots.cols(); ++i) { vKnots(i) = msg->knots[i]; }
77 for(
int i = 0; i < mCtrls.rows(); ++i) {
for(
int j = 0; j < mCtrls.cols(); ++j) { mCtrls(i,j) = msg->ctrls[i].val[j]; } }
84 Eigen::SplineTraits< Eigen::Spline3d >::DerivativeType diff =
spline_->derivatives(i / (
double)
pointsNrPath_, 1);
85 double v_x = diff(0,1);
86 double v_y = diff(1,1);
89 Ogre::Quaternion rotation = Ogre::Quaternion ( Ogre::Radian( (*
spline_)(i / (
double)pointsNrPath_ )(2) + atan2(v_y, v_x) ), Ogre::Vector3::UNIT_Z );
90 Ogre::Quaternion rotation2 = Ogre::Quaternion ( Ogre::Radian( -Ogre::Math::PI/2.), Ogre::Vector3::UNIT_Y );
93 splinePtsXY_[i]->setPosition ( Ogre::Vector3 ( p_x, p_y, 0 ) );
103 Eigen::SplineTraits< Eigen::Spline3d >::DerivativeType diff =
spline_->derivatives(i / (
double)
pointsNrOrient_, 1);
104 double v_x = diff(0,1);
105 double v_y = diff(1,1);
108 Ogre::Quaternion rotation = Ogre::Quaternion ( Ogre::Radian( (*
spline_)(i / (
double)pointsNrOrient_ )(2) + atan2(v_y, v_x) ), Ogre::Vector3::UNIT_Z );
109 Ogre::Quaternion rotation2 = Ogre::Quaternion ( Ogre::Radian( -Ogre::Math::PI/2.), Ogre::Vector3::UNIT_Y );
144 Ogre::Vector3 posOld = splineXYi->getPosition();
145 Ogre::Quaternion orientOld = splineXYi->getOrientation();
148 splineXYi->setPosition ( posOld );
149 splineXYi->setOrientation ( orientOld );
174 double p_x = splineEval(0,0), p_y = splineEval(1,0);
175 double v_x = splineEval(0,1), v_y = splineEval(1,1);
177 Ogre::Quaternion rotation = Ogre::Quaternion ( Ogre::Radian( splineEval(2,0) + atan2(v_y, v_x) ), Ogre::Vector3::UNIT_Z );
178 Ogre::Quaternion rotation2 = Ogre::Quaternion ( Ogre::Radian( -Ogre::Math::PI/2.), Ogre::Vector3::UNIT_Y );
182 splinePtsXY_[i]->setPosition ( Ogre::Vector3 ( p_x, p_y, 0 ) );
195 double p_x = splineEval(0,0), p_y = splineEval(1,0);
196 double v_x = splineEval(0,1), v_y = splineEval(1,1);
198 Ogre::Quaternion rotation = Ogre::Quaternion ( Ogre::Radian( splineEval(2,0) + atan2(v_y, v_x) ), Ogre::Vector3::UNIT_Z );
199 Ogre::Quaternion rotation2 = Ogre::Quaternion ( Ogre::Radian( -Ogre::Math::PI/2.), Ogre::Vector3::UNIT_Y );
void setFrameOrientation(const Ogre::Quaternion &orientation)
void setOrientPointsNr(int pointsNr)
Ogre::SceneNode * frame_node_
Ogre::ColourValue colorOrient_
void setShape(rviz::Shape::Type shape_type)
void setPathColor(Ogre::ColourValue color)
void setMessage(const tuw_nav_msgs::Spline::ConstPtr &msg)
void setOrientScale(float scale)
std::vector< boost::shared_ptr< rviz::Arrow > > splinePtsTheta_
Ogre::ColourValue colorPath_
rviz::Shape::Type shape_type_
boost::shared_ptr< Eigen::Spline3d > spline_
Ogre::SceneManager * scene_manager_
void setOrientColor(Ogre::ColourValue color)
SplineVisual(Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node)
void setPathScale(float scale)
void setPathPointsNr(int pointsNr)
std::vector< boost::shared_ptr< rviz::Shape > > splinePtsXY_
void setFramePosition(const Ogre::Vector3 &position)