当前位置:网站首页>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公布获奖信息,请中奖用户及时私信
更多精彩专栏:
边栏推荐
- 待读书单列表
- From 2023 onwards, these regions will be able to obtain a certificate with a score lower than 45 in the soft examination.
- nacos startup error, the database has been configured, stand-alone startup
- 2022-08-01 mysql/stoonedb slow SQL-Q18 analysis
- openGauss切换后state状态显示不对
- 【LeetCode每日一题】——704.二分查找
- MySQL8 下载、启动、配置、验证
- messy website
- CodeTon Round 2 D. Magical Array
- 【LeetCode每日一题】——654.最大二叉树
猜你喜欢

哈希冲突和一致性哈希

typescript30 - any type

AWR分析报告问题求助:SQL如何可以从哪几个方面优化?

Win Go development kit installation configuration, GoLand configuration

Pinduoduo leverages the consumer expo to promote the upgrading of domestic agricultural products brands and keep pace with international high-quality agricultural products

"NetEase Internship" Weekly Diary (1)

软件测试 接口自动化测试 pytest框架封装 requests库 封装统一请求和多个基础路径处理 接口关联封装 测试用例写在yaml文件中 数据热加载(动态参数) 断言

【LeetCode每日一题】——654.最大二叉树

MySQL8 下载、启动、配置、验证

Understand the big model in seconds | 3 steps to get AI to write a summary
随机推荐
Handwriting a blogging platform ~ Day 3
软件测试功能测试全套常见面试题【开放性思维题】面试总结4-3
Check if IP or port is blocked
成都openGauss用户组招募啦!
【ORB_SLAM2】void Frame::AssignFeaturesToGrid()
CodeTon Round 2 D. Magical Array 规律
2022-08-01 mysql/stoonedb slow SQL-Q18 analysis
bool框架::PosInGrid (const简历:关键点kp, int &posX, int诗句)
【LeetCode每日一题】——704.二分查找
LeetCode刷题日记:34、 在排序数组中查找元素的第一个和最后一个位置
编码经验之谈
Chengdu openGauss user group recruit!
Speed up your programs with bitwise operations
2023年起,这些地区软考成绩低于45分也能拿证
Day116.尚医通:预约挂号详情 ※
3. Bean scope and life cycle
个人博客系统项目测试
MySQL8 download, start, configure, verify
MySQL optimization strategy
[LeetCode Daily Question]——654. The largest binary tree
