components.robot.behaviors package

Submodules

components.robot.behaviors.motion_planning_behaviors module

class components.robot.behaviors.motion_planning_behaviors.NavigateToPoint(robot, key, robot_communicator, simulator_communicator, name='NavigateToPoint')

Bases: py_trees.behaviour.Behaviour

Robot behavior to navigate to a specific point in the structure. Upon receiving a message to reach the desired destination, the behavior will perform the necessary actions to reach the sepcified point.

Note that the behavior does not do any of the work, it alerts a separate process to do the real work. This behavior is not blocking and can be interrupted in the middle of trying to navigate to a point.

Note that path planning is performed for each initialization. May want to remove this

For each tick, the behavior returns:
SUCCESS: If robot has reached specified point RUNNING: Robot in process of reaching specified point but has not yet reached it FAILURE: Robot has failed to reach point
initialise()

Note

User Customisable Callback

Subclasses may override this method to perform any necessary initialising/clearing/resetting of variables when when preparing to enter this behaviour if it was not previously RUNNING. i.e. Expect this to trigger more than once!

setup()

Note

User Customisable Callback

Subclasses may override this method for any one-off delayed construction & validation that is necessary prior to ticking the tree. Such construction is best done here rather than in __init__ so that trees can be instantiated on the fly for easy rendering to dot graphs without imposing runtime requirements (e.g. establishing a middleware connection to a sensor or a driver to a serial port).

Equally as important, executing methods which validate the configuration of behaviours will increase confidence that your tree will successfully tick without logical software errors before actually ticking. This is useful both before a tree’s first tick and immediately after any modifications to a tree has been made between ticks.

Tip

Faults are notified to the user of the behaviour via exceptions. Choice of exception to use is left to the user.

Warning

The kwargs argument is for distributing objects at runtime to behaviours before ticking. For example, a simulator instance with which behaviours can interact with the simulator’s python api, a ros2 node for setting up communications. Use sparingly, as this is not proof against keyword conflicts amongst disparate libraries of behaviours.

Args:
**kwargs (dict): distribute arguments to this
behaviour and in turn, all of it’s children
Raises:
Exception: if this behaviour has a fault in construction or configuration

See also

py_trees.behaviour.Behaviour.shutdown()

terminate(new_status)

Nothing to clean up in this example.

update()

Note

User Customisable Callback

Returns:
Status: the behaviour’s new status Status

Subclasses may override this method to perform any logic required to arrive at a decision on the behaviour’s new status. It is the primary worker function called on by the tick() mechanism.

Tip

This method should be almost instantaneous and non-blocking

class components.robot.behaviors.motion_planning_behaviors.PlaceBlock(robot, key, robot_communicator, simulator_communicator, state_key='state/block_has_been_placed', place_block_key='place_block/location_to_place_block', remove_block_key='remove_block/block_to_remove', name='PlaceBlock')

Bases: py_trees.behaviour.Behaviour

Robot behavior to place a block on the structure. Upon receiving a message to place a block, the behavior will perform the necessary actions to place the block on the structure.

Note this behavior is blocking in that it will wait for the robot to either succeed or fail at placing the block. This blocking is performed to ensure that the robot cannot be interrupted when in the process of placing a block, as all blocks should be either placed completely or not at all

For each tick, the behavior returns:
SUCCESS: If robot has successfully placed block FAILURE: Robot has failed at placing a block
initialise()

Reset a counter variable.

setup()

No delayed initialisation required for this example.

update()

Increment the counter and decide upon a new status result for the behaviour.

class components.robot.behaviors.motion_planning_behaviors.RemoveBlock(robot, key, robot_communicator, simulator_communicator, name='RemoveBlock')

Bases: py_trees.behaviour.Behaviour

Robot behavior to remove a block from the structure. Upon receiving a message to remove a block, the behavior will perform the necessary actions to remove the block from the structure.

Note this behavior is blocking in that it will wait for the robot to either succeed or fail at removing the block. This blocking is performed to ensure that the robot cannot be interrupted when in the process of removing a block, as all blocks should be either removed completely or not at all

For each tick, the behavior returns:
SUCCESS: If robot has successfully removed block FAILURE: Robot has failed at removing a block
initialise()

Note

User Customisable Callback

Subclasses may override this method to perform any necessary initialising/clearing/resetting of variables when when preparing to enter this behaviour if it was not previously RUNNING. i.e. Expect this to trigger more than once!

setup()

Note

User Customisable Callback

Subclasses may override this method for any one-off delayed construction & validation that is necessary prior to ticking the tree. Such construction is best done here rather than in __init__ so that trees can be instantiated on the fly for easy rendering to dot graphs without imposing runtime requirements (e.g. establishing a middleware connection to a sensor or a driver to a serial port).

