Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
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         
00016 
00017 }
00018 
00019 TKState::TKState(const telekyb_msgs::TKState& tkStateMsg)
00020 {
00021         fromTKStateMsg(tkStateMsg);
00022 }
00023 
00024 TKState::~TKState() {
00025         
00026 }
00027 
00028 void TKState::toTKStateMsg(telekyb_msgs::TKState& tkStateMsg) const
00029 {
00030         tkStateMsg.header.stamp = time.toRosTime();
00031         
00032         tkStateMsg.pose.position.x = position(0);
00033         tkStateMsg.pose.position.y = position(1);
00034         tkStateMsg.pose.position.z = position(2);
00035 
00036         
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         
00043         tkStateMsg.twist.linear.x = linVelocity(0);
00044         tkStateMsg.twist.linear.y = linVelocity(1);
00045         tkStateMsg.twist.linear.z = linVelocity(2);
00046 
00047         
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         
00058         position(0) = tkStateMsg.pose.position.x;
00059         position(1) = tkStateMsg.pose.position.y;
00060         position(2) = tkStateMsg.pose.position.z;
00061 
00062         
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         
00069         linVelocity(0) = tkStateMsg.twist.linear.x;
00070         linVelocity(1) = tkStateMsg.twist.linear.y;
00071         linVelocity(2) = tkStateMsg.twist.linear.z;
00072 
00073         
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); 
00082 }
00083 
00084 }
00085