正在加载图片...
/publishing the odometry and the new tf broadcaster.sendTransform(odom trans); odom_pub.publish(odom); loop_rate.sleep(); return0; 以上程序分析如下: 首先创建了一个transformation变量并且对frame id和child frame_id值进行赋值,这样 确定什么时候应该要移动坐标系了。在这里,机器人基座坐标系base footprint将会相对与 odom坐标系移动。 geometry_msgs::TransformStamped odom trans; odom trans.header.frame id ="odom": odom_trans.child frame id="base footprint"; 在下面我们生成了机器人的位姿。利用线速度和角速度可以计算一段时间后机器人的理 论的位姿。并创建四元素。 double dt =(current time-last time).toSec(): double delta_x=(vx cos(th)-vy sin(th))*dt; double delta y=(vx sin(th)+vy cos(th))*dt; double delta th=vth dt; x+=delta_x; y+=delta y; th+=delta th; geometry_msgs::Quaternion odom quat; odom_quat=tf:createQuaternionMsgFromRollPitchYaw(0,0,th); 对于transformation,我们只需要将x和rotation属性进行赋值即可,因为我们的机器人仅 仅在向前向后和转动? 对于里程,我们同样将frame id和child frame id值进行赋值为机器人基座坐标系 base footprint与odom坐标系。 因为里程topic?有两个结构,我们将填写pose的x,y和orientation。在twist结构体中国, 我们将天蝎线速度和角速度 /∥position odom.pose.pose.position.x=x; odom.pose.pose.position.y=y; odom.pose.pose.orientation=odom_quat; ∥velocity odom.twist.twist.linear.x vx: odom.twist.twist.angular.z=vth: 数据赋值好后就可以发布数据。 /publishing the odometry and the new tf broadcaster.sendTransform(odom trans); odom pub.publish(odom); -14-- 14 - // publishing the odometry and the new tf broadcaster.sendTransform(odom_trans); odom_pub.publish(odom); loop_rate.sleep(); } return 0; } 以上程序分析如下: 首先创建了一个transformation变量并且对frame_id 和child_frame_id值进行赋值,这样 确定什么时候应该要移动坐标系了。在这里,机器人基座坐标系base_footprint将会相对与 odom坐标系移动。 geometry_msgs::TransformStamped odom_trans; odom_trans.header.frame_id = "odom"; odom_trans.child_frame_id = "base_footprint"; 在下面我们生成了机器人的位姿。利用线速度和角速度可以计算一段时间后机器人的理 论的位姿。并创建四元素。 double dt = (current_time - last_time).toSec(); double delta_x = (vx * cos(th) - vy * sin(th)) * dt; double delta_y = (vx * sin(th) + vy * cos(th)) * dt; double delta_th = vth * dt; x += delta_x; y += delta_y; th += delta_th; geometry_msgs::Quaternion odom_quat; odom_quat = tf::createQuaternionMsgFromRollPitchYaw(0,0,th); 对于transformation,我们只需要将x和rotation属性进行赋值即可,因为我们的机器人仅 仅在向前向后和转动? 对于里程,我们同样将frame_id 和child_frame_id值进行赋值为机器人基座坐标系 base_footprint与odom坐标系。 因为里程topic有两个结构,我们将填写pose的x,y和orientation。在twist结构体中国, 我们将天蝎线速度和角速度 // position odom.pose.pose.position.x = x; odom.pose.pose.position.y = y; odom.pose.pose.orientation = odom_quat; // velocity odom.twist.twist.linear.x = vx; odom.twist.twist.angular.z = vth; 数据赋值好后就可以发布数据。 // publishing the odometry and the new tf broadcaster.sendTransform(odom_trans); odom_pub.publish(odom);
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有