utils.h
Go to the documentation of this file.
00001 /*
00002  * utils.h
00003  *
00004  *  Created on: Oct 21, 2009
00005  *      Author: sturm
00006  */
00007 
00008 #ifndef ARTICULATION_MODELS_UTILS_H_
00009 #define ARTICULATION_MODELS_UTILS_H_
00010 
00011 #include "tf/LinearMath/Transform.h"
00012 #include "articulation_msgs/TrackMsg.h"
00013 #include "articulation_msgs/ParamMsg.h"
00014 #include <Eigen/Core>
00015 
00016 namespace articulation_models {
00017 
00018 #ifndef SQR
00019 #define SQR(a) ((a)*(a))
00020 #endif
00021 
00022 #ifndef MIN
00023 #define MIN(a,b) ((a<=b)?(a):(b))
00024 #endif
00025 
00026 #ifndef MAX
00027 #define MAX(a,b) ((a>=b)?(a):(b))
00028 #endif
00029 
00030 #define PRINT_TRANSFORM(tf) \
00031         "[ "<<tf.getOrigin().x() <<"; "<<tf.getOrigin().y() <<"; "<<tf.getOrigin().z() <<"]" << \
00032         "( "<<tf.getRotation().x() <<"; "<<tf.getRotation().y() <<"; "<<tf.getRotation().z()<<"; "<<tf.getRotation().w() <<") "
00033 
00034 typedef Eigen::MatrixXd M_CartesianJacobian;
00035 typedef Eigen::VectorXd V_Configuration;
00036 
00037 inline tf::Quaternion orientationToQuaternion(geometry_msgs::Quaternion orientation) {
00038         return tf::Quaternion(orientation.x,orientation.y,orientation.z,orientation.w);
00039 }
00040 
00041 inline tf::Vector3 positionToVector(geometry_msgs::Point position) {
00042         return tf::Vector3(position.x,position.y,position.z);
00043 }
00044 
00045 inline tf::Transform poseToTransform(geometry_msgs::Pose pose) {
00046         return(tf::Transform(
00047                         orientationToQuaternion(pose.orientation),
00048                         positionToVector(pose.position)
00049                 ));
00050 }
00051 
00052 inline geometry_msgs::Quaternion quaternionToOrientation(tf::Quaternion quat) {
00053         geometry_msgs::Quaternion orientation;
00054         orientation.x = quat.x();
00055         orientation.y = quat.y();
00056         orientation.z = quat.z();
00057         orientation.w = quat.w();
00058         return orientation;
00059 }
00060 
00061 inline geometry_msgs::Point vectorToPosition(tf::Vector3 point) {
00062         geometry_msgs::Point position;
00063         position.x = point.x();
00064         position.y = point.y();
00065         position.z = point.z();
00066         return position;
00067 }
00068 
00069 inline geometry_msgs::Pose transformToPose(tf::Transform transform) {
00070         geometry_msgs::Pose pose;
00071         pose.orientation = quaternionToOrientation( transform.getRotation() );
00072         pose.position = vectorToPosition( transform.getOrigin() );
00073         return pose;
00074 }
00075 
00076 int openChannel(articulation_msgs::TrackMsg &track,std::string name,bool autocreate=true);
00077 
00078 articulation_msgs::TrackMsg flipTrack(articulation_msgs::TrackMsg input, int corner=0);
00079 
00080 Eigen::VectorXd pointToEigen(geometry_msgs::Point p);
00081 geometry_msgs::Point eigenToPoint(Eigen::VectorXd v);
00082 void setParamIfNotDefined(std::vector<articulation_msgs::ParamMsg> &vec,
00083                 std::string name, double value, uint8_t type=articulation_msgs::ParamMsg::PRIOR);
00084 void setParam(std::vector<articulation_msgs::ParamMsg> &vec,
00085                 std::string name, double value, uint8_t type=articulation_msgs::ParamMsg::PRIOR);
00086 double getParam(std::vector<articulation_msgs::ParamMsg> &vec,
00087                 std::string name);
00088 bool hasParam(std::vector<articulation_msgs::ParamMsg> &vec,
00089                 std::string name);
00090 //Eigen::VectorXd vectorToEigen(V_Configuration q);
00091 //Eigen::MatrixXd matrixToEigen(M_CartesianJacobian J);
00092 
00093 
00094 bool check_values(const tf::Vector3 &vec);
00095 bool check_values(const tf::Quaternion &vec);
00096 bool check_values(double v);
00097 bool check_values(float v);
00098 }
00099 
00100 #endif /* UTILS_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


articulation_models
Author(s): Juergen Sturm
autogenerated on Wed Dec 26 2012 15:35:18