35 #include <pr2_mechanism_controllers/Pose3D.h> 37 #include <geometry_msgs/Twist.h> 38 #include <nav_msgs/Odometry.h> 39 #include <geometry_msgs/Quaternion.h> 64 squ = quat.w * quat.w;
65 sqx = quat.x * quat.x;
66 sqy = quat.y * quat.y;
67 sqz = quat.z * quat.z;
70 vec.x =
atan2(2 * (quat.y*quat.z + quat.w*quat.x), squ - sqx - sqy + sqz);
73 vec.y =
asin(-2 * (quat.x*quat.z - quat.w * quat.y));
76 vec.z =
atan2(2 * (quat.x*quat.y + quat.w*quat.z), squ + sqx - sqy - sqz);
103 ros::Node *node =
new ros::Node(
"test_run_base_controller");
115 geometry_msgs::Twist
cmd;
124 bool run_time_set =
false;
128 cmd.linear.x = atof(argv[1]);
131 cmd.linear.y = atof(argv[2]);
134 cmd.angular.z = atof(argv[3]);
138 run_time = atof(argv[4]);
144 file_num = atoi(argv[5]);
147 node->advertise<geometry_msgs::Twist>(
"cmd_vel",10);
150 libTF::Vector ang_rates;
154 std::ofstream odom_log_file;
155 odom_log_file.open(
"odom_log.txt");
162 if(run_time_set && delta_time.
toSec() > run_time)
165 odom_log_file << tb.
odom.pose.pose.position.x <<
" " << tb.
odom.pose.pose.position.y <<
" " <<
tf::getYaw(tb.
odom.pose.pose.orientation) <<
" " << tb.
odom.twist.twist.linear.x <<
" " << tb.
odom.twist.twist.linear.y <<
" " << tb.
odom.twist.twist.angulat.z <<
" " << tb.
odom.header.stamp.sec + tb.
odom.header.stamp.nsec/1.0e9 << std::endl;
167 cout << endl <<
"odometry:: " << endl <<
"velocity:" << endl <<
" x:" << tb.
odom.twist.twist.linear.x << endl <<
" y:" << tb.
odom.twist.twist.linear.y << endl <<
" omega:" << tb.
odom.twist.twist.angular.z << std::endl;
168 node->publish(
"cmd_vel",cmd);
172 node->unsubscribe(
"odom");
173 node->unadvertise(
"cmd_vel");
175 odom_log_file.close();
static double getYaw(const Quaternion &bt_q)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
Duration & fromSec(double t)
INLINE Rall1d< T, V, S > asin(const Rall1d< T, V, S > &x)
void finalize(int donecare)
libTF::Vector GetAsEuler(geometry_msgs::Quaternion quat)
INLINE Rall1d< T, V, S > atan2(const Rall1d< T, V, S > &y, const Rall1d< T, V, S > &x)
int main(int argc, char **argv)