Equally as important, executing methods which validate the configuration of behaviours will increase confidence that your tree will successfully tick without logical software errors before actually ticking. This is useful both before a tree’s first tick and immediately after any modifications to a tree has been made between ticks.

Tip

Faults are notified to the user of the behaviour via exceptions. Choice of exception to use is left to the user.

Warning

The kwargs argument is for distributing objects at runtime to behaviours before ticking. For example, a simulator instance with which behaviours can interact with the simulator’s python api, a ros2 node for setting up communications. Use sparingly, as this is not proof against keyword conflicts amongst disparate libraries of behaviours.

Args:
**kwargs (dict): distribute arguments to this
behaviour and in turn, all of it’s children
Raises:
Exception: if this behaviour has a fault in construction or configuration

See also

py_trees.behaviour.Behaviour.shutdown()

terminate(new_status)

Note

User Customisable Callback

Subclasses may override this method to clean up. It will be triggered when a behaviour either finishes execution (switching from RUNNING to FAILURE || SUCCESS) or it got interrupted by a higher priority branch (switching to INVALID). Remember that the initialise() method will handle resetting of variables before re-entry, so this method is about disabling resources until this behaviour’s next tick. This could be a indeterminably long time. e.g.

  • cancel an external action that got started
  • shut down any tempoarary communication handles
Args:
new_status (Status): the behaviour is transitioning to this new status

Warning

