Report/Docs/2024-12-20/README.md

66 lines
2.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

**一.ROS**
1.学习ROS的相关概念和基础机制。
2.在ROS系统编写节点用节点发布话题并发送信息。用另外的节点订阅该话题并接收信息
![image-20241220154042461](https://raw.githubusercontent.com/wwjiefei/pictureBed/main/202412201540514.png)
![image-20241220153922935](https://raw.githubusercontent.com/wwjiefei/pictureBed/main/202412201539973.png)
3.实现在ROS系统中通过编写节点发布速度控制信息控制gazebo仿真工具中的机器人运动
![image-20241220154235198](https://raw.githubusercontent.com/wwjiefei/pictureBed/main/202412201542253.png)
4.实现在ROS系统中编写节点接收激光雷达测得的信息
![image-20241220155029810](https://raw.githubusercontent.com/wwjiefei/pictureBed/main/202412201550871.png)
5.实现ROS系统中编写节点接收雷达测得的信息之后发布运动控制信息完成避障功能
```c++
#include <ros/ros.h>
#include <sensor_msgs/LaserScan.h>
#include <geometry_msgs/Twist.h>
ros::Publisher vel_pub;
void LidarCallback(const sensor_msgs::LaserScan msg)
{
float fMidDist = msg.ranges[180];
ROS_INFO("前方测距 ranges[180] = %f m", fMidDist);
geometry_msgs::Twist vel_cmd;
//如果前方障碍物的距离小于1.5米则以0.3弧度/秒的速度旋转
if(fMidDist < 1.5)
{
vel_cmd.angular.z = 0.3;
}
else //否则向前的速度为0.05米/秒
{
vel_cmd.linear.x = 0.05;
}
vel_pub.publish(vel_cmd);
}
int main(int argc, char *argv[])
{
setlocale(LC_ALL,"");
ros::init(argc, argv, "lidar_vel_node");
ros::NodeHandle n;
ros::Subscriber lidar_sub = n.subscribe("/scan", 10, &LidarCallback);
vel_pub = n.advertise<geometry_msgs::Twist>("/cmd_vel", 10);
ros::spin();
return 0;
}
```
**二.实验**
观摩师兄做实验了解lighthouse的使用流程。下载steamVR并完成了相关配置。
![1](https://raw.githubusercontent.com/wwjiefei/pictureBed/main/202412201632459.jpg)