robot_statemachine: rsm_additions | rsm_core | rsm_msgs | rsm_rqt_plugins | rsm_rviz_plugins

Package Summary

The statemachine package includes the Robot Statemachine's main functionality

Documentation

The RSM consists of various non-customizable and custom states that are based on the Base State. The former non-customizable states and the Base State are a part of this package containing the RSM's basics. To handle state transitions the State Interface is used. Robot Control Mux coordinates the actual control of the robot's movement while the Service Provider contains services, publishers and subscribers for communication between states and updating the GUI. To be able to handle arbitrary robots, the RSM relies on Plugins that can be implemented depending on the robot.

Base State

The base state for all states of the RSM features the following four main functions:

  • onSetup
  • onEntry
  • onActive
  • onExit

The function onSetup is called immediately after it was constructed and should be used to initialize the state. The function onEntry is run before the state's onActive method is executed for the first time and should be used to start up the processing in the state. The latter is the state's primary method that is executed periodically and contains its main logic. onExit is called before the state will be destroyed and should take care of leaving the state cleanly.

To realize interrupts in the RSM, the following five functions need to be implemented:

  • onExplorationStart
  • onExplorationStop
  • onWaypointFollowingStart
  • onWaypointFollowingStop
  • onInterrupt

These functions handle commands issued from the GUI or the use of teleoperation by telling the current state which command or interrupt occurred and let the state handle it. The method onInterrupt receives the type of interrupt which are also defined in the Base State and are listed below:

  • INTERRUPT_END: Former interrupt ended (only relevant to specific interrupt handlers)
  • EMERGENCY_STOP_INTERRUPT: Emergency Software Stop was pushed in the GUI
  • TELEOPERATION_INTERRUPT: Teleoperation was used
  • SIMPLE_GOAL_INTERRUPT: A navigation goal was issued through the RViz GUI
  • SIMPLE_GOAL_STOP_INTERRUPT: The navigation goal was stopped in the GUI

The four other methods receive a reference to a bool and a string variable. The former informs if the request was successful and the desired action will be executed (true) or not (false) and the latter features a descriptive text.

The Base State holds a reference to the State Interface which has to be used for state transitions. It also has a variable with its name that is necessary to display the current state in the GUI and needs to be set in the onSetup or onEntry method.

State Interface

The State Interface holds a reference to the current state and handles state transitions. It also provides references to plugins created for exploration, navigation, mapping or routines. The State Interface provides the method transitionToVolatileState which will initiate a transition to the state provided as an argument. The provided argument is a boost::shared_ptr of the Base State type. This can be one of the known non-customizable states or a custom state defined through a plugin.

To access these plugins State Interface offers the method getPluginState which takes the plugin type and optionally a plugin routine name as parameters. The former can be one of the following types:

  • CALCULATEGOAL_STATE
  • NAVIGATION_STATE
  • MAPPING_STATE
  • ROUTINE_STATE

For a ROUTINE_STATE the routine name needs to be provided as well, otherwise this parameter can remain empty. The other plugin states are set by parameters provided to State Interface on launch. If no plugin type was specified but only a name, arbitrary plugins can be created and returned for state transition. If no plugin type and name were received or the desired plugin to be created does not exist, the Idle State will be returned and an error message put out.

State Interface subscribes to the stateInfo and simpleGoal topics to issue interrupts to the currently active state. Furthermore, it offers the two services startStopExploration and startStopWaypointFollowing which call the particular function in the active state.

The State Interface updates the currently active state periodically through its awake function. This function also executes the state transition initiated by transitionToVolatileState and calls the active state's methods.

Robot Control Mux

The Robot Control Mux (=Multiplexer) controls the velocity commands sent to the ROS node interfacing the motor controllers. In a simple configuration, a navigation or teleoperation node would output velocity commands that will be received by the motor controller interface and move the robot. To enable high level control of the input the motor controller receives, the Robot Control Mux should be the only node in the setup publishing directly on the topic the motor controller interface subscribes to.

Velocity commands generated by navigation should be published to an autonomy topic and velocity commands issued by teleoperation to a teleoperation topic. These two topics are subscribed by the Robot Control Mux that decides which or if any topic will be forwarded. The two input and the output topic's names are set by parameters at launch.

Which topic will be conducted is based on the operation mode which can be one of the following:

  • Autonomy
  • Stopped
  • Teleoperation

For Autonomy and Teleoperation the respective topic is propagated to the motor controller interface. If the operation mode is set to Stopped a command velocity of zero for all directions is published. The operation mode can be set through the GUI by a service Robot Control Mux is providing. It is published to the GUI for display as well. If a teleoperation command is issued, the mode automatically switches to Teleoperation. When in Teleoperation mode, a timer is started to supervise if new commands are being issued. If no new commands are received for the timer duration (which is set through a parameter), Teleoperation is replaced with the Stopped mode.

If the software emergency stop is activated in the GUI, the operation mode is handled as Stopped and cannot be changed until the stop button is released again.

Service Provider

