基于UWB和激光雷达的智能跟随与避障系统
来源:互联网 发布:腾讯绿标域名跳转代码 编辑:程序博客网 时间:2024/05/17 22:18
#include <ros/ros.h>#include "std_msgs/String.h"#include <math.h>#include <iostream>#include <geometry_msgs/Pose.h>#include "message_filters/subscriber.h"#include "geometry_msgs/Twist.h"#include <std_msgs/Header.h>#include <leg_tracker/Person.h>#include <leg_tracker/PersonArray.h>#include <std_msgs/Header.h>#include <sstream>using namespace std;ros::Publisher cmdpub_;bool start_follower = false;float global_x = 0;float global_y = 0;int master_id = 0;float euclidean_Distance = 100;void poseCB(const leg_tracker::PersonArrayConstPtr& ptr){ std_msgs::Header header; header = ptr->header; stringstream ss; //int seq; //ss << "---" << endl << "header:" << endl << ptr->header << "people:" << endl << " - " << endl; std::vector<int>::size_type size1 = ptr->people.size(); //people is a array if(start_follower == false) { ROS_INFO("start_follower is close "); euclidean_Distance = 100; for (unsigned i=0; i<size1; i++) { ss << ptr->people[i]; //master_id = ptr->people[i].id; global_x = ptr->people[i].pose.position.x; global_y = ptr->people[i].pose.position.y; float dst; dst = sqrt(global_x * global_x + global_y * global_y); if(euclidean_Distance > dst) //get minimum distance { euclidean_Distance = dst; master_id = ptr->people[i].id; } } if(euclidean_Distance < 0.6) //start condition { start_follower = true; ROS_INFO("start_follower is opening "); } } else { int cnt = 0; for (unsigned k=0; k<size1; k++) { if(ptr->people[k].id == master_id) { global_x = ptr->people[k].pose.position.x; global_y = ptr->people[k].pose.position.y; ROS_INFO("master_id:%d",master_id); float distance; distance = sqrt(global_x * global_x + global_y * global_y); if(distance > 0.7 && distance < 2.6) { geometry_msgs::TwistPtr cmd(new geometry_msgs::Twist()); cmd->linear.x = distance/1.6*0.8; //maxmum v is 0.8m/s //cmd->linear.x = 0.6; cmd->angular.z = -atan2(global_y,global_x); cmdpub_.publish(cmd); ROS_INFO("linear:%f,angular:%f",cmd->linear.x,cmd->angular.z); } else { geometry_msgs::TwistPtr cmd_stop(new geometry_msgs::Twist()); cmd_stop->linear.x = 0; cmd_stop->angular.z = 0; cmdpub_.publish(cmd_stop); ROS_INFO("linear:%f,angular:%f",cmd_stop->linear.x,cmd_stop->angular.z); } } else { cnt++; } } if(cnt == size1) { start_follower = false; ROS_INFO("start_follower is closing"); } }}int main(int argc, char **argv){ ros::init(argc, argv, "master_pose"); ros::NodeHandle nh; ros::Subscriber sub = nh.subscribe("people_tracked", 1000, poseCB); cmdpub_ = nh.advertise<geometry_msgs::Twist>("/cmd_vel",1,true); while(ros::ok()) { ros::spinOnce(); } return 0;}
阅读全文
0 0
- 基于UWB和激光雷达的智能跟随与避障系统
- 7基于UWB定位智能巡检系统建设应用方案
- 测距和避障传感器——激光测距仪和激光雷达
- ROS入门--基于激光的避障
- 基于并行遗传算法的无人驾驶(自动驾驶)避障算法和安全性研究
- 基于激光测距仪的移动机器人避障新方法PDF
- 智能避障小车顺利结束
- 基于ARM与DSP的智能仪器系统设计
- 基于ARM与DSP的智能仪器系统设计
- 视频:行业首款智能手表跟拍与避障无人机XEagle发布会
- 行业首款智能手表跟拍与避障无人机XEagle亮相高交会
- 基于UWB技术的隧道人员定位系统分析
- 熊大UWB系列教程四:UWB超宽带三基站定位系统原理介绍与效果展示
- 基于windows系统的智能DNS
- 基于自然语言对话的智能辅导系统
- 基于 C8051F 的智能测量系统
- 基于ARM9的智能车载系统设计
- 基于openwrt系统的智能路由器
- human pose regression by combining indirect part detection and contextual information
- 2.1最简单的结构——线性表
- PDF.js开发笔记
- Qt如何上传zip文件(两种形式),及随机生成规定长度的字符串的小方法
- FORTRAN 开发平面薄壁结构有限元程序
- 基于UWB和激光雷达的智能跟随与避障系统
- keras examples
- js字符串方法match()匹配出所有正则表达式的内容
- 11.(此处为以上综合精华)如何使用ActiveMQ,以及spring+jms下整合
- 错误表现:在action中无法获取session中的user信息;
- Android camera之native_setup
- go学习(十四)——Go和Python操作mongodb性能对比统计
- 银联无跳转支付流程(银联侧开通)
- Qt5.9.0中打开与关闭系统软键盘