一、Gazebo和环境模型准备
二、机器人模型设计
三、为模型上装备传感器和执行器
目标:设计一台具备激光雷达、IMU和相机的机器人仿真模型用于避障和路径规划
1、\安装 bingda_tutorials包:git clone https://gitee.com/bingda-robot/bingda_tutorials
cd catkin_ws/src/bingda_tutorials/
git reset --hard
git pull origin master
cd ..
git clone https://gitee.com/bingda-robot/bingda_tutorials
cd ..
编译:
catkin_make --pkg bingda_tutorial
2、\安装依赖功能包
cd catkin_ws
sudo apt update
sudo apt install ros-$ROS_DISTRO-gazebo-ros ros-$ROS_DISTRO-gazebo-ros-control ros-$ROS_DISTRO-gazebo-plugins ros-$ROS_DISTRO-joint-state-publisher ros-$ROS_DISTRO-joint-state-publisher-gui ros-$ROS_DISTRO-robot-state-publisher
3、\实验
确定gazebo正常运行
打开终端:gazebo
创建并保存:room.world
cd catkin_ws
source ./devel/setup.bash
roslaunch bingda_tutorials gazebo_world.launch
4、\准备机器人模型:urdf -ROS WiKi
cd catkin_ws/src/bingda_tutorials/urdf
check_urdf mybot.urdf
cd catkin_ws
source ./devel/setup.bash
roslaunch bingda_tutorials display_robot.launch
\出错:Traceback (most recent call last):
File "/opt/ros/melodic/lib/joint_state_publisher_gui/joint_state_publisher_gui", line 50, in <module>
jsp_gui = joint_state_publisher_gui.JointStatePublisherGui('Joint State Publisher',
AttributeError: module 'joint_state_publisher_gui' has no attribute 'JointStatePublisherGui'. Did you mean: 'JofloatStatePublisherGui'?
[joint_state_publisher_gui-3] process has died [pid 18832, exit code 1, cmd /opt/ros/melodic/lib/joint_state_publisher_gui/joint_state_publisher_gui __name:=joint_state_publisher_gui __log:=/home/xu/.ros/log/82bf5c0e-1453-11ef-b89b-347df6d69705/joint_state_publisher_gui-3.log].
log file: /home/xu/.ros/log/82bf5c0e-1453-11ef-b89b-347df6d69705/joint_state_publisher_gui-3*.log
\问题尚未解决
roslaunch bingda_tutorials gazebo_robot.launch
5、\给机器人增加执行器和传感器
文件:xacro -ROS WiKi或http www ros org wiki xacro
cd catkin_ws
source ./devel/setup.bash
roslaunch bingda_tutorials simulation_robot.launch
打开新的终端:
rostopic list
rostopic info /cmd_vel
rqt_image_view
新终端:
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
通过实践, 发现各个键值的作用如下:
u-- 向左前方前进 i-- 直行前进 o-- 向右前方前进 j-- 逆时针旋转 k-- 停止 l-- 顺时针旋转 m-- 向左后方后退 ,-- 后退
. – 向右后方后退
q – 增加速度
z – 减小速度
新终端:rviz
Add-TF-RobotModel-LaserScan:Topic:/scan;Size(m):o.03
控制键盘建来控制小车运动
参考博主:
【70分钟快速入门Gazebo机器人仿真】 https://www.bilibili.com/video/BV143411C75B/?p=6&share_source=copy_web&vd_source=7e0f2c799fb46162b4921e238f945f78