TKState.cpp
Go to the documentation of this file.
00001 /*
00002  * TKState.cpp
00003  *
00004  *  Created on: Nov 8, 2011
00005  *      Author: mriedel
00006  */
00007 
00008 #include <telekyb_base/Messages/TKState.hpp>
00009 
00010 namespace TELEKYB_NAMESPACE {
00011 
00012 TKState::TKState()
00013         : time(ros::Time::now()), position(0.0,0.0,0.0), orientation(1.0,0.0,0.0,0.0), linVelocity(0.0,0.0,0.0), angVelocity(0.0,0.0,0.0)
00014 {
00015         // TODO Auto-generated constructor stub
00016 
00017 }
00018 
00019 TKState::TKState(const telekyb_msgs::TKState& tkStateMsg)
00020 {
00021         fromTKStateMsg(tkStateMsg);
00022 }
00023 
00024 TKState::~TKState() {
00025         // TODO Auto-generated destructor stub
00026 }
00027 
00028 void TKState::toTKStateMsg(telekyb_msgs::TKState& tkStateMsg) const
00029 {
00030         tkStateMsg.header.stamp = time.toRosTime();
00031         // Position
00032         tkStateMsg.pose.position.x = position(0);
00033         tkStateMsg.pose.position.y = position(1);
00034         tkStateMsg.pose.position.z = position(2);
00035 
00036         // Orientation
00037         tkStateMsg.pose.orientation.w = orientation.w();
00038         tkStateMsg.pose.orientation.x = orientation.x();
00039         tkStateMsg.pose.orientation.y = orientation.y();
00040         tkStateMsg.pose.orientation.z = orientation.z();
00041 
00042         // linear Velocity
00043         tkStateMsg.twist.linear.x = linVelocity(0);
00044         tkStateMsg.twist.linear.y = linVelocity(1);
00045         tkStateMsg.twist.linear.z = linVelocity(2);
00046 
00047         // angular Velocity
00048         tkStateMsg.twist.angular.x = angVelocity(0);
00049         tkStateMsg.twist.angular.y = angVelocity(1);
00050         tkStateMsg.twist.angular.z = angVelocity(2);
00051 
00052 }
00053 
00054 void TKState::fromTKStateMsg(const telekyb_msgs::TKState& tkStateMsg)
00055 {
00056         time = Time(tkStateMsg.header.stamp);
00057         // Position
00058         position(0) = tkStateMsg.pose.position.x;
00059         position(1) = tkStateMsg.pose.position.y;
00060         position(2) = tkStateMsg.pose.position.z;
00061 
00062         // Orientation
00063         orientation.w() = tkStateMsg.pose.orientation.w;
00064         orientation.x() = tkStateMsg.pose.orientation.x;
00065         orientation.y() = tkStateMsg.pose.orientation.y;
00066         orientation.z() = tkStateMsg.pose.orientation.z;
00067 
00068         // linear Velocity
00069         linVelocity(0) = tkStateMsg.twist.linear.x;
00070         linVelocity(1) = tkStateMsg.twist.linear.y;
00071         linVelocity(2) = tkStateMsg.twist.linear.z;
00072 
00073         // angular Velocity
00074         angVelocity(0) = tkStateMsg.twist.angular.x;
00075         angVelocity(1) = tkStateMsg.twist.angular.y;
00076         angVelocity(2) = tkStateMsg.twist.angular.z;
00077 }
00078 
00079 Vector3D TKState::getEulerRPY() const
00080 {
00081         return orientation.toRotationMatrix().eulerAngles(0,1,2); // xyz
00082 }
00083 
00084 }
00085 
 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