The Service Provider handles the communication between the different states and saves data throughout state transitions. Therefore it offers a lot of services to save and retrieve variables for the core functionality of the RSM.

It offers all services to control waypoint following which includes adding, moving and removing single waypoints, setting their visited and unreachable variables and the routine to be executed upon reaching the waypoint. Furthermore, all waypoints can be retrieved and reset which effectively sets visited and unreachable to false. The waypoint following mode can be set and the list of all available routines retrieved. The latter is given as a parameter to the Service Provider. The list of waypoints is also published.

For setting and retrieving the current navigation goal the Service Provider is offering services. In addition, previously failed goals can be set, retrieved or reset. These serve as a way of blacklisting goals.

The current robot pose can be retrieved and is calculated from the transform of the map to the robot's base footprint.

The Service Provider hosts services for exploration that enable setting and getting the exploration mode. It is also published. If the exploration mode is set to Interrupt, the Service Provider subscribes to the list of available exploration goals and checks if the current navigation goal is still in this list. A tolerance for comparing these positions can be set with a parameter. If the navigation goal is not an exploration goal anymore, it becomes obsolete. This info is published when the mode is set to Interrupt as well.

Furthermore, it advertises services for setting and retrieving the reverse mode, which is also published.

Non-customizable states

The core state machine already features the following states for direct usage:

  • Boot State: Is the first state to be called and subscribes to a service which tells it when all necessary systems are available and ready to use. Then it initiates a transition to the Idle State. Can only be interrupted by the software emergency stop.
  • Emergency Stop State: State being called when the software emergency stop was pushed. Only allows transition to Idle State when button is released.
  • Idle State: Standard state when no commands were issued. Allows transitions to all other states through interrupts.
  • Teleoperation State: State being called when teleoperation commands were issued. Only transitions to Idle State when teleoperation timed out and Emergency Stop State when receiving the respective interrupt.
  • Waypoint Following State: Handles the waypoint following functionality by providing the next navigation goal depending on the status of all waypoints and the waypoint following mode. Normally transitions to the navigation state plugin. Can be interrupted by the software emergency stop and teleoperation which leads to a transition to the particular state. If waypoint following is stopped, transitions to Idle State.

Plugins

The RSM package requires three different plugin states, one for exploration to calculate the next goal, one for navigation and one for mapping. The first is called when exploration is started or a previous exploration target was mapped successfully and should interface an exploration package like explore_lite which finds unexplored regions in the map and extract a next goal from it. The second should interface a package for navigation like the ROS navigation stack and update the RSM according to the navigation's progress. The last is called when an exploration goal is reached and can include movements for better map acquisition or similar behaviors.

Also, up to ten plugins states can be included for the waypoint following routines that are executed upon reaching a waypoint. They are not necessary for the RSM like the plugins mentioned above. These routines can be implemented to enable arbitrary behavior when reaching a certain waypoint, for example inspecting gauge valves with a camera.

More plugins can be added if additional states during exploration or waypoint following are desired. These can only be called from other implemented plugin states as the basic RSM only includes transitions to the plugins described above. For example, if you have a robot able to climb stairs and you detect stairs during navigation, you can then call another plugin for stair-climbing and afterwards transition back to normal navigation.

Tutorials

The following section displays some examples and tutorials on how to use the RSMas well as the required setup to use the RSM. Afterwards, running and launching the RSM on its own and in a simulation environment is presented. The provided GUI and its controls are shown and a tutorial on writing and including your own plugin state is presented last.

  1. Launch RSM Simulation

    How to launch the provided simulations demonstrating the Robot Statemachine.

  2. GUI Introduction

    How to use the GUI provided by the Robot Statemachine in RViz and rqt.

  3. RSM Robot Setup

    Required steps to setup a mobile robot to use the Robot Statemachine for exploration and waypoint following.

  4. Run RSM

    Launch the Robot Statemachine for your robot

  5. Writing a Plugin State

    How to write a plugin state for the Robot Statemachine and properly setup the package where it will be in

  6. Use Plugin State in the RSM

    Use the previously created Plugin State in the RSM

Nodes

rsmNode

This node realizes transitions between the different states.

Subscribed Topics

operationMode (rsm_msgs/OperationMode)
  • The current operation mode as set by the GUI or interrupts
simpleGoal (geometry_msgs/PoseStamped)
  • Navigation goal set in RViz

Published Topics

stateInfo (std_msgs/String)
  • Current state info text

Services

startStopExploration (std_srvs/SetBool)
  • Call to start or stop exploration, depending on the bool value (true: start, false: stop)
startStopWaypointFollowing (std_srvs/SetBool)
  • Call to start or stop waypoint following, depending on the bool value (true: start, false: stop)
stateInfo (std_srvs/Trigger)
  • Get current state info text
stop2DNavGoal (std_srvs/Trigger)
  • Call to stop navigation started through RViz tool 2D Nav Goal

Parameters

~update_frequency (float, default: 20)
  • Update rate in Hz
~calculate_goal_plugin (string, default: "rsm::CalculateGoalPlugin")
  • Sets the plugin's name for the state calculating the next goal
