Custom behaviors and launch files for demonstrations of the ROS 2 and FlexBE-based Flexible Navigation (Wiki) for use with the Kobuki-based Turtlebot 2 system.
This repository contains code that interfaces with the ROS 2 versions of the Kobuki Turtlebot2 models, the FlexBE Behavior Engine, [FlexBE App], and the Flexible Navigation system.
This package has a number of dependencies.
For CNU Robotics work, we typically use CHRISLab Install scripts to handle workspace setup, install, and build. The repos listed below are included in the CHRISLab Install scripts.
Quickly skim this README before installing or running anything:
This demonstration makes use of the following repositories:
- git: {local-name: src/flexbe_webui, uri: 'https://github.com/FlexBE/flexbe_webui.git', version: main }
- git: {local-name: src/flexbe_behavior_engine, uri: 'https://github.com/FlexBE/flexbe_behavior_engine.git', version: ros2-devel }
- git: {local-name: src/flexible_navigation, uri: 'https://github.com/FlexBE/flexible_navigation.git', version: ros2-devel }
- git: {local-name: src/flex_nav_turtlebot2_demo, uri: 'https://github.com/CNURobotics/flex_nav_turtlebot2_demo.git', version: ros2-devel }
- git: {local-name: src/ball_detector, uri: 'https://github.com/CNURobotics/ball_detector.git', version: ros2-devel }
- git: {local-name: src/chris_ros_turtlebot2, uri: 'https://github.com/CNURobotics/chris_ros_turtlebot2.git', version: ros2-devel }
- git: {local-name: src/chris_world_models, uri: 'https://github.com/CNURobotics/chris_world_models.git', version: ros2-devel }
See specific directions for each package in their associated README files.
Install in the src folder of your WORKSPACE_ROOT, and from the
colcon build --symlink-install . setup.bash
or use the aliases in chris_install (e.g. ccb, ccbs, ccbu)
NOTE: Anytime you build new packages, you need to re-run the setup.bash script inside the workspace root. Anytime you change a Python script or launch file, you need to re-run
colcon buildfrom the WORKSPACE_ROOT folder, but you only need to re-source. setup.bashwhen the package information and folders change.
A number of start up scripts are provided in flex_nav_turtlebot2_bringup
export USE_SIM_TIME=False ros2 run flex_nav_turtlebot2_bringup hw-tmux ros2 run flex_nav_turtlebot2_bringup onboard-tmux
And on OCS computer,
ros2 run flex_nav_turtlebot2_bringup ocs-tmux
For onboard hw, the tmux is preferred.
For OCS, either ocs-tmux or launch-ocs bash script is available.
export USE_SIM_TIME=True ros2 run flex_nav_turtlebot2_bringup launch-sim ros2 run flex_nav_turtlebot2_bringup launch-onboard ros2 run flex_nav_turtlebot2_bringup launch-ocs
These may be started up on a single computer, or multiple computers if using networked simulation.
There are also associated tmux versions for simulation if preferred.
NOTE: With both
tmuxandlaunchscripts, the terminal will close if the started nodes completely shutdown. Manually starting each script may be warranted for debugging.
To launch in separate terminals, use these commands in each terminal:
Note: the launch scripts default to using
use_sim_time:=True
# Simulation
clear; ros2 launch chris_world_models ${WORLD_MODEL:=gazebo_creech_world}.launch.py
clear; ros2 launch chris_ros_turtlebot2 turtlebot_gazebo.launch.py
# Onboard
# To use other (e.g. fake, amcl, or cartographer, set LOCALIZATION environment variable (e.g. export LOCALIZATION=amcl)
# To use other (e.g. flex, flex_multi, or flex_four_level, set FLEX_NAV_SETUP environment variable (e.g. export LOCALIZATION=flex)
clear; ros2 launch flex_nav_turtlebot2_bringup "${LOCALIZATION:=fake}.launch.py"
clear; ros2 launch flex_nav_turtlebot2_bringup ${FLEX_NAV_SETUP:=flex}.launch.py
clear; ros2 launch flexbe_onboard behavior_onboard.launch.py
# Operator Control Station (OCS)
clear; ros2 launch flex_nav_turtlebot2_bringup rviz.launch.py
clear; ros2 launch flexbe_webui flexbe_ocs.launch.py headless:=true
clear; ros2 run flexbe_webui webui_client --qt_software
# Optional depending on selected behavior
clear; ros2 launch flex_nav_turtlebot2_bringup paths_by_name.launch.py
clear; ros2 launch simple_ball_detector ball_detector.launch.py
Note: We are using the
--qt_softwareoption forflexbe_webuiversion4.0.3due to some observed issues on older NVidia GPUs and Ubuntu 24.04.
Note: If using
amclfor localization, you will need to manually start themap_serverfor now. The map server publishes the known map that you are working with.
e.g.,
ros2 launch chris_world_models creech_map_050_server.launch.py
Do this before starting
amcllocalization, which will activate the map server lifecycle by default.
All of these scripts also make use of the following environment variables:
export WORLD_MODEL= export LOCALIZATION=fake # (e.g. fake, slam, amcl, or cartographer) export USE_SIM_TIME=true # (or false as appropriate) export FLEX_NAV_SETUP=flex # (or flex_multi_level or flex_four_level) export WORLD_MODEL=gazebo_creech_world #( if not set by launch, see the `chris_world_models` package for more world model setups.)
By default we are using the fake localization provided by chris_ros_turtlebot2 for testing.
Typically the setup.bash is created by the setup script created during our standard
install process CHRISLab Install .
The following directions are for a simple demonstration of Flexible Navigation
The "Detector" behaviors look for balls in the scene. To add some to simulation at random locations use:
ros2 launch chris_world_models creech_random_balls.launch.py
The launch file specifies 8 blue, 2 red, and 4 green balls dropped randomly in Creech world.
You can edit the launch file to change quantities, or use the add_balls.launch.py and edit the param/balls.csv file
if you want to start with specified locations.
Displays a standard view of transforms of Turtlebot2, sensor data, with maps, and paths displayed
NOTE: This is typically started by the
launch-ocsscript described above.
-
ros2 launch flex_nav_turtlebot2_bringup rviz.launch.pyThis custom version adds the robot model, path, and global cost map to the default cartographer setup.
- A
Pathto the RViz display and set the topic to/high_level_planner/plan - A
RobotModel(uses the/robot_descriptiontopic) - A
Mapshowing the topic/global_costmap/costmap - The
2D Goal Posepublishes to the topic/flex_nav_global/goal
- A
You may want to add a Camera pointing to the /ball_detector/image to see the marked balls.
These are relatively small and may not be that useful.
To see full size, it might be better to periodically run:
ros2 run image_view image_saver --ros-args --remap image:=/ball_detector/imageorros2 run image_view image_view --ros-args --remap image:=/ball_detector/image
You can also add a MarkerArray with the topic /ball_detector/ball_markers.
In the topic, you will need to set the Reliability to "Best Effort" for the topics to be received.
- ROS 2 defaults to publishing sensor data as "Best Effort" to save band width for large data systems.
NOTE: This section is only applicable if using manual start up. Otherwise, the
hw-tmuxorlaunch-onboardscripts described above have already started these scripts with the selection made via theFLEX_NAV_SETUPenvironment variable.
Then start one (and only one) of the following:
ros2 launch flex_nav_turtlebot2_bringup flex.launch.py
- This starts the planning and control nodes.
- This version uses a 2-level planner as a demonstration.
- The global planner plans over the full map, with sensor data
- The local planner plans over smaller window trying to follow the global path
or
ros2 launch flex_nav_turtlebot2_bringup flex_multi_level.launch.py
-
This starts the planning and control nodes.
-
This version uses a 3-level planner as a demonstration.
-
The high-level planner is based only on the static map
-
The mid-level planner using only local obstacle sensing
-
The low-level planner using the ROS 2 Navigation2 DWBLocalPlanner as controller
-
The mid- and low-level planners run concurrently as they try to follow the global path defined by the high-level planner.
or
ros2 launch flex_nav_turtlebot2_bringup flex_four_level.launch.py
-
This starts the planning and control nodes.
-
This version uses a 4-level planner as a demonstration.
-
The high-level planner is based only on the static map
-
The mid-level planner using only local obstacle sensing
-
The low-mid-level planner using only local obstacle sensing
-
The low-level planner using the ROS 2 Navigation2 DWBLocalPlanner as controller
-
The mid- and low-level planners run concurrently as they try to follow the global path defined by the high-level planner.
Flexible Navigation requires startup of planning and control nodes, as well as the FlexBE behavior engine and UI.
After OCS startup, all control is through the FlexBE WebUI operator interface and RViz.
-
First load the desired behavior through the
FlexBE Behavior Dashboardtab.- The behavior should match the flex launch started above.
flex.launch.py-->Turtlebot 2 Flex Plannerflex_multi_level.launch.py-->Turtlebot 2 Multi Level Flex Plannerflex_four_level.launch.py-->Turtlebot 2 Four Level Flex Planner
- The behavior should match the flex launch started above.
-
Examine (but don't modify yet!) the behavior using the
Statemachine Editorbutton on FlexBE app- Click on a state to see the configurable parameters
-
Execute the behavior via the
FlexBE Runtime Controltab.- Click
Connectto establish the initial connection between App and Behavior Engine - Then
Start Execution
- Click
-
The system requires the operator to input a
2D Nav Goalvia theRVizscreen- If the system is in
lowautonomy or higher, the system will request a global plan as soon as the goal is received - If the autonomy level is
off(default), then the operator will need to confirm receipt by clicking thedonetransition.
- If the system is in
-
After requesting a path to the goal, the resulting plan will be visualized in the
RVizwindow.- If the system is not in full autonomy mode, the operator must confirm that the system should execute the plan via the
FlexBE UI - If the operator sets the
Runtime Executivetofullautonomy, the plan will automatically be executed. - In less than
fullautonomy, the operator can request a recovery behavior at this point.
- If the system is not in full autonomy mode, the operator must confirm that the system should execute the plan via the
-
Once execution of this plan is complete,
FlexBEwill seek permission to continue planning- In
fullautonomy, the system will automatically transition to requesting a new goal - In any autonomy level less than
full, the system will require an operator decision to continue
- In
Whenever a plan is being executed, the FlexBE state machine transitions to a concurrent node that uses on line planners
to refine the plans as the robot moves, and also monitors the Turtlebot bumper status for collision.
The operator can terminate the execution early by selecting the appropriate transition in the FlexBE UI.
If this low level plan fails, the robot will request permission to initiate a recovery behavior;
in full autonomy the system automatically initiates the recovery.
Note: The current set up uses the DWB controller for the local planner. This has known issues with achieving the final pose, and will often fail to acheive the final pose.
Please use the following publications for reference when using Flexible Navigation:
-
David C. Conner and Justin Willis, "Flexible Navigation: Finite state machine-based integrated navigation and control for ROS enabled robots," SoutheastCon 2017.
-
Joshua Zutell, David C. Conner and Philipp Schillinger, "ROS 2-Based Flexible Behavior Engine for Flexible Navigation," SoutheastCon, 2022.
