Fezzik’s Brain

Summary

The brain is the software device that controls all the other features in Fezzik. It is a state machine that selects what should run at what points in the Fezzik demonstration flow. The following figure shows the Fezzik state machine; below we explain how to generate it.

_images/sm_sis.jpg

Hardware Requirements

For the brain itself, you need no hardware. You can run through every major state in the brain using just the command line and ROS. However, the brain also interacts with each of the other components, and it is only useful when it moves from one state to another based on what is happening in the real world. So in that sense, it requires the full physical presence and sensing capabilities of Robot DE NIRO.

Software Requirements

  • smach: the state machine package
  • smach-viewer: visualise the state machine in qt (optional)

The brain also depends on each of the other major features. This is so that the brain can reach into other packages, launch them, access their .srv files, and retrieve other types of information. If you intend to have the brain intimately linked with the other features, then these must be added to package.xml as dependencies.

This can be done by adding <depend>package_name<depend> to the file.

Installation Steps

  1. Install smach
$ sudo apt-get install ros-kinetic-smach
  1. Install smach-viewer
$ sudo apt-get install ros-kinetic-smach-viewer

Setup Tests

There is no specific set-up necessary for the brain other than ensuring all the other components are functioning properly.

Implementation

The brain is a state machine, managing which states the robot is in and engaging certain functions accordingly. The states (in order) are:

  1. InitRobot
  2. Idling
  3. Listening
  4. RememberingUser
  5. Navigating
  6. Grasping
  7. Returning
  8. SeekingUser
  9. OfferingObject

We built the main structure of the brain state machine off the model from a previous project with Robot DE NIRO and using the smach package for ROS. This package is perfectly suited for using state machines with ROS.

SM_MACH.PY

This file contains details on the state transitions. At the moment, the states are purely sequential, with no loops or other complicated structures. The order can easily be changed by replacing the state associated with the TRANSITION keyword in the transitions dictionary.

Note

TRANSITION is a variable representing the string "Transitioning to".

More complex structures can also be created by adding more keys to this dictionary. For example, the following code would also add a failure branch to the Listening state which forces it to go back to Idling.

# define FAILURE = "failure"
smach.StateMachine.add(LISTENING, sm_states.Listening(),
                                transitions = {TRANSITION: REMEMBERING_USER, FAILURE: IDLING}
)

SM_STATES.PY

The definitions of each state is defined here. Each state has an associated constructor and an execute method that is called when the state machine is running.

Usage

To kick off the state machine,

$ roslaunch brain brain.launch

This launches sm_main.py, which then goes on to employ all the other files beginning with sm_. In addition, this launch file also launches the _.launch files in the other packages except Navigation, which was intended to run on a separate computer.

If there are no errors, the brain will first run the INIT_ROBOT state which has two jobs: to initialise all the parameters, used in Project Fezzik, on the ROS parameter server (see ros_parameters for a list of these); and to run initial status checks.

You can visualise the state machine once it’s running by typing the following command in a new terminal window

$ rosrun smach-viewer smach-viewer.py

This will display the figure displayed in the summary section.

Status Checks

The status checks are responsible for asking each Fezzik feature whether it is ready. This works by calling the status_checks method in the status_check_client.py file in the brain.

Currently, this method only checks whether the grasping is ready i.e. the arms are enabled and placed in the neutral position, and the grippers calibrated. In the future, this should be extended to the other packages as well.

Limitations

  • The structure of the brain is very simple. Future projects could extend this to add additional complexity.
  • The only status check performed is for grasping. Status checks for other packages should also be added too to increase robustness.