**一.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 #include #include 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("/cmd_vel", 10); ros::spin(); return 0; } ``` **二.实验** 观摩师兄做实验,了解lighthouse的使用流程。下载steamVR,并完成了相关配置。 ![1](https://raw.githubusercontent.com/wwjiefei/pictureBed/main/202412201632459.jpg)