main
翟帅帅 2024-12-20 16:34:48 +08:00
parent 121d638ffa
commit c3d2f414fc
6 changed files with 65 additions and 0 deletions

BIN
Docs/2024-12-20/Image/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 MiB

BIN
Docs/2024-12-20/Image/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

BIN
Docs/2024-12-20/Image/3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
Docs/2024-12-20/Image/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

BIN
Docs/2024-12-20/Image/5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

65
Docs/2024-12-20/README.md Normal file
View File

@ -0,0 +1,65 @@
**一.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)