~navigation_plugin (string, default: "rsm::NavigationPlugin")
  • Sets the plugin's name for the navigation state
~mapping_plugin (string, default: "rsm::MappingPlugin")
  • Sets the plugin's name for the mapping state.

robotControlMuxNode

This node is for controlling if the robot is running autonomous, by teleoperation or is stopped.

Subscribed Topics

<teleoperation_cmd_vel_topic> (std_msgs/String)
  • Publishes teleoperation command velocities
<autonomy_operation_cmd_vel_topic> (std_msgs/String)
  • Publishes autonomy command velocities

Published Topics

<cmd_vel_topic> (std_msgs/String)
  • Command velocity that the robot should follow
operationMode (rsm_msgs/OperationMode)
  • The current operation mode as set by the GUI or interrupts

Services

setOperationMode (rsm_msgs/SetOperationMode)
  • Sets the operation mode to the given parameter

Parameters

~update_frequency (float, default: 20)
  • Update rate in Hz
~autonomy_cmd_vel_topic (string, default: "autonomy/cmd_vel")
  • Topic name for the autonomy command velocity
~teleoperation_cmd_vel_topic (string, default: "teleoperation/cmd_vel")
  • Topic name for the teleoperation command velocity
~cmd_vel_topic (string, default: "cmd_vel")
  • Topic name for the command velocity the robot should follow
~teleoperation_idle_timer (double, default: 0.5)
  • Time until teleoperation is stopped when no new command is received

serviceProviderNode

This node provides services for saving and receiving data needed by the volatile states.

Subscribed Topics

exploration_goals (geometry_msgs/PoseArray)
  • List of all currently available exploration goals (only active if exploration mode is set to "interrupt")

Published Topics

waypoints (rsm_msgs/WaypointArray)
  • List of all waypoints and their information
explorationMode (std_msgs/Bool)
  • The current exploration mode (true: interrupt, false: finish)
goalObsolete (std_msgs/Bool)
  • Information if the current goal is still viable (only active is exploration mode is set to "interrupt")
reverseMode (std_msgs/Bool)
  • Information if the robot is currently moving in reverse (true: reverse, false: forward)

Services

addWaypoint (rsm_msgs/AddWaypoint)
  • Add a waypoint to the list of waypoints
getWaypoints (rsm_msgs/GetWaypoints)
  • Get list of waypoints
moveWaypoint (rsm_msgs/MoveWaypoint)
  • Move the waypoint at the given position in the waypoint list
removeWaypoint (rsm_msgs/RemoveWaypoint)
  • Remove the waypoint at the given position in the waypoint list
waypointVisited (rsm_msgs/WaypointVisited)
  • Set the waypoint at the given position in the waypoint list to visited
waypointUnreachable (rsm_msgs/WaypointUnreachable)
  • Set the waypoint at the given position in the waypoint list to unreachable
resetWaypoints (std_srvs/Trigger)
  • Reset all waypoint's status to default
setWaypointFollowingMode (rsm_msgs/SetWaypointFollowingMode)
  • Sets the waypoint following mode (0: single, 1: roundtrip, 2: patrol)
setWaypointRoutine (rsm_msgs/SetWaypointRoutine)
  • Sets the routine of the waypoint at the given position in the waypoint list
getWaypointRoutines (rsm_msgs/GetWaypointRoutines)
  • Return the list of all waypoint routines available
setNavigationGoal (rsm_msgs/SetNavigationGoal)
  • Sets the current navigation goal
getNavigationGoal (rsm_msgs/GetNavigationGoal)
  • Gets the current navigation goal
addFailedGoal (rsm_msgs/AddFailedGoal)
  • Add an unreachable goal to the list of all failed goals
getFailedGoals (rsm_msgs/GetFailedGoals)
  • Return list of all previously failed goals
resetFailedGoals (std_srvs/Trigger)
  • Deletes the list of previously failed goals
getRobotPose (rsm_msgs/GetRobotPose)
  • Return the current robot pose in relation to the map frame
setExplorationMode (std_srvs/SetBool)
  • Set the exploration mode (true: interrupt, false: finish)
getExplorationMode (std_srvs/Trigger)
  • Get the exploration mode
SetReverseMode (std_srvs/SetBool)
  • Set the robot to reverse mode (true: reverse, false: forward)
GetReverseMode (std_srvs/Trigger)
  • Return the reverse mode (true: reverse, false: forward)

Parameters

~update_frequency (float, default: 20)
  • Update rate in Hz
~robot_frame (string, default: "/base_link")
  • Transform frame for the robot
~waypoint_routines (std::vector, default: [])
  • Vector with waypoint routines available as state plugins
~exploration_goal_tolerance (double, default: 0.05)
  • Distance in all directions in meters that the robot's current position can differ from an exploration goal to still count it as reached

Required tf Transforms

<robot_frame>map
  • Usually provided by SLAM

Wiki: rsm_core (last edited 2019-09-13 12:59:15 by MarcoSteinbrink)