30 #include <OGRE/OgreVector3.h> 31 #include <OGRE/OgreSceneNode.h> 32 #include <OGRE/OgreSceneManager.h> 35 #include <eigen3/unsupported/Eigen/Splines> 67 static double timeOld_;
68 if( timeOld_ == msg->header.stamp.toSec() ){
return; }
69 timeOld_ = msg->header.stamp.toSec();
71 Eigen::MatrixXd vKnots(1, msg->knots.size() );
72 Eigen::MatrixXd mCtrls(msg->ctrls.size(), msg->ctrls[0].val.size() );
73 for(
int i = 0; i < vKnots.cols(); ++i) { vKnots(i) = msg->knots[i]; }
74 for(
int i = 0; i < mCtrls.rows(); ++i) {
for(
int j = 0; j < mCtrls.cols(); ++j) { mCtrls(i,j) = msg->ctrls[i].val[j]; } }
81 Eigen::SplineTraits< Eigen::Spline3d >::DerivativeType diff =
spline_->derivatives(i / (
double)
pointsNrPath_, 1);
82 double v_x = diff(0,1);
83 double v_y = diff(1,1);
86 Ogre::Quaternion rotation = Ogre::Quaternion ( Ogre::Radian( (*
spline_)(i / (
double)pointsNrPath_ )(2) + atan2(v_y, v_x) ), Ogre::Vector3::UNIT_Z );
87 Ogre::Quaternion rotation2 = Ogre::Quaternion ( Ogre::Radian( -Ogre::Math::PI/2.), Ogre::Vector3::UNIT_Y );
90 splinePtsXY_[i]->setPosition ( Ogre::Vector3 ( p_x, p_y, 0 ) );
100 Eigen::SplineTraits< Eigen::Spline3d >::DerivativeType diff =
spline_->derivatives(i / (
double)
pointsNrOrient_, 1);
101 double v_x = diff(0,1);
102 double v_y = diff(1,1);
105 Ogre::Quaternion rotation = Ogre::Quaternion ( Ogre::Radian( (*
spline_)(i / (
double)pointsNrOrient_ )(2) + atan2(v_y, v_x) ), Ogre::Vector3::UNIT_Z );
106 Ogre::Quaternion rotation2 = Ogre::Quaternion ( Ogre::Radian( -Ogre::Math::PI/2.), Ogre::Vector3::UNIT_Y );
141 Ogre::Vector3 posOld = splineXYi->getPosition();
142 Ogre::Quaternion orientOld = splineXYi->getOrientation();
145 splineXYi->setPosition ( posOld );
146 splineXYi->setOrientation ( orientOld );
171 double p_x = splineEval(0,0), p_y = splineEval(1,0);
172 double v_x = splineEval(0,1), v_y = splineEval(1,1);
174 Ogre::Quaternion rotation = Ogre::Quaternion ( Ogre::Radian( splineEval(2,0) + atan2(v_y, v_x) ), Ogre::Vector3::UNIT_Z );
175 Ogre::Quaternion rotation2 = Ogre::Quaternion ( Ogre::Radian( -Ogre::Math::PI/2.), Ogre::Vector3::UNIT_Y );
179 splinePtsXY_[i]->setPosition ( Ogre::Vector3 ( p_x, p_y, 0 ) );
192 double p_x = splineEval(0,0), p_y = splineEval(1,0);
193 double v_x = splineEval(0,1), v_y = splineEval(1,1);
195 Ogre::Quaternion rotation = Ogre::Quaternion ( Ogre::Radian( splineEval(2,0) + atan2(v_y, v_x) ), Ogre::Vector3::UNIT_Z );
196 Ogre::Quaternion rotation2 = Ogre::Quaternion ( Ogre::Radian( -Ogre::Math::PI/2.), Ogre::Vector3::UNIT_Y );
Ogre::ColourValue colorPath_
void setOrientColor(Ogre::ColourValue color)
void setOrientPointsNr(int pointsNr)
boost::shared_ptr< Eigen::Spline3d > spline_
void setOrientScale(float scale)
void setPathColor(Ogre::ColourValue color)
void setFramePosition(const Ogre::Vector3 &position)
void setShape(rviz::Shape::Type shape_type)
std::vector< boost::shared_ptr< rviz::Arrow > > splinePtsTheta_
rviz::Shape::Type shape_type_
SplineVisual(Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node)
Ogre::ColourValue colorOrient_
void setMessage(const tuw_spline_msgs::Spline::ConstPtr &msg)
void setFrameOrientation(const Ogre::Quaternion &orientation)
Ogre::SceneManager * scene_manager_
void setPathPointsNr(int pointsNr)
std::vector< boost::shared_ptr< rviz::Shape > > splinePtsXY_
void setPathScale(float scale)
Ogre::SceneNode * frame_node_