1:
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
2:
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3:
sudo apt update
4:安装
sudo apt install ros-noetic-desktop-full
5:配置
source /opt/ros/noetic/setup.bash
Bash:
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
Zsh:
echo "source /opt/ros/noetic/setup.zsh" >> ~/.zshrc
source ~/.zshrc
ros-noetic-desktop-full (1.5.0-1focal.20200724.201236)
sudo apt install ros-noetic-
Display all 1048 possibilities? (y or n)
1:
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
2:
sudo apt update && sudo apt install curl gnupg2 lsb-release
3:
sudo gedit /etc/apt/sources.list.d/ros2-latest.list
deb [arch=amd64,arm64] https://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu/ focal main
4:
sudo apt update
5: 安装
sudo apt install ros-foxy-desktop
6: 配置
source /opt/ros/foxy/setup.bash
ros-foxy-desktop (0.9.2-1focal.20200807.222642)
sudo apt install ros-foxy-
Display all 815 possibilities? (y or n)
7:
sudo apt install python3-argcomplete
配置:Noetic和Foxy切换(Bash)
# ROS 1.0 noetic or ROS 2.0 foxy
echo Hello, ROS 1.0 or ROS 2.0? 1=noetic 2=foxy
read ROS
if (($ROS==1));then
source /opt/ros/noetic/setup.bash
#export ROS_PACKAGE_PATH=/home/ros/RobTool/ROS1/Wiki/src:/home/relaybot/RobTool/Cozmo/ros/src:$ROS_PACKAGE_PATH
#source /home/ros/RobTool/ROS1/Wiki/devel/setup.bash
#export ROS_MASTER_URI=http://192.168.1.100:11311
#export ROS_IP=192.168.1.100
echo "noetic"
elif (($ROS==2));then
source /opt/ros/foxy/setup.bash
echo "foxy"
else
echo "Non-ROS"
fi
案例:
使用新立得软件工具安装deb包。
点击应用:
实物如上:
roslaunch mir_gazebo mir_maze_world.launch
仿真如下:
环境图如下:
可以测试各类算法。
foxy-turtlebot3:
ign-gazebo-demos(ros1+ros2):
$ roslaunch ros_ign_gazebo_demos
air_pressure.launch gpu_lidar.launch
battery.launch image_bridge.launch
camera.launch imu.launch
create.launch magnetometer.launch
depth_camera.launch rgbd_camera_bridge.launch
diff_drive.launch rgbd_camera.launch
gpu_lidar_bridge.launch$ ros2 launch ros_ign_gazebo_demos
-a imu.launch.py
air_pressure.launch.py magnetometer.launch.py
battery.launch.py -p
camera.launch.py --print
-d --print-description
--debug rgbd_camera_bridge.launch.py
depth_camera.launch.py rgbd_camera.launch.py
diff_drive.launch.py -s
gpu_lidar_bridge.launch.py --show-all-subprocesses-output
gpu_lidar.launch.py --show-args
image_bridge.launch.py --show-arguments
Noetic:
Foxy:
电池耗尽机器人将停止运动!!!
ign_gazebo
演示如何将ign_gazebo
与ROS一起使用的演示。
启动ign_gazebo
启动文件,例如:
ros2 launch ros_ign_gazebo ign_gazebo.launch.py ign_args:="shapes.sdf"
ros1使用roslaunch
sensor_msgs/msg/FluidPressure
。
发布流体压力读数。
ros2 launch ros_ign_gazebo_demos air_pressure.launch.py
发布RGB相机图像和信息。
图像可以通过ros_ign_bridge
或ROS ros_ign_image发布
。
使用图像桥接(单向,使用image_transport):
ros2 launch ros_ign_gazebo_demos image_bridge.launch.py
使用常规桥接:
ros2 launch ros_ign_gazebo_demos camera.launch.py
向差速驱动车辆发送命令并听其里程表。
ros2 launch ros_ign_gazebo_demos diff_drive.launch.py
然后取消暂停并发送命令
ros2 topic pub /model/vehicle_blue/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 5.0}, angular: {z: 0.5}}"
深度相机数据可通过以下方式获得:
sensor_msgs/msg/Image
,通过ros_ign_bridge
或ros_ign_image
sensor_msgs/msg/PointCloud2
,通过 ros_ign_point_cloud
使用图像桥接(单向,使用image_transport):
ros2 launch ros_ign_gazebo_demos image_bridge.launch.py
使用ign_gazebo
件:
ros2 launch ros_ign_gazebo_demos depth_camera.launch.py
GPU激光雷达数据可通过以下方式获得:
sensor_msgs/msg/LaserScan
,通过 ros_ign_bridge
sensor_msgs/msg/PointCloud2
,通过ros_ign_bridge
或ros_ign_point_cloud
使用桥接:
ros2 launch ros_ign_gazebo_demos gpu_lidar_bridge.launch.py
使用ign_gazebo
插件:
ros2 launch ros_ign_gazebo_demos gpu_lidar.launch.py
发布IMU读数。
ros2 launch ros_ign_gazebo_demos imu.launch.py
发布磁场读数。
ros2 launch ros_ign_gazebo_demos magnetometer.launch.py
RGBD摄像机数据可通过以下方式获得:
sensor_msgs/msg/Image
,通过ros_ign_bridge
或ros_ign_image
sensor_msgs/msg/PointCloud2
,通过ros_ign_bridge
或ros_ign_point_cloud
使用图像桥接(单向,使用image_transport):
ros2 launch ros_ign_gazebo_demos image_bridge.launch.py
使用常规桥接:
ros2 launch ros_ign_gazebo_demos rgbd_camera_bridge.launch.py
使用ign_gazebo
插件:
ros2 launch ros_ign_gazebo_demos rgbd_camera.launch.py
获取电池的当前状态。
ros2 launch ros_ign_gazebo_demos battery.launch.py
然后发送命令,使车辆行驶并消耗电池电量
ros2 topic pub /model/vehicle_blue/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 5.0}, angular: {z: 0.5}}"