机器人视觉项目:视觉检测识别+机器人跟随(22)

本文主要介绍了机器人使用ROS的turtle_floower节点进行人体跟随的调试过程,特别是针对launch文件参数的调整,以提升在转弯处的跟随性能。尽管有所改进,但在某些情况下仍存在跟丢的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

机器人调试

ros turtle_floower人体跟随

#include <ros/ros.h>
#include <pluginlib/class_list_macros.h>
#include <nodelet/nodelet.h>
#include <geometry_msgs/Twist.h>
#include <sensor_msgs/Image.h>
#include <visualization_msgs/Marker.h>
#include <turtlebot_msgs/SetFollowState.h>
​
#include "dynamic_reconfigure/server.h"
#include "turtlebot_follower/FollowerConfig.h"
​
#include <depth_image_proc/depth_traits.h>
​
​
namespace turtlebot_follower
{
​
//* The turtlebot follower nodelet.
/**
 * The turtlebot follower nodelet. Subscribes to point clouds
 * from the 3dsensor, processes them, and publishes command vel
 * messages.
 */
class TurtlebotFollower : public nodelet::Nodelet
{
public:
  /*!
   * @brief The constructor for the follower.
   * Constructor for the follower.
   */
  TurtlebotFollower() : min_y_(0.1), max_y_(0.5),
                        min_x_(-0.2), max_x_(0.2),
                        max_z_(0.8), goal_z_(0.6),
                        z_scale_(1.0), x_scale_(5.0)
  {
​
  }
​
  ~TurtlebotFollower()
  {
    delete config_srv_;
  }
​
private:
  double min_y_; /**< The minimum y position of the points in the box. */
  double max_y_; /**< The maximum y position of the points in the box. */
  double min_x_; /**< The minimum x position of the points in the box. */
  double max_x_; /**< The maximum x position of the points in the box. */
  double max_z_; /**< The maximum z position of the points in the box. 框中 点的最大z位置,以上四个字段用来设置框的大小*/
  double goal_z_; /**< The distance away from the robot to hold the centroid 离机器人的距离,以保持质心*/
  double z_scale_; /**< The scaling factor for translational robot speed 移动机器人速度的缩放系数*/
  double x_scale_; /**< The scaling factor for rotational robot speed 旋转机器人速度的缩放系数*/
  bool   enabled_; /**< Enable/disable following; just prevents motor commands 启用/禁用追踪; 只是阻止电机命令,置为false后,机器人不会移动,/mobile_base/mobile_base_controller/cmd_vel topic 为空*/
​
  // Service for start/stop following
  ros::ServiceServer switch_srv_;
​
  // Dynamic reconfigure server 动态配置服务
  dynamic_reconfigure::Server<turtlebot_follower::FollowerConfig>* config_srv_;
​
  /*!
   * @brief OnInit method from node handle.
   * OnInit method from node handle. Sets up the parameters
   * and topics.
   * 初始化handle,参数,和话题
   */
  virtual void onInit()
  {
    ros::NodeHandle& nh = getNodeHandle();
    ros::NodeHandle& private_nh = getPrivateNodeHandle();
   //从参数服务器获取设置的参数(launch文件中设置数值)
    private_nh.getParam("min_y", min_y_);
    private_nh.getParam("max_y", max_y_);
    private_nh.getParam("min_x", min_x_);
    private_nh.getParam("max_x", max_x_);
    private_nh.getParam("max_z", max_z_);
    private_nh.getParam("goal_z", goal_z_);
    private_nh.getParam("z_scale", z_scale_);
    private_nh.getParam("x_scale", x_scale_);
    private_nh.getParam("enabled", enabled_);
    //设置机器人移动的话题(用于机器人移动):/mobile_base/mobile_base_controller/cmd_vel(换成机器人的移动topic)
    cmdpub_ = private_nh.advertise<geometry_msgs::Twist> ("/mobile_base/mobile_base_
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值