当前位置:网站首页>The principle and code implementation of intelligent follower robot in the actual combat of innovative projects
The principle and code implementation of intelligent follower robot in the actual combat of innovative projects
2022-08-02 02:12:00 【Mr.Winter”】
目录
0 专栏介绍
This column is designed to pass onROS的系统学习,掌握ROSThe underlying basic distributed principle,And has robot modeling and applicationROSEngineering ability to develop and debug real projects.
详情:《ROS从入门到精通》
1 The application of intelligent following robot
Robots are sensor networks、通信、人工智能、分布式计算、An integrator of various technologies such as automation,The level of development of robotics marks a national industry、The advanced and innovative nature of manufacturing.

The robotics industry has huge market potential,In the context of high-end industrial applications of industrial robots,Service robots have become the new blue ocean.
among many robots,The development of mobile robots is the fastest,It has been commercialized on a large scale.Intelligent following robots are one of the most common applications,in various competitions、创新项目、There are applications in open source projects and even commercial projects.例如以下场景:
- 高尔夫球场
- 病人看护
- 物流基地
- 商业导购
- 军事运输
- 2022 TICup Questions
- …
本文基于ROS从入门到精通(十) TF坐标变换原理,为什么需要TF变换?中TF变换的原理,Construct an intelligent follower robotDemo,It is convenient to provide secondary development.The overall operation process is very simple:Initialize both robots->获取机器人1Coordinates relative to the global coordinate system->Set this coordinate to the robot2的目标点,The second step is usedTF变换.虽然原理简单,但是可扩展性强.例如:
- 机器人1Can be replaced by pedestrians,在机器人2Use the laser method to detect the coordinates
- 机器人1Can be replaced with tracking objects,在机器人2Applies vision and image processing methods to detect coordinates
- Applications covered in this articleTF变换,Design a multi-robot work environment
- …
为了便于扩展,This paper adopts the standard engineering programming method.
2 Constructs the robot object
Due to the heterogeneity of robots in practical scenarios,We can't just set a few functions to drive the robot.对应地,We use object-oriented thinking,From Universal RobotsRobotVarious robot classes are derived from the interface class,Such as this article designedTurtleThe robot class is as follows:
class Turtle: public general_robot::Robot
{
public:
/** * @brief Robot object default constructor **/
Turtle();
/** * @brief Robot constructor * @param[in]: name -> 机器人名字 * @retval: None **/
Turtle(std::string name);
/** * @brief Robot object default destructor **/
~Turtle();
/** * @brief 初始化函数 * @param[in]: name -> 机器人名字 * @retval: None **/
void initialize(std::string name);
/** * @brief Drive the robot to move * @param[in]: cmd -> Motion control messages * @retval: None **/
void driveRobot(geometry_msgs::Twist cmd);
/** * @brief Set the robot starting pose * @param[in]: pose -> 起始位姿 * @retval: None **/
void setStart(general_robot::Pose pose);
/** * @brief Set the robot starting pose * @param[in]: pose -> 起始位姿 * @retval: None **/
void setGoal(general_robot::Pose pose);
}
The advantage of this design is that the interface at the application layer can be unified,such as path planning,We can achieve polymorphism by simply passing in any derived robot object,对不同结构、The parametric robot implements a unified planning algorithm.
3 机器人初始化
Mainly pose initialization,This is implemented in a very simple way for local projects.对于CS架构,Users can submit configuration lists to the backend server,The server parses the pose data,Then perform initialization as follows.To avoid business logic confusing core concepts,This article takes the following function as an example.
std::vector<turtle_robot::Turtle> robotInitialization()
{
std::vector<turtle_robot::Turtle> robots;
turtle_robot::Turtle robot1("robot1");
general_robot::Pose start;
start.x = -2.0;
start.y = -0.5;
start.theta = PI / 2;
robot1.setStart(start);
robots.push_back(robot1);
turtle_robot::Turtle robot2("robot2");
start.x = 2.0;
start.y = 0.5;
start.theta = PI / 2;
robot2.setStart(start);
robots.push_back(robot2);
return robots;
}
4 实现跟随
首先打开一个ros循环,Implement persistent follower tasks.
while (ros::ok())
{
// The logic introduced next is here
}
接着,获得机器人1The pose relative to the map
geometry_msgs::TransformStamped tfs = buffer.lookupTransform("map","robot1/base_footprint",ros::Time(0));
ROS_INFO("[x:%.2f, y:%.2f]", tfs.transform.translation.x, tfs.transform.translation.y);
Take this global pose as the robot2的目标点
goal.x = tfs.transform.translation.x;
goal.y = tfs.transform.translation.y;
goal.theta = PI / 2;
robots[1].setGoal(goal);
继续循环
loop_rate.sleep();
ros::spinOnce();
5 效果展示
The 3D simulation scene is shown below:


The complete code can be obtained from the blogger's business card below
文末抽奖送书
本期图书推荐:《Python机器学习:数据建模与分析》

【书籍简介】
- 系统介绍PythonData analysis for machine learning、机器学习、数据可视化相关库.Combine a large number of examples to thoroughly explain various machine learning algorithms in data modeling、Applications in data analysis.Data modeling visualizations are presented in full color,Companion datasets are provided、源代码、PPT等学习资源
【抽奖方式】
- 关注博主,点赞收藏文章,并做出有效评论
- 根据评论记录随机抽取3位用户赠送实体图书
- 截止日期:8.7日晚8点,届时通过blink公布获奖信息,请中奖用户及时私信
更多精彩专栏:
边栏推荐
- Constructor of typescript35-class
- LeetCode brushing diary: 33. Search and rotate sorted array
- 待读书单列表
- Can Youxuan database import wrongly be restored?
- 密码学的基础:X.690和对应的BER CER DER编码
- volatile原理解析
- LeetCode Brushing Diary: 74. Searching 2D Matrix
- The first time I wrote a programming interview question for Niu Ke: input a string and return the letter with the most occurrences of the string
- Fundamentals of Cryptography: X.690 and Corresponding BER CER DER Encodings
- 【ORB_SLAM2】void Frame::AssignFeaturesToGrid()
猜你喜欢

Safety (2)

3.Bean的作用域与生命周期

Huawei's 5-year female test engineer resigns: what a painful realization...

2023年起,这些地区软考成绩低于45分也能拿证

From 2023 onwards, these regions will be able to obtain a certificate with a score lower than 45 in the soft examination.

【LeetCode Daily Question】——704. Binary Search

Constructor of typescript35-class

Data transfer at the data link layer

项目后台技术Express

手写一个博客平台~第三天
随机推荐
密码学的基础:X.690和对应的BER CER DER编码
十字光标太小怎么调节、CAD梦想画图算量技巧
LeetCode刷题日记:34、 在排序数组中查找元素的第一个和最后一个位置
to-be-read list
Centos7 安装postgresql并开启远程访问
The characteristics and principle of typescript29 - enumeration type
【LeetCode每日一题】——103.二叉树的锯齿形层序遍历
雇用WordPress开发人员:4个实用的方法
Effects of Scraping and Aggregation
软件测试功能测试全套常见面试题【开放性思维题】面试总结4-3
Power button 1374. Generate each character string is an odd number
messy website
Constructor instance method of typescript36-class
oracle查询扫描全表和走索引
MySQL optimization strategy
LeetCode刷题日记: 33、搜索旋转排序数组
¶Backtop 回到顶部 不生效
云和恩墨:让商业数据库时代的价值在openGauss生态上持续繁荣
手写博客平台~第二天
Huawei's 5-year female test engineer resigns: what a painful realization...
