Module API¶
py_trees_ros¶
ROS extensions, behaviours and utilities for py_trees.
py_trees_ros.actions¶
Behaviours for ROS actions.
-
class
py_trees_ros.actions.
ActionClient
(action_type, action_name, action_goal, name=<Name.AUTO_GENERATED: 'AUTO_GENERATED'>, generate_feedback_message=None)[source]¶ Bases:
py_trees.behaviour.Behaviour
A generic action client interface. This simply sends a pre-configured goal to the action client.
Parameters: - action_type (
any
) – spec type for the action (e.g. move_base_msgs.msg.MoveBaseAction) - action_name (
str
) – where you can find the action topics & services (e.g. “bob/move_base”) - action_goal (
any
) – pre-configured action goal (e.g. move_base_msgs.action.MoveBaseGoal()) - name (
str
, optional) – name of the behaviour defaults to lowercase class name - generate_feedback_message (
func
, optional) – formatter for feedback messages, takes action_type.Feedback messages and returns strings, defaults to None
-
goal_response_callback
(future)[source]¶ Handle goal response, proceed to listen for the result if accepted.
-
send_goal_request
()[source]¶ Send the goal and get a future back, but don’t do any spinning here to await the future result.
Returns: rclpy.task.Future
-
setup
(**kwargs)[source]¶ Setup the action client services and subscribers.
Parameters: **kwargs (
dict
) – distribute arguments to this behaviour and in turn, all of it’s childrenRaises: KeyError
– if a ros2 node isn’t passed under the key ‘node’ in kwargsTimedOutError
– if the action server could not be found
- action_type (
py_trees_ros.battery¶
Getting the most out of your battery.
-
class
py_trees_ros.battery.
ToBlackboard
(name, topic_name='/battery/state', threshold=30.0)[source]¶ Bases:
py_trees_ros.subscribers.ToBlackboard
Subscribes to the battery message and writes battery data to the blackboard. Also adds a warning flag to the blackboard if the battery is low - note that it does some buffering against ping-pong problems so the warning doesn’t trigger on/off rapidly when close to the threshold.
When ticking, updates with
RUNNING
if it got no data,SUCCESS
otherwise.- Blackboard Variables:
- battery (
sensor_msgs.msg.BatteryState
)[w]: the raw battery message - battery_low_warning (
bool
)[w]: False if battery is ok, True if critically low
- battery (
Parameters:
py_trees_ros.blackboard¶
This module provides the py_trees_ros.blackboard.Exchange
class,
a ROS wrapper around a
Blackboard that permits
introspection of either the entire board or a window onto a smaller part
of the board over a ROS API via the py-trees-blackboard-watcher
command line utility.
-
class
py_trees_ros.blackboard.
BlackboardView
(node, topic_name, attrs)[source]¶ Bases:
object
Utility class that enables tracking and publishing of relevant parts of the blackboard for a user. This is used by the
Exchange
operator.Parameters: - topic_name (
str
) – name of the topic for the publisher - attrs (
???
) –
- topic_name (
-
class
py_trees_ros.blackboard.
BlackboardWatcher
(callback=<function BlackboardWatcher.<lambda>>, namespace_hint=None)[source]¶ Bases:
object
The blackboard watcher sits on the other side of the exchange and is a useful mechanism from which to pull all or part of the blackboard contents. This is extremely useful for logging, but also for introspecting in the runtime for various uses (e.g. reporting out on the current state to a fleet server).
See also
-
close_connection
()[source]¶ Raises: NotReadyError
– if setup not executed or it hitherto failedTimedOutError
– if the services could not be reached
-
open_connection
(variables, callback=None, executor=None)[source]¶ First calls the exchange to get details on the connect the watcher is required to open and then initiates that tunnel. Note that this does some spinning waiting for the service call, so if the executor must be shared with other nodes (e.g. for testing) make sure you pass in your own executor.
Parameters: - variables (
[str]
) – list of variables to listen for - callback (func, optional) – method with a std_msgs/String argument, defaults to
blackboard_contents_callback()
in this class - executor (
Executor
) –
Raises: NotReadyError
– if setup not executed or it hitherto failedServiceError
– if the service failed to respondTimedOutError
– if the services could not be reached
- variables (
-
request_list_variables
()[source]¶ Request of the blackboard a list of it’s variables.
Returns: Future
-
-
class
py_trees_ros.blackboard.
Exchange
[source]¶ Bases:
object
Establishes ros communications around a
Blackboard
that enable users to introspect or watch relevant parts of the blackboard.- ROS Publishers:
- ~/blackboard (
std_msgs.msg.String
)- streams (string form) the contents of the entire blackboard as it updates
- ~/blackboard (
- ROS Services:
- ~/get_blackboard_variables (
py_trees_msgs.srv.GetBlackboardVariables
)- list all the blackboard variable names (not values)
- ~/open_blackboard_watcher (
py_trees_msgs.srv.OpenBlackboardWatcher
)- request a publisher to stream a part of the blackboard contents
- ~/close_blackboard_watcher (
py_trees_msgs.srv.CloseBlackboardWatcher
)- close a previously opened watcher
- ~/get_blackboard_variables (
Watching could be more simply enabled by just providing a get style service on a particular variable(s), however that would introduce an asynchronous interrupt on the library’s usage and subsequently, locking. Instead, a watcher service requests for a stream, i.e. a publisher to be created for private use that streams only a subsection of the blackboard to the user. Additional services are provided for closing the stream and listing the variables on the blackboard.
See also
BehaviourTree
(in which it is used) and py-trees-blackboard-watcher (working with the watchers).-
publish_blackboard
(unused_tree=None)[source]¶ Lazy string publishing of the blackboard (the contents of the blackboard can be of many and varied types, so string form is the only way to transmit this across a ros message) on the ~blackboard topic.
Typically you would call this from a tree custodian (e.g.
py_trees_ros.trees.BehaviourTree
) after each and every tick.Note
Lazy: it will only do the relevant string processing if there are subscribers present.
Parameters: unused_tree ( any
) – if used as a post_tick_handler, needs the argument, but nonetheless, gets unused
-
setup
(node)[source]¶ This is where the ros initialisation of publishers and services happens. It is kept outside of the constructor for the same reasons that the familiar py_trees
setup()
method has - to enable construction of behaviours and trees offline (away from their execution environment) so that dot graphs and other visualisations of the tree can be created.Parameters: node ( Node
) – node to hook ros communications onExamples
It is expected that users will use this in their own customised tree custodian:
class MyTreeManager(py_trees.trees.BehaviourTree): def __init__(self): pass def setup(self, timeout): super(MyTreeManager, self).setup(timeout) self.exchange = py_trees_ros.blackboard.Exchange() self.exchange.setup(timeout)
See also
This method is called in the way illustrated above in
BehaviourTree
.
py_trees_ros.conversions¶
Converter methods for transferring information back and forth between py_trees objects and ros messages.
-
py_trees_ros.conversions.
behaviour_to_msg
(behaviour)[source]¶ Convert a behaviour to a message.
Parameters: behaviour ( py_trees.behaviour.Behaviour
) – behaviour to convertReturns: a ros message representation of a behaviour Return type: py_trees_ros_interfaces.msg.Behaviour
-
py_trees_ros.conversions.
behaviour_type_to_msg_constant
(behaviour)[source]¶ Convert a behaviour class type to a message constant.
Parameters: behaviour ( py_trees.behaviour.Behaviour
) – investigate the type of this behaviourReturns: from the type constants in py_trees_ros_interfaces.msg.Behaviour
Return type: uint8
-
py_trees_ros.conversions.
blackbox_enum_to_msg_constant
(blackbox_level)[source]¶ Convert a blackbox level enum to a message constant.
Parameters: blackbox_level ( BlackboxLevel
) – blackbox level of a behaviourReturns: from the type constants in py_trees_ros_interfaces.msg.Behaviour
Return type: uint8
-
py_trees_ros.conversions.
msg_constant_to_behaviour_type
(value)[source]¶ Convert one of the behaviour type constants in a
Behaviour
message to a type.Parameters: (obj (value) – int`: see the message definition for details Returns: a behaviour class type (e.g. py_trees.composites.Sequence
)Raises: TypeError
– if the message type is unrecognised
-
py_trees_ros.conversions.
msg_constant_to_blackbox_level_enum
(value)[source]¶ Convert one of the blackbox level constants in a
Behaviour
message to a py_trees status enum.Parameters: (obj (value) – int`: see the message definition for details Returns: a py_trees blackbox level Return type: py_trees.common.BlackBoxLevel
Raises: TypeError
– if the status type is unrecognised
-
py_trees_ros.conversions.
msg_constant_to_status_enum
(value)[source]¶ Convert one of the status constants in a
Behaviour
message to a py_trees status enum.Parameters: (obj (value) – int`: see the message definition for details Returns: a py_trees status Return type: Status
Raises: TypeError
– if the status type is unrecognised
-
py_trees_ros.conversions.
msg_to_behaviour
(msg)[source]¶ Convert behaviour message to a py_trees behaviour. This doesn’t completely recreate the original behaviour (doesn’t have any of the custom state), but allows the user to compose a tree that can be utilised for debugging or visualisation applications.
Parameters: msg ( py_trees_ros_interfaces.msg.Behaviour
) – a ros message representation of a behaviourReturns: converted, skeleton of the original behaviour Return type: py_trees.behaviour.Behaviour
-
py_trees_ros.conversions.
msg_to_uuid4
(msg)[source]¶ Convert a uuid4 python object to a ros unique identifier, UUID type.
Parameters: msg ( unique_identifier_msgs.msg.UUID
) – the ros message typeReturns: the behaviour’s uuid, python style Return type: uuid.UUID
-
py_trees_ros.conversions.
rclpy_duration_to_float
(duration)[source]¶ Convert a ros2 duration (seconds/nanoseconds) to a float.
Parameters: time ( rclpy.time.Duration
) – time to convertReturn type: float
-
py_trees_ros.conversions.
rclpy_time_to_float
(time)[source]¶ Convert a ros2 time (seconds/nanoseconds) to a float.
Parameters: time ( rclpy.time.Time
) – time to convertReturn type: float
-
py_trees_ros.conversions.
status_enum_to_msg_constant
(status)[source]¶ Convert a status to a message constant.
Parameters: status ( Status
) – status enum of a behaviourReturns: from the status constants in py_trees_ros_interfaces.msg.Behaviour
Return type: uint8
-
py_trees_ros.conversions.
uuid4_to_msg
(uuid4=UUID('f161ea5c-9a90-496d-af0c-d8417a509f23'))[source]¶ Convert a uuid4 python object to a ros unique identifier, UUID type.
Parameters: uuid4 ( uuid.UUID
) – unique identifier to convert, defaults to auto-generated uuid4Returns: the ros message type Return type: unique_identifier_msgs.msg.UUID
py_trees_ros.subscribers¶
ROS subscribers are asynchronous communication handles whilst py_trees are by their nature synchronous. They tick, pause, then tick again and provide an assumption that only one behaviour or function is running at any single moment. Firing off a subscriber callback in the middle of that synchronicity to write to a blackboard would break this assumption.
To get around that, subscriber behaviours run the ros callbacks in a background thread and constrain locking and a local cache inside the behaviour. Only in the update function is a cached variable unlocked and then permitted to be used or written to the blackboard.
-
class
py_trees_ros.subscribers.
CheckData
(name='Check Data', topic_name='/foo', topic_type=None, qos_profile=<Mock name='mock.qos.QoSProfile()' id='140624793538688'>, variable_name='bar', expected_value=None, fail_if_no_data=False, fail_if_bad_comparison=False, comparison_operator=<built-in function eq>, clearing_policy=<ClearingPolicy.ON_INITIALISE: 1>)[source]¶ Bases:
py_trees_ros.subscribers.Handler
Check a subscriber to see if it has received data.
It optionally checks whether that data, or part of it has a specific value.
Usage Patterns
Sequence Guard:
RUNNING
until there is a successful comparison- fail_if_no_data=False
- fail_if_bad_comparison=False
Selector Priority Chooser:
FAILURE
until there is a successful comparison- fail_if_no_data=True
- fail_if_bad_comparison=True
Parameters: - name (
str
) – name of the behaviour - topic_name (
str
) – name of the topic to connect to - topic_type (
any
) – class of the message type (e.g.std_msgs.msg.String
) - qos_profile (
bool
) – qos profile for the subscriber - variable_name (
str
) – name of the variable to check - expected_value (
any
) – expected value of the variable - fail_if_no_data (
bool
) –FAILURE
instead ofRUNNING
if there is no data yet - fail_if_bad_comparison (
bool
) –FAILURE
instead ofRUNNING
if comparison failed - comparison_operator (
func
) – one from the python operator module - clearing_policy (
ClearingPolicy
) – when to clear the data
Tip
Prefer
ToBlackboard
and the various blackboard checking behaviours instead. It will provide you with better introspection capability and less complex behaviour construction to manage.
-
class
py_trees_ros.subscribers.
EventToBlackboard
(name='Event to Blackboard', topic_name='/event', qos_profile=<Mock name='mock.qos.QoSProfile()' id='140624793538688'>, variable_name='event')[source]¶ Bases:
py_trees_ros.subscribers.Handler
Listen for events (
std_msgs.msg.Empty
) on a subscriber and writes the result to the blackboard.This will write True if at least one message was received, False otherwise to a bool. This can then be consumed by the tree’s tick. No need to clean up, it will write anew on the next tick.
Tip
Ideally you need this at the very highest part of the tree so that it gets triggered every time - once this happens, then the rest of the behaviour tree can utilise the variables.
Parameters:
-
class
py_trees_ros.subscribers.
Handler
(name='Subscriber Handler', topic_name='/foo', topic_type=None, qos_profile=<Mock name='mock.qos.qos_profile_default' id='140624793443408'>, clearing_policy=<ClearingPolicy.ON_INITIALISE: 1>)[source]¶ Bases:
py_trees.behaviour.Behaviour
Warning
Do not use - it will always return
INVALID
. Subclass it to create a functional behaviour.Not intended for direct use, as this just absorbs the mechanics of setting up a subscriber for inheritance by user-defined behaviour classes. There are several options for the mechanism of clearing the data so that a new result can be processed.
Always Look for New Data
This will clear any currently stored data upon entry into the behaviour (i.e. when
initialise()
is called). This is useful for a behaviour in a sequence that is looking to start fresh as it is about to tick and be in aRUNNING
state until new data arrives.Look for New Data only after SUCCESS
This will clear any currently stored data as soon as the behaviour returns
SUCCESS
. This is useful for catching new triggers/events from things like buttons where you don’t want to miss things even though you may not actually be ticking.Use the Latest Data
Even if this data was received before entry into the behaviour. In this case
initialise()
does not do anything with the currently stored data. Useful as a blocking behaviour to wait on some some topic having been initialised with some data (e.g. CameraInfo).Parameters: - name (
str
) – name of the behaviour - topic_name (
str
) – name of the topic to connect to - topic_type (
any
) – class of the message type (e.g.std_msgs.msg.String
) - qos_profile (
bool
) – qos profile for the subscriber - clearing_policy (
ClearingPolicy
) – when to clear the data
-
initialise
()[source]¶ If the clearing policy is set to
ON_INITIALISE
it will clear the internally saved message, otherwise it does nothing.
- name (
-
class
py_trees_ros.subscribers.
ToBlackboard
(name='ToBlackboard', topic_name='chatter', topic_type=None, qos_profile=<Mock name='mock.qos.QoSProfile()' id='140624793538688'>, blackboard_variables={'chatter': None}, initialise_variables={}, clearing_policy=<ClearingPolicy.ON_INITIALISE: 1>)[source]¶ Bases:
py_trees_ros.subscribers.Handler
Saves the latest message to the blackboard and immediately returns success. If no data has yet been received, this behaviour blocks (i.e. returns RUNNING).
Typically this will save the entire message, however sub fields can be designated, in which case they will write to the specified keys.
Parameters: - name (
str
) – name of the behaviour - topic_name (
str
) – name of the topic to connect to - topic_type (
any
) – class of the message type (e.g.std_msgs.msg.String
) - qos_profile (
bool
) – qos profile for the subscriber - blackboard_variables (
dict
) – blackboard variable string or dict {names (keys) - message subfields (values)}, use a value of None to indicate the entire message - initialise_variables (
bool
) – initialise the blackboard variables to some defaults - clearing_policy (
ClearingPolicy
) – when to clear the data
Examples
To capture an entire message:
chatter_to_blackboard = ToBlackboard(topic_name="chatter", topic_type=std_msgs.msg.String, blackboard_variables = {'chatter': None} )
or to get rid of the annoying sub-data field in std_msgs/String:
chatter_to_blackboard = ToBlackboard(topic_name="chatter", topic_type=std_msgs.msg.String, blackboard_variables = {'chatter': 'data'} )
combinations of multiple entities inside the message can also be saved:
blackboard_variables={"pose_with_covariance_stamped": None, "pose": "pose.pose"}
- name (
-
class
py_trees_ros.subscribers.
WaitForData
(name='Wait For Data', topic_name='chatter', topic_type=None, qos_profile=<Mock name='mock.qos.QoSProfile()' id='140624793538688'>, clearing_policy=<ClearingPolicy.ON_INITIALISE: 1>)[source]¶ Bases:
py_trees_ros.subscribers.Handler
Waits for a subscriber’s callback to be triggered. This doesn’t care about the actual data, just whether it arrived or not, so is useful for catching triggers (std_msgs/Empty messages) or blocking (in the behaviour sense) until some data has arrived (e.g. camera configuration). There are two use cases:
Usage Patterns
Got Something, Sometime
- clearing_policy ==
NEVER
Don’t care when data arrived, just that it arrived. This could be for something like a map topic, or a configuration that you need to block. Once it returns
SUCCESS
, it will always returnSUCCESS
.Wating for the Next Thing, Starting From Now
- clearing_policy ==
ON_INTIALISE
Useful as a gaurd at the start of a sequence, that is waiting for an event to trigger after the sequence has started (i.e. been initialised).
Wating for the Next Thing, Starting from the Last
- clearing_policy ==
ON_SUCCESS
Useful as a guard watching for an event that could have come in anytime, but for which we do with to reset (and subsequently look for the next event). e.g. button events.
Parameters: - name (
str
) – name of the behaviour - topic_name (
str
) – name of the topic to connect to - topic_type (
any
) – class of the message type (e.g.std_msgs.msg.String
) - qos_profile (
bool
) – qos profile for the subscriber - clearing_policy (
ClearingPolicy
) – when to clear the data
- clearing_policy ==
py_trees_ros.trees¶
The py_trees_ros.trees.BehaviourTree
class
extends the core py_trees.trees.BehaviourTree
class
with a ROS publisher that publishes the initial and updated snapshots of
the tree whenever the tree changes.
‘Change’ is defined by deletion or insertion of behaviours into the tree or the status of any behaviour in the tree changing from tick to tick.
-
class
py_trees_ros.trees.
BehaviourTree
(root, unicode_tree_debug=False)[source]¶ Bases:
py_trees.trees.BehaviourTree
Extend the
py_trees.trees.BehaviourTree
class with a few bells and whistles for ROS:- ros publishers that serialises a snapshot of the tree for viewing/logging
- a blackboard exchange with introspection and watcher services
- ROS Publishers:
- ~/snapshots (
py_trees_msgs.msg.BehaviourTree
)
- ~/snapshots (
See also
It also exposes publishers and services from the blackboard exchange in it’s private namespace. Refer to
Exchange
for details.Parameters: Raises: AssertionError
– if incoming root variable is not the correct type-
setup
(timeout=<Duration.INFINITE: inf>)[source]¶ Setup the publishers, exechange and add ros-relevant pre/post tick handlers to the tree. Ultimately relays this call down to all the behaviours in the tree.
Parameters: timeout (
float
) – time (s) to wait (use common.Duration.INFINITE to block indefinitely)Raises: rclpy.exceptions.NotInitializedException
– rclpy not yet initialisedException
– be ready to catch if any of the behaviours raise an exception
-
tick_tock
(period_ms, number_of_iterations=-1, pre_tick_handler=None, post_tick_handler=None)[source]¶ Tick continuously at the period specified.
This is a re-implementation of the
tick_tock()
tick_tock that takes advantage of the rclpy timers so callbacks are interleaved inbetween rclpy callbacks (keeps everything synchronous so no need for locks).Parameters:
-
class
py_trees_ros.trees.
Watcher
(namespace_hint, mode=<WatcherMode.ASCII_SNAPSHOT: 'ASCII_SNAPSHOT'>)[source]¶ Bases:
object
The tree watcher sits on the other side of a running
BehaviourTree
and is a useful mechanism for quick introspection of it’s current state.Parameters: - namespace_hint (
str
) – (optionally) used to locate the blackboard if there exists more than one - mode (
WatcherMode
) – viewing mode for the watcher
See also
- namespace_hint (
-
class
py_trees_ros.trees.
WatcherMode
[source]¶ Bases:
enum.Enum
An enumerator specifying the view mode for the watcher
-
ASCII_SNAPSHOT
= 'ASCII_SNAPSHOT'¶ Print an ascii art view of the behaviour tree’s current state after the last tick
-
ASCII_TREE
= 'ASCII_TREE'¶ Print an ascii art representation of the static tree (sans visited path/status/feedback messages).
-
DOT_TREE
= 'DOT_TREE'¶ Render with the dot graph representation of the static tree (using an application or text to console).
-
py_trees_ros.utilities¶
Assorted utility functions.
-
class
py_trees_ros.utilities.
Publishers
(node, publisher_details, introspection_topic_name='publishers')[source]¶ Bases:
object
Utility class that groups the publishers together in one convenient structure.
Parameters: (obj (publisher_details) – tuple): list of (str, str, bool, int) tuples representing (unique_name, topic_name, publisher_type, latched) specifications for creating publishers Examples
Convert the incoming list of specifications into proper variables of this class.
publishers = py_trees.utilities.Publishers( [ ('foo', ~/foo', std_msgs.String, True, 5), ('bar', /foo/bar', std_msgs.String, False, 5), ('foobar', '/foo/bar', std_msgs.String, False, 5), ] )
-
class
py_trees_ros.utilities.
Subscribers
(node, subscriber_details, introspection_topic_name='subscribers')[source]¶ Bases:
object
Utility class that groups the publishers together in one convenient structure.
Parameters: (obj (subscriber_details) – tuple): list of (str, str, bool, func) tuples representing (unique_name, topic_name, subscriber_type, latched, callback) specifications for creating subscribers Examples
Convert the incoming list of specifications into proper variables of this class.
subscribers = py_trees.utilities.Subscribers( [ ('foo', ~/foo', std_msgs.String, True, foo), ('bar', /foo/bar', std_msgs.String, False, self.foo), ('foobar', '/foo/bar', std_msgs.String, False, foo.bar), ] )
-
py_trees_ros.utilities.
basename
(name)[source]¶ Generate the basename from a ros name.
Parameters: name ( str
) – ros nameReturns: name stripped up until the last slash or tilde character. Return type: str
Examples
basename("~dude") # 'dude' basename("/gang/dude") # 'dude'
-
py_trees_ros.utilities.
create_anonymous_node_name
(node_name='node')[source]¶ Creates an anonoymous node name by adding a suffix created from a monotonic timestamp, sans the decimal.
Returns: the unique, anonymous node name Return type: str
-
py_trees_ros.utilities.
find_service
(node, service_type, namespace=None)[source]¶ Discover a service of the specified type and if necessary, under the specified namespace.
Parameters: Returns: fully expanded the service name
Return type: Raises: NotFoundError
– if no services were foundMultipleFoundError
– if multiple services were found
-
py_trees_ros.utilities.
find_topic
(node, topic_type, namespace=None)[source]¶ Discover a topic of the specified type and if necessary, under the specified namespace.
Parameters: Returns: fully expanded the service name
Return type: Raises: NotFoundError
– if no services were foundMultipleFoundError
– if multiple services were found
-
py_trees_ros.utilities.
get_py_trees_home
()[source]¶ Find the default home directory used for logging, bagging and other esoterica.
-
py_trees_ros.utilities.
qos_profile_latched_topic
()[source]¶ Convenience retrieval for a latched topic (publisher / subscriber)
-
py_trees_ros.utilities.
resolve_name
(node, name)[source]¶ Convenience function for getting the resolved name (similar to ‘publisher.resolved_name’ in ROS1).
Parameters: - node (
rclpy.node.Node
) – the node, namespace it should be relevant to - (obj (name) – str): topic or service name
Note
This entirely depends on the user providing the relevant node, name pair.
- node (
py_trees_ros.visitors¶
ROS Visitors are entities that can be passed to a ROS tree implementation
(e.g. BehaviourTree
) and used to either visit
each and every behaviour in the tree, or visit behaviours as the tree is
traversed in an executing tick. At each behaviour, the visitor
runs its own method on the behaviour to do as it wishes - logging, introspecting).
Warning
Visitors should not modify the behaviours they visit.
See also
The base interface and core visitors in py_trees.visitors
-
class
py_trees_ros.visitors.
TreeToMsgVisitor
[source]¶ Bases:
py_trees.visitors.VisitorBase
Visits the entire tree and gathers all behaviours as messages for the tree logging publishers.
Variables: tree ( py_trees_msgs.msg.BehaviourTree
) – tree representation in message form
py_trees_ros.programs¶
Entry points to the programs (tools and utilities).
py_trees_ros.programs.blackboard_watcher¶
Open up a window onto the blackboard!
Examples:
$ py-trees-blackboard-watcher
$ py-trees-blackboard-watcher --list-variables
$ py-trees-blackboard-watcher access_point odom/pose/pose/position
usage: py-trees-blackboard-watcher [-h] [-l] [-n [NAMESPACE]] ...
Positional Arguments¶
variables | space separated list of blackboard variables to watch Default: [] |
Named Arguments¶
-l, --list-variables | |
list the blackboard variables | |
-n, --namespace | |
namespace of blackboard services (if there should be more than one blackboard) |
Example interaction with the services of an py_trees_ros.blackboard.Exchange
:
py_trees_ros.programs.tree_watcher¶
Open up a window onto the behaviour tree!
Print static or dynamic (snapshot) unicode art views of the tree on the console or render a dot graph (static view only). Use the namespace argument to select from trees when there are multiple available.
Examples:
$ py-trees-tree-watcher
$ py-trees-tree-watcher --unicode-tree
$ py-trees-tree-watcher --dot-tree
$ py-trees-tree-watcher --namespace=foo --unicode-tree
usage: py-trees-tree-watcher [-h] [-n [NAMESPACE]] [-s | -t | -d]
Named Arguments¶
-n, --namespace | |
namespace of pytree communications (if there should be more than one tree active) | |
-s, --snapshot | print a live snapshot of the tree state as unicode art on your console |
-t, --tree | print the tree structure as unicode art on your console |
-d, --dot-tree | render the tree structure as a dot graph |
Command line utility to interact with a running
BehaviourTree
instance. Print the tree structure
or a live snapshot of the tree state as unicode art on your console,
view tick statistics as a stream or display the tree as a dot graph.