当前位置:网站首页>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公布获奖信息,请中奖用户及时私信
更多精彩专栏:
边栏推荐
- AWR analysis report questions for help: How can SQL be optimized from what aspects?
- Scheduled tasks for distributed applications in Golang
- 【ORB_SLAM2】void Frame::AssignFeaturesToGrid()
- 用位运算为你的程序加速
- Win Go开发包安装配置、GoLand配置
- Constructor of typescript35-class
- PHP uses PHPRedis and Predis
- 成都openGauss用户组招募啦!
- Power button 1374. Generate each character string is an odd number
- 力扣、752-打开转盘锁
猜你喜欢

2022-08-01 mysql/stoonedb slow SQL-Q18 analysis

拼多多借力消博会推动国内农产品品牌升级 看齐国际精品农货

6-25 Vulnerability Exploitation - irc Backdoor Exploitation

Record the pits where an error occurs when an array is converted to a collection, and try to use an array of packaging types for conversion

用位运算为你的程序加速

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

The underlying data structure of Redis

oracle查询扫描全表和走索引

检查IP或端口是否被封

Analysis of volatile principle
随机推荐
oracle查询扫描全表和走索引
Typescript31 - any type
"NetEase Internship" Weekly Diary (2)
个人博客系统项目测试
The characteristics and principle of typescript29 - enumeration type
Record the pits where an error occurs when an array is converted to a collection, and try to use an array of packaging types for conversion
¶Backtop 回到顶部 不生效
YGG Guild Development Plan Season 1 Summary
手写一个博客平台~第三天
Day116. Shangyitong: Details of appointment registration ※
LeetCode brush diary: LCP 03. Machine's adventure
2022-08-01 反思
待读书单列表
Win Go开发包安装配置、GoLand配置
The Paddle Open Source Community Quarterly Report is here, everything you want to know is here
From 2023 onwards, these regions will be able to obtain a certificate with a score lower than 45 in the soft examination.
leetcode / anagram in string - some permutation of s1 string is a substring of s2
AntPathMatcher使用
LeetCode Review Diary: 34. Find the first and last position of an element in a sorted array
Personal blog system project test
