当前位置:网站首页>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公布获奖信息,请中奖用户及时私信
更多精彩专栏:
边栏推荐
- 2022-08-01 Reflection
- A full set of common interview questions for software testing functional testing [open thinking questions] interview summary 4-3
- 手写一个博客平台~第一天
- How to adjust the cross cursor too small, CAD dream drawing calculation skills
- 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
- LeetCode刷题日记:53、最大子数组和
- oracle query scan full table and walk index
- Redis 底层的数据结构
- After graduating from three books, I was rejected by Tencent 14 times, and finally successfully joined Alibaba
- Centos7 install postgresql and enable remote access
猜你喜欢
随机推荐
PHP uses PHPRedis and Predis
2022-07-30 mysql8执行慢SQL-Q17分析
Power button 1374. Generate each character string is an odd number
Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021:解读
Speed up your programs with bitwise operations
Constructor of typescript35-class
Win Go development kit installation configuration, GoLand configuration
"NetEase Internship" Weekly Diary (1)
Redis Subscription and Redis Stream
云和恩墨:让商业数据库时代的价值在openGauss生态上持续繁荣
Software testing Interface automation testing Pytest framework encapsulates requests library Encapsulates unified request and multiple base path processing Interface association encapsulation Test cas
AntPathMatcher uses
¶Backtop 回到顶部 不生效
A good book for newcomers to the workplace
nacos startup error, the database has been configured, stand-alone startup
Check if IP or port is blocked
[ORB_SLAM2] void Frame::ComputeImageBounds(const cv::Mat & imLeft)
nacos启动报错,已配置数据库,单机启动
The underlying data structure of Redis
¶ Backtop back to the top is not effective










