来源:Turtlebot4入门教程-软件-软件包安装 - 创客智造
说明:
相关设备:
turtlebot4
sudo apt update
sudo apt install ros-galactic-turtlebot4-description \
ros-galactic-turtlebot4-msgs \
ros-galactic-turtlebot4-navigation \
ros-galactic-turtlebot4-node
cd ~/turtlebot4_ws/src
git clone https://github.com/turtlebot/turtlebot4.git
cd ~/turtlebot4_ws
vcs import src < src/turtlebot4/dependencies.repos
rosdep install --from-path src -yi
source /opt/ros/galactic/setup.bash
colcon build --symlink-install
turtlebot4_description
turtlebot4_msgs
turtlebot4_msgs 包包含 TurtleBot 4 上使用的自定义消息:
UserButton:用户按钮状态。
UserLed:用户主导控制。
UserDisplay:用户显示数据。
TurtleBot 4 还可以使用 iRobot® Create® 3 平台支持的所有操作、消息和服务:
Actions
Messages
Services
**turtlebot4_navigation **
turtlebot4_navigation 包包含在 TurtleBot 4 上使用 SLAM 和导航的启动和配置文件。
它还包含 TurtleBot 4 Navigator Python 节点。
启动文件:
Nav Bringup:启动导航。允许启动配置使用 SLAM、Nav2 和本地化。
SLAM Sync:使用在线同步映射启动 slam_toolbox。建议在 PC 上使用。
SLAM Async:使用在线异步映射启动 slam_toolbox。推荐在树莓派 4 上使用。
Nav Bringup 启动配置选项:
namespace: Top-level namespace.
default: None
use_namespace: Whether to apply a namespace to the navigation stack.
options: true, false
default: false
slam: Whether to launch SLAM.
options: off, sync, async
default: off
localization: Whether to launch localization.
options: true, false
default: false
nav2: Whether to launch Nav2.
options: true, false
default: false
map: Full path to map yaml file to load.
default: /path/to/turtlebot4_navigation/maps/depot.yaml
use_sim_time: Use simulation (Gazebo) clock if true.
options: true, false
default: false
param_file: Full path to the ROS2 parameters file to use for nav2 and localization nodes.
default: /path/to/turtlebot4_navigation/config/nav2.yaml
autostart: Automatically startup the nav2 stack.
options: true, false
default: true
use_composition: Whether to use composed bringup.
options: true, false
default: true
ros2 launch turtlebot4_navigation nav_bringup.launch.py slam:=sync
ros2 launch turtlebot4_navigation nav_bringup.launch.py slam:=async
ros2 launch turtlebot4_navigation nav_bringup.launch.py localization:=true slam:=off map:=/path/to/map.yaml
TurtleBot 4 导航器
turtlebot4_node
Publishers:
/hmi/display: turtlebot4_msgs/msg/UserDisplay
description: The current information that is to be displayed (TurtleBot 4 model only).
/ip: std_msgs/msg/String
description: The IP address of the Wi-Fi interface.
Subscribers:
/battery_state: sensor_msgs/msg/BatteryState
description: Current battery state of the Create® 3.
/hmi/buttons: turtlebot4_msgs/msg/UserButton
description: Button states of the TurtleBot 4 HMI (TurtleBot 4 model only).
/hmi/display/message: std_msgs/msg/String
description: User topic to print custom message to display (TurtleBot 4 model only).
/hmi/led: turtlebot4_msgs/msg/UserLed
description: User topic to control User LED 1 and 2 (TurtleBot 4 model only).
/interface_buttons: irobot_create_msgs/msg/InterfaceButtons
description: Button states of Create® 3 buttons.
/joy: sensor_msgs/msg/Joy
description: Bluetooth controller button states (TurtleBot 4 model only).
/wheel_status: irobot_create_msgs/msg/WheelStatus
description: Wheel status reported by Create® 3.
Service Clients:
/e_stop: irobot_create_msgs/srv/EStop
description: Enable or disable motor stop.
/robot_power: irobot_create_msgs/srv/RobotPower
description: Power off the robot.
Action Clients:
/dock: irobot_create_msgs/action/DockServo
description: Command the robot to dock into its charging station.
/wall_follow: irobot_create_msgs/action/WallFollow
description: Command the robot to wall follow on left or right side using bump and IR sensors.
/undock: irobot_create_msgs/action/Undock
description: Command the robot to undock from its charging station.
Functions
该节点具有一组静态功能,可通过按钮或显示菜单使用。
目前支持的功能有:
Dock: Call the /dock action.
Undock: Call the /undock action.
Wall Follow Left: Call the /wall_follow action with direction FOLLOW_LEFT and a duration of 10 seconds.
Wall Follow Right: Call the /wall_follow action with direction FOLLOW_RIGHT and a duration of 10 seconds.
Power: Call the /robot_power service and power off the robot.
EStop: Call the /e_stop service and toggle EStop state.
Scroll Up: Scroll menu up.
Scroll Down: Scroll menu down.
Back: Exit message screen or return to first menu entry.
Select: Select currently highlighted menu entry.
Help: Print help statement.
Configuration
可以使用参数 .yaml 文件配置此节点。 默认机器人参数可以在这里找到。
Parameters:
wifi.interface: The Wi-Fi interface being used by the computer. This is used to find the current IP address of the computer.
menu.entries: Set menu entries to be displayed. Each entry must be one of the support functions.
buttons: Set the function of Create® 3 and HMI buttons.
controller: Set the function of TurtleBot 4 Controller buttons.
Buttons/按钮
turtlebot4_node 中的 Buttons 类为机器人上的所有按钮提供功能。 这包括 Create® 3 按钮、HMI 按钮和 TurtleBot 4 控制器按钮。 该节点从 /interface_buttons、/hmi/buttons 和 /joy 主题接收按钮状态。
每个按钮都可以配置为在按下时具有单一功能,或者通过短按或长按来配置两个功能。 这是通过配置完成的。
支持的按钮:
buttons:
create3_1:
create3_power:
create3_2:
hmi_1:
hmi_2:
hmi_3:
hmi_4:
controller:
a:
b:
x:
y:
up:
down:
left:
right:
l1:
l2:
l3:
r1:
r2:
r3:
share:
options:
home:
实例:
假设我们希望 TurtleBot 4 具有以下按钮功能:
短按 Create® 3 按钮 1 切换 EStop。
在 TurtleBot 4 控制器上按下 Home 5 秒即可关闭机器人。
短按 HMI 按钮 1 执行左墙跟随,长按 3 秒执行右墙跟随。
创建一个新的 yaml 文件:
cd /home/ubuntu/turtlebot4_ws
touch example.yaml
turtlebot4_node:
ros__parameters:
buttons:
create3_1: ["EStop"]
hmi_1: ["Wall Follow Left", "Wall Follow Right", "3000"]
controller:
home: ["Power", "5000"]
ros2 launch turtlebot4_bringup standard.launch.py param_file:=/home/ubuntu/turtlebot4_ws/example.yaml
LEDs
turtlebot4_node 中的 Leds 类控制 TurtleBot 4 上 HMI LED 的状态。它不用于 TurtleBot 4 Lite。
有 5 个状态 LED 由节点控制:POWER、MOTOR、COMMS、WIFI 和 BATTERY。 还有 2 个用户 LED:USER_1 和 USER_2,它们由用户通过 /hmi/led 主题控制。 BATTERY 和 USER_2 LED 由一个红色和绿色 LED 组成,可以将它们打开为绿色、红色或黄色(红色 + 绿色)。 其余的只有绿色。
状态 LED:
POWER: Always ON while turtlebot4_node is running.
MOTOR: ON when wheels are enabled, OFF when wheels are disabled.
Wheel status is reported on the /wheel_status topic.
COMMS: ON when communication with Create® 3 is active. OFF otherwise.
Receiving data on the /battery_state topic implies that communication is active.
WIFI: ON when an IP address can be found for the Wi-Fi interface specified in the configuration.
BATTERY: Colour and pattern will vary based on battery percentage.
Battery percentage is received on /battery_state topic.
用户 LED:
可以通过使用 UserLed 消息发布到 /hmi/led 主题来设置用户 LED。
用户引导消息:
led: Which available LED to use.
uint8 USER_LED_1 = 0
uint8 USER_LED_2 = 1
color: Which color to set the LED to.
uint8 COLOR_OFF = 0
uint8 COLOR_GREEN = 1
uint8 COLOR_RED = 2
uint8 COLOR_YELLOW = 3
blink_period: Blink period in milliseconds.
uint32 ms
duty_cycle: Percentage of blink period that the LED is ON.
float64 (0.0 to 1.0)
ros2 topic pub /hmi/led turtlebot4_msgs/msg/UserLed "led: 0
color: 1
blink_period: 1000
duty_cycle: 1.0" --once
ros2 topic pub /hmi/led turtlebot4_msgs/msg/UserLed "led: 0
color: 0
blink_period: 1000
duty_cycle: 1.0" --once
ros2 topic pub /hmi/led turtlebot4_msgs/msg/UserLed "led: 1
color: 2
blink_period: 1000
duty_cycle: 0.5" --once
Display
turtlebot4_node 中的 Display 类控制 TurtleBot 4 的 HMI 显示。
物理显示器是 128x64 OLED,通过 I2C 和 SSD1306 驱动程序进行控制。
显示器有一个标题行,其中包含配置中指定的 Wi-Fi 接口的 IP 地址,以及在 /battery_state 主题上收到的电池百分比。
显示屏还有 5 行默认用于菜单。 菜单条目在配置中指定,是一组可用功能。
可以通过使用字符串消息发布到 /hmi/display/message 来覆盖 5 个菜单行。
菜单可以有任意数量的条目。
如果有超过 5 个条目,用户将不得不向下滚动以查看不适合 5 个菜单行的条目。
Menu Control
TurtleBot 4 显示屏有一个简单的滚动菜单。 菜单有 4 种控制功能:向上滚动、向下滚动、选择和返回。
上下滚动允许用户浏览菜单条目,默认情况下分别映射到用户按钮 3 和 4。
选择功能将调用当前选择的菜单项。
这可以触发诸如停靠之类的操作、诸如 EStop 之类的服务,或显示诸如帮助消息之类的消息。 此功能默认映射到用户按钮 1。
返回功能允许用户从消息屏幕返回菜单。
如果菜单已经显示菜单条目,它将返回显示前 5 个菜单条目,并且第一个条目将突出显示。
TurtleBot 4 Robot
cd ~/turtlebot4_ws/src
git clone https://github.com/turtlebot/turtlebot4_robot.git
cd ~/turtlebot4_ws
vcs import src < src/turtlebot4_robot/dependencies.repos
rosdep install --from-path src -yi
source /opt/ros/galactic/setup.bash
colcon build --symlink-install
Base
Publishers:
/hmi/buttons: turtlebot4_msgs/msg/UserButton
description: Button states of the TurtleBot 4 HMI (TurtleBot 4 model only).
Subscribers:
/hmi/display: turtlebot4_msgs/msg/UserDisplay
description: The current information that is to be displayed (TurtleBot 4 model only).
/hmi/led/_: std_msgs/msg/Int32
description: Hidden topics indicating the state of each LED.
GPIO Interface
I2C Interface
SSD1306
配置
turtlebot4_base_node:
ros__parameters:
# GPIO definition for HMI. Do NOT change if you are using the standard PCBA.
gpio:
user_button_1: 13
user_button_2: 19
user_button_3: 16
user_button_4: 26
led_green_power: 17
led_green_motors: 18
led_green_comms: 27
led_green_wifi: 24
led_green_battery: 22
led_red_battery: 23
led_green_user_1: 25
led_green_user_2: 6
led_red_user_2: 12
display_reset: 2
Robot Upstart
systemctl | grep turtlebot4
turtlebot4.service loading active running "bringup turtlebot4"
。sudo journalctl -u turtlebot4 -r
sudo systemctl stop turtlebot4.service
sudo systemctl start turtlebot4.service
ros2 run robot_upstart install turtlebot4_bringup/launch/standard.launch.py --job turtlebot4 --rmw rmw_cyclonedds_cpp --rmw_config /etc/cyclonedds_rpi.xml
ros2 run robot_upstart install turtlebot4_bringup/launch/lite.launch.py --job turtlebot4 --rmw rmw_cyclonedds_cpp --rmw_config /etc/cyclonedds_rpi.xml
ros2 run robot_upstart uninstall turtlebot4
Bringup
turtlebot4_bringup 包包含启动和配置文件来运行机器人软件。
启动文件:
Joy Teleop: Launches nodes to enable the bluetooth controller.
OAKD: Launches the OAK-D nodes.
RPLIDAR: Launches the RPLIDAR node.
Robot: Launches the TurtleBot 4 nodes.
Lite: Launches all necessary nodes for the TurtleBot 4 Lite.
Standard: Launches all necessary nodes for the TurtleBot 4.
TurtleBot 4 Controller: Configurations for the TurtleBot 4 controller.
TurtleBot 4: Configurations for the turtlebot4_node and turtlebot4_base_node.
Diagnostics
Diagnostics: Launches the turtlebot4 diagnostics updater and the diagnostic aggregator node.
Diagnostics Updater
/battery_state: Check battery voltage and percentage.
/wheel_status: Check if wheels are enabled.
/dock: Check if the robot is docked.
/scan: Check the frequency of laser scans from the RPLIDAR.
/left/image: Check the frequency of images from the left OAK-D camera.
/right/image: Check the frequency of images from the right OAK-D camera.
/color/image: Check the frequency of images from the OAK-D colour sensor.
/stereo/image: Check the frequency of depth images from the OAK-D.
/hazard_detection: Check for detected hazards.
/imu: Check the frequency of IMU messages.
/mouse: Check the frequency of Mouse messages.
ros2 launch turtlebot4_viz view_diagnostics.launch.py
turtlebot4_tests
turtlebot4_tests 包包含 TurtleBot 4 系统测试脚本的源代码。 这些脚本测试机器人的基本功能,对于解决问题很有用。
ROS Tests
ROS 测试使用 ROS 主题和操作来测试各种系统功能。
测试结果保存到 ~/turtlebot4_test_results/Y_m_d-H_M_S 其中 Y_m_d-H_M_S 是测试的日期和时间。
在测试期间还会记录一个 rosbag 并保存到同一位置。
目前支持的测试:
Light Ring: Test the Create® 3 light ring
Create® 3 Button: Test the Create® 3 buttons
User LED: Test the HMI LEDs (TurtleBot 4 model only)
User Button: Test the HMI buttons (TurtleBot 4 model only)
Display: Test the HMI display (TurtleBot 4 model only)
Dock: Test the robots ability to undock and dock.
ros2 run turtlebot4_tests ros_tests
TurtleBot 4 Desktop
sudo apt update
sudo apt install ros-galactic-turtlebot4-desktop
cd ~/turtlebot4_ws/src
git clone https://github.com/turtlebot/turtlebot4_desktop.git
cd ~/turtlebot4_ws
rosdep install --from-path src -yi
source /opt/ros/galactic/setup.bash
colcon build --symlink-install
turtlebot4_viz
turtlebot4_viz 包包含启动文件和配置,用于在 Rviz2 中查看机器人,以及查看诊断。
启动文件:
View Diagnostics: Launches rqt_robot_monitor to view diagnostic data.
View Model: Launches rviz2. Used to view the model and sensor data.
View Robot: Launches rviz2. Used to view the robot while navigating.
TurtleBot 4 Simulator
sudo apt install -y \
python3-colcon-common-extensions \
python3-rosdep \
python3-vcstool
sudo apt-get update && sudo apt-get install wget
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
sudo apt-get update && sudo apt-get install ignition-edifice
sudo apt update
sudo apt install ros-galactic-turtlebot4-simulator ros-galactic-irobot-create-nodes
cd ~/turtlebot4_ws/src
git clone https://github.com/turtlebot/turtlebot4_simulator.git
cd ~/turtlebot4_ws
vcs import src < src/turtlebot4_simulator/dependencies.repos
rosdep install --from-path src -yi
source /opt/ros/galactic/setup.bash
colcon build --symlink-install
Ignition Bringup
Ignition: Launches Ignition Gazebo and all required nodes to run the simulation.
ROS Ignition Bridge: Launches all of the required ros_ign_bridge nodes to bridge Ignition topics with ROS topics.
TurtleBot 4 Nodes: Launches the turtlebot4_node and turtlebot4_ignition_hmi_node required to control the HMI plugin and robot behaviour.
model: Which TurtleBot 4 model to use.
options: standard, lite
default: standard
rviz: Whether to launch rviz.
options: true, false
default: false
slam: Whether to launch SLAM.
options: off, sync, async
default: off
nav2: Whether to launch Nav2.
options: true, false
default: false
param_file: Path to parameter file for turtlebot4_node.
default: /path/to/turtlebot4_ignition_bringup/config/turtlebot4_node.yaml
world: Which world to use for simulation.
default: depot
robot_name: What to name the spawned robot.
default: turtlebot4
ros2 launch turtlebot4_ignition_bringup ignition.launch.py
ros2 launch turtlebot4_ignition_bringup ignition.launch.py slam:=sync nav2:=true rviz:=true
Ignition GUI Plugins
Ignition Toolbox