Do not set self.status = new_status here, that is automatically handled by the stop() method. Use the argument purely for introspection purposes (e.g. comparing the current state in self.status with the state it will transition to in new_status.

update()

Note

User Customisable Callback

Returns:
Status: the behaviour’s new status Status

Subclasses may override this method to perform any logic required to arrive at a decision on the behaviour’s new status. It is the primary worker function called on by the tick() mechanism.

Tip

This method should be almost instantaneous and non-blocking

components.robot.behaviors.motion_planning_behaviors.create_root(robot, robot_communicator, simulator_communicator, set_variables=False)

Create the behavior tree made up of the following behaviors:

NavigateToPoint, RemoveBlock, NavigateToPoint, PlaceBlock

Parameters:
  • robot_communicator – Object to send messages to structure
  • simulator_communicator – Object to send messages to simulator
  • set_variables – Used for testing purposes, can set blackboard variables to test with
Returns:

components.robot.behaviors.motion_planning_behaviors.get_motion_planning_behaviors_tree(robot_communicator, simulator_communicator, robot)
Parameters:
  • robot_communicator – Object to send messages to structure
  • simulator_communicator – Object to send messages to simulator
Returns:

components.robot.behaviors.motion_planning_behaviors.get_move_to_point_tree(robot_communicator, simulator_communicator, robot)
Parameters:
  • robot_communicator – Object to send messages to structure
  • simulator_communicator – Object to send messages to simulator
Returns:

components.robot.behaviors.motion_planning_behaviors.get_path_to_point(robot, destination, simulator_communicator, old_path=None)

Returns a path to the specified point

Parameters:
  • robot – Robot object
  • destination – Tuple consisting of 3d location and face to reach
  • simulator_communicator – Object to send messages to simulator
Returns:

components.robot.behaviors.motion_planning_behaviors.ik_solver(pipe_connection, robot, simulator_communicator, percentage_done=0)

Action used to solve for inverse kinematics

Parameters:
  • pipe_connection – Process connection to receive messages from parent process
  • robot – Robot object
  • simulator_communicator – Object to send messages to simulator
  • percentage_done – Percentage of ik solved
Returns:

components.robot.behaviors.motion_planning_behaviors.main()
components.robot.behaviors.motion_planning_behaviors.place_block(robot, simulator_communicator, location_to_set_block, block)

Action used to place a block on the structure at the specified location

Parameters:
  • robot – Robot object
  • simulator_communicator – Object to send messages to simulator
  • location_to_set_block – Tuple denoting location and orientation to place block
Returns:

components.robot.behaviors.motion_planning_behaviors.remove_block(robot, block_to_pick_up, simulator_communicator)

Action used to remove a block from the structure at the specified location

Parameters:
  • robot – Robot object
  • block_to_pick_up – Block object
  • simulator_communicator – Object to send messages to simulator
Returns:

components.robot.behaviors.move_blocks module

class components.robot.behaviors.move_blocks.Build(name, status_identifier, robot_communicator, simulator_communicator, navigation_first_key='navigation/point_to_reach', place_block_key='place_block/location_to_place_block', navigation_second_key='navigation/point_to_reach_2', remove_block_key='remove_block/block_to_remove', blocks_to_move_key='blocks_to_move', robot_state='robot_status', block_placed_state='block_has_been_placed')

Bases: components.robot.behaviors.move_blocks.MoveBlocks

class components.robot.behaviors.move_blocks.FerryBlocks(name, status_identifier, robot_communicator, simulator_communicator, navigation_first_key='navigation/point_to_reach', place_block_key='place_block/location_to_place_block', navigation_second_key='navigation/point_to_reach_2', remove_block_key='remove_block/block_to_remove', blocks_to_move_key='blocks_to_move', robot_state='robot_status', block_placed_state='block_has_been_placed')

Bases: components.robot.behaviors.move_blocks.MoveBlocks

class components.robot.behaviors.move_blocks.MoveBlocks(name, status_identifier, robot_communicator, simulator_communicator, navigation_first_key='navigation/point_to_reach', place_block_key='place_block/location_to_place_block', navigation_second_key='navigation/point_to_reach_2', remove_block_key='remove_block/block_to_remove', blocks_to_move_key='blocks_to_move', robot_state='robot_status', block_placed_state='block_has_been_placed')

Bases: py_trees.behaviour.Behaviour

initialise()

Note

User Customisable Callback

Subclasses may override this method to perform any necessary initialising/clearing/resetting of variables when when preparing to enter this behaviour if it was not previously RUNNING. i.e. Expect this to trigger more than once!

update()

Note

User Customisable Callback

Returns:
Status: the behaviour’s new status Status

Subclasses may override this method to perform any logic required to arrive at a decision on the behaviour’s new status. It is the primary worker function called on by the tick() mechanism.

Tip

This method should be almost instantaneous and non-blocking

components.robot.behaviors.move_blocks.create_move_blocks_root(robot_communicator, robot, simulator_communicator=None, ferry=True)
components.robot.behaviors.move_blocks.main()

Entry point for the demo script.

components.robot.behaviors.move_robot module

class components.robot.behaviors.move_robot.MoveToNewLocation(name, status_identifier, robot_communicator, navigation_first_key='navigation/point_to_reach', location_to_move_to_key='location_to_move_to', robot_state='robot_status', block_placed_state='block_has_been_placed', destination_reached='point_to_reach')

Bases: py_trees.behaviour.Behaviour

initialise()

Note

User Customisable Callback

Subclasses may override this method to perform any necessary initialising/clearing/resetting of variables when when preparing to enter this behaviour if it was not previously RUNNING. i.e. Expect this to trigger more than once!

update()

Note

User Customisable Callback

Returns:
Status: the behaviour’s new status Status

Subclasses may override this method to perform any logic required to arrive at a decision on the behaviour’s new status. It is the primary worker function called on by the tick() mechanism.

Tip

This method should be almost instantaneous and non-blocking

components.robot.behaviors.move_robot.create_move_robot_root(robot_communicator, simulator_communicator, robot)
components.robot.behaviors.move_robot.main()

components.robot.behaviors.update_state module

class components.robot.behaviors.update_state.UpdateState(name, status_identifier, robot_communicator, navigation_first_key='navigation/point_to_reach', place_block_key='place_block/location_to_place_block', navigation_second_key='navigation/point_to_reach_2', remove_block_key='remove_block/block_to_remove', blocks_to_move_key='blocks_to_move', robot_state='robot_status', block_placed_state='block_has_been_placed', location_to_move_to_key='location_to_move_to', destination_reached='point_to_reach')

Bases: py_trees.behaviour.Behaviour

handle_build_message(update)
handle_ferry_message(update)
handle_move_message(update)
handle_wait_message(update)
initialise()

Note

User Customisable Callback

Subclasses may override this method to perform any necessary initialising/clearing/resetting of variables when when preparing to enter this behaviour if it was not previously RUNNING. i.e. Expect this to trigger more than once!

update()

Note

User Customisable Callback

Returns:
Status: the behaviour’s new status Status

Subclasses may override this method to perform any logic required to arrive at a decision on the behaviour’s new status. It is the primary worker function called on by the tick() mechanism.

Tip

This method should be almost instantaneous and non-blocking

components.robot.behaviors.update_state.create_update_behavior_root(robot_communicator)
components.robot.behaviors.update_state.main()

Entry point for the demo script.

components.robot.behaviors.wait module

class components.robot.behaviors.wait.Wait(name, status_identifier, robot_communicator, robot_state='robot_status')

Bases: py_trees.behaviour.Behaviour

initialise()

Note

User Customisable Callback

Subclasses may override this method to perform any necessary initialising/clearing/resetting of variables when when preparing to enter this behaviour if it was not previously RUNNING. i.e. Expect this to trigger more than once!

update()

Note

User Customisable Callback

Returns:
Status: the behaviour’s new status Status

Subclasses may override this method to perform any logic required to arrive at a decision on the behaviour’s new status. It is the primary worker function called on by the tick() mechanism.

Tip

This method should be almost instantaneous and non-blocking

components.robot.behaviors.wait.create__waiting_root(robot_communicator)
components.robot.behaviors.wait.main()

Module contents