ROSturtlebot_follower:让机器人跟随我们移动ROSturtlebot_follower学习首先在catkin_ws/src目录下载源码了解代码见注释(其中有些地方我也不是很明白)#include<ros/>#include<pluginlib/>#include<nodelet/>#include<geometry_msgs/>#include<sensor_msgs/>#include<visualization_msgs/>#include<turtlebot_msgs/>#include"dynamic_reconfigure/"#include"turtlebot_follower/"#include<depth_image_proc/>namespaceturtlebot_follower{//*Theturtlebotfollowernodelet./****fromthe3dsensor,processesthem,mandvel*messages.*/classTurtlebotFollower:odelet::Nodelet{public:/*!****@briefTheconstructorforthefollower.*Constructorforthefollower.*/TurtlebotFollower():min_y_(),max_y_(),min_x_(),max_x_(),max_z_(),goal_z_(),z_scale_(),x_scale_(){}~TurtlebotFollower(){deleteconfig_srv_;}private:doublemin_y_;/**<Theminimumypositionofthepointsinthebox.*/doublemax_y_;/**<Themaximumypositionofthepointsinthebox.*/doublemin_x_;/**<Theminimumxpositionofthepointsinthebox.*/doublemax_x_;/**<Themaximumxpositionofthepointsinthebox.*/doublemax_z_;/**<,以上四个字段用来设置框的大小*/doublegoal_z_;/**<Thedistanceawayfromtherobottoholdthecentroid离机器人的距离,以保持质心*/doublez_scale_;/**<Thescalingfactorfortranslationalrobotspeed移动机器人速度的缩放系数*/doublex_scale_;/**<Thescalingfactorforrotationalrobotspeed旋转机器人速度的缩放系数*/boolenabled_;/**<Enable/disablefollowing;mands启用/禁用追踪;只是阻止电机命令,置为false后,机器人不会移动,/mobile_base/mobile_base_controller/cmd_veltopic为空*///Serviceforstart/stopfollowingros::ServiceServerswitch_srv_;//Dynamicreconfigureserver动态配置服务dynamic_reconfigure::Server<turtlebot_follower::FollowerConfig>*config_srv_;/*!****@briefOnInitmethodfromnodehandle.**andtopics.*初始化handle,参数,和话题*/virtualvoidonInit(){ros::NodeHandle&nh=getNodeHandle();ros::NodeHandle&private_nh=getPrivateNodeHandle();//从参数服务器获取设置的参数(launch文件中设置数值)("min_y",min_y_);("max_y",max_y_);("min_x",min_x_);("max_x",max_x_);("max_z",max_z_);("goal_z",goal_z_);("z_scale",z_scale_);("x_scale",x_scale_);("ena
ROS-turtlebot-follower-:让机器人跟随我们移动 来自淘豆网m.daumloan.com转载请标明出处.