TKTrajectory.hpp
Go to the documentation of this file.
00001 /*
00002  * TKTrajectory.hpp
00003  *
00004  *  Created on: Nov 8, 2011
00005  *      Author: mriedel
00006  */
00007 
00008 #ifndef TKTRAJECTORY_HPP_
00009 #define TKTRAJECTORY_HPP_
00010 
00011 #include <telekyb_defines/telekyb_defines.hpp>
00012 #include <telekyb_defines/telekyb_enums.hpp>
00013 
00014 #include <telekyb_base/Spaces/R3.hpp>
00015 
00016 #include <telekyb_msgs/TKTrajectory.h>
00017 
00018 namespace TELEKYB_NAMESPACE {
00019 
00020 class TKTrajectory {
00021 public:
00022         // Position
00023         Position3D position;
00024         Velocity3D velocity;
00025         Acceleration3D acceleration;
00026         Eigen::Vector3d jerk;
00027         Eigen::Vector3d snap;
00028 
00029         PosControlType xAxisCtrl;
00030         PosControlType yAxisCtrl;
00031         PosControlType zAxisCtrl;
00032 
00033         // Yaw
00034         double yawAngle;
00035         double yawRate;
00036         double yawAcceleration;
00037         YawControlType yawCtrl;
00038 
00039         TKTrajectory();
00040         TKTrajectory(const telekyb_msgs::TKTrajectory& tkTrajMsg);
00041         virtual ~TKTrajectory();
00042 
00043         void toTKTrajMsg(telekyb_msgs::TKTrajectory& tkTrajMsg) const;
00044         void fromTKTrajMsg(const telekyb_msgs::TKTrajectory& tkTrajMsg);
00045 
00046         // Convenience Setters
00047         void setPosition(
00048                         const Position3D& position_,
00049                         const Velocity3D& velocity_ = Velocity3D::Zero(),
00050                         const Acceleration3D& acceleration_ = Acceleration3D::Zero(),
00051                         const Eigen::Vector3d& jerk_ = Eigen::Vector3d::Zero(),
00052                         const Eigen::Vector3d& snap_ = Eigen::Vector3d::Zero()
00053                         );
00054         void setVelocity(
00055                         const Velocity3D& velocity_,
00056                         const Acceleration3D& acceleration_ = Acceleration3D::Zero(),
00057                         const Eigen::Vector3d& jerk_ = Eigen::Vector3d::Zero(),
00058                         const Eigen::Vector3d& snap_ = Eigen::Vector3d::Zero()
00059                         );
00060         void setAcceleration(
00061                         const Acceleration3D& acceleration_,
00062                         const Eigen::Vector3d& jerk_ = Eigen::Vector3d::Zero(),
00063                         const Eigen::Vector3d& snap_ = Eigen::Vector3d::Zero()
00064                         );
00065 
00066         void setYawAngle(
00067                         double yawAngle_,
00068                         double yawRate_ = 0.0,
00069                         double yawAcceleration_ = 0.0
00070                         );
00071         void setYawRate(
00072                         double yawRate_,
00073                         double yawAcceleration_ = 0.0
00074                         );
00075 //      void setYawAcceleration(
00076 //                      double yawAcceleration_
00077 //                      );
00078 
00079         GlobalPosControlType getGlobalPositionControlType() const;
00080 };
00081 
00082 // Inline Functions
00083 inline
00084 void TKTrajectory::setPosition(
00085                 const Position3D& position_,
00086                 const Velocity3D& velocity_,
00087                 const Acceleration3D& acceleration_,
00088                 const Eigen::Vector3d& jerk_,
00089                 const Eigen::Vector3d& snap_
00090                 )
00091 {
00092         position = position_;
00093         velocity = velocity_;
00094         acceleration = acceleration_;
00095         jerk = jerk_;
00096         snap = snap_;
00097 
00098         xAxisCtrl = PosControlType::Position;
00099         yAxisCtrl = PosControlType::Position;
00100         zAxisCtrl = PosControlType::Position;
00101 }
00102 
00103 inline
00104 void TKTrajectory::setVelocity(
00105                 const Velocity3D& velocity_,
00106                 const Acceleration3D& acceleration_,
00107                 const Eigen::Vector3d& jerk_,
00108                 const Eigen::Vector3d& snap_
00109                 )
00110 {
00111         position = Position3D::Zero();
00112         velocity = velocity_;
00113         acceleration = acceleration_;
00114         jerk = jerk_;
00115         snap = snap_;
00116 
00117         xAxisCtrl = PosControlType::Velocity;
00118         yAxisCtrl = PosControlType::Velocity;
00119         zAxisCtrl = PosControlType::Velocity;
00120 }
00121 
00122 inline
00123 void TKTrajectory::setAcceleration(
00124                 const Acceleration3D& acceleration_,
00125                 const Eigen::Vector3d& jerk_,
00126                 const Eigen::Vector3d& snap_
00127                 )
00128 {
00129         position = Position3D::Zero();
00130         velocity = Velocity3D::Zero();
00131         acceleration = acceleration_;
00132         jerk = jerk_;
00133         snap = snap_;
00134 
00135         xAxisCtrl = PosControlType::Acceleration;
00136         yAxisCtrl = PosControlType::Acceleration;
00137         zAxisCtrl = PosControlType::Acceleration;
00138 }
00139 
00140 inline
00141 void TKTrajectory::setYawAngle(
00142                 double yawAngle_,
00143                 double yawRate_,
00144                 double yawAcceleration_
00145                 )
00146 {
00147         yawAngle = yawAngle_;
00148         yawRate = yawRate_;
00149         yawAcceleration = yawAcceleration_;
00150 
00151         yawCtrl = YawControlType::AngleOnBoard;
00152 }
00153 
00154 inline
00155 void TKTrajectory::setYawRate(
00156                 double yawRate_,
00157                 double yawAcceleration_
00158                 )
00159 {
00160         yawAngle = 0.0;
00161         yawRate = yawRate_;
00162         yawAcceleration = yawAcceleration_;
00163 
00164         yawCtrl = YawControlType::RateOnBoard;
00165 }
00166 
00167 //inline
00168 //void TKTrajectory::setYawAcceleration(
00169 //              double yawAcceleration_
00170 //              )
00171 //{
00172 //
00173 //}
00174 
00175 inline
00176 GlobalPosControlType TKTrajectory::getGlobalPositionControlType() const
00177 {
00178         GlobalPosControlType retValue = GlobalPosControlType::Mixed;
00179 
00180         if (xAxisCtrl == PosControlType::Position
00181                         && yAxisCtrl == PosControlType::Position
00182                         && zAxisCtrl == PosControlType::Position) {
00183                 retValue = GlobalPosControlType::Position;
00184         } else if (xAxisCtrl == PosControlType::Velocity
00185                         && yAxisCtrl == PosControlType::Velocity
00186                         && zAxisCtrl == PosControlType::Velocity) {
00187                 retValue = GlobalPosControlType::Velocity;
00188         } else if (xAxisCtrl == PosControlType::Acceleration
00189                         && yAxisCtrl == PosControlType::Acceleration
00190                         && zAxisCtrl == PosControlType::Acceleration) {
00191                 retValue = GlobalPosControlType::Acceleration;
00192         } else {
00193                 // Mixed
00194         }
00195 
00196 
00197         return retValue;
00198 }
00199 
00200 
00201 // Delegate Definition
00202 //class TKTrajInputReceiver {
00203 //public:
00204 //      virtual ~TKTrajInputReceiver() {}
00205 //      virtual void trajInputStep(const TKTrajectory& input) = 0;
00206 //};
00207 
00208 }
00209 
00210 #endif /* TKTRAJECTORY_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines


telekyb_base
Author(s): Dr. Antonio Franchi and Martin Riedel
autogenerated on Mon Nov 11 2013 11:12:34