Task Trees API Reference
task_trees.task_trees_manager module
- class task_trees.task_trees_manager.BasicTask(param=None)
Bases:
object
It defines the essential parameters for the lifecycle management by the TaskTreesManager :meta private:
- cancel(wait=True) bool
cancel the task
- Returns:
True if the task has been submitted and the cancellation is sucessful.
- Return type:
bool
- get_commander_feedback() str
return the final feedback from the commander for error checking :return: the final message :rtype: str
- get_param()
returns the param of the task
- Returns:
the param of the task
- Return type:
arbitrary, dependent on the subclass definition
- get_state() TaskStates
return the state of the task :return: the current state of the task :rtype: TaskStates
- get_time_since_submit() float
return the time lapse since submission :return: the time lapse since submission, or -1 if the task has not been submitted :rtype: float
- update_state(new_state: TaskStates)
update the state (thread-safe)
- Parameters:
new_state (TaskStates) – the new state
- wait_for_completion(until_states: list = None)
a blocking function that returns when the task has entered into one of the :param:until_states
- Parameters:
until_states (list, optional) – _description_, defaults to None
- Returns:
_description_
- Return type:
_type_
- wait_for_working()
a blocking function that returns when the task has entered into WORKING state or GUARDED_ABORTED state
- class task_trees.task_trees_manager.BasicTaskTreesManager
Bases:
object
subclass the BasicTaskTreesManager to develop a project specific task trees manager and its behaviour trees.
- display_tree()
renders the behaviour tree of this task trees manager as a dot file
- get_submitted_task() BasicTask
Return the submitted task :return: The submitted task, or None :rtype: BasicTask
- shutdown()
Shutdown the task trees manager immediately
- spin()
- stop(*args, **kwargs)
- class task_trees.task_trees_manager.GuardedTaskTreesManager(arm_commander: arm_commander.commander_moveit.GeneralCommander, guard_reset=True)
Bases:
TaskTreesManager
subclass the TaskTreesManager to develop application specific behaviour trees that are structures to support the plug-in of tasks, timeout, and on-shot initialization branches
- is_global_guard_activated()
Returns True if the global guard has been activated
- is_task_guard_activated()
Returns True if the task subtree guard has been activated
- reset_guard()
Reset the guard that has been switched on
- set_global_guard_condition_fn(global_guard_condition_fn)
Set the function that returns the global guard condition
- Parameters:
global_guard_condition_fn – a function definition that returns a bool
- set_task_guard_condition_fn(task_guard_condition_fn)
Set the function that returns the task subtree guard condition
- Parameters:
task_guard_condition_fn – a function definition that returns a bool
- class task_trees.task_trees_manager.TaskTreesManager(arm_commander)
Bases:
BasicTaskTreesManager
subclass the TaskTreesManager to develop application specific behaviour trees that are structures to support the plug-in of tasks, timeout, and on-shot initialization branches
- display_tree(branch=None, target_directory=None)
Save a graphical representation of the given branch of a behaviour tree to the target directory
- Parameters:
branch – the branch to be drawn, defaults to None which means the whole behaviour tree
target_directory – the output directory, defaults to None
- shutdown()
Shutdown the task trees manager, including the behaviour tree and then terminate the program
task_trees.behaviours_move module
task_trees.behaviours_move_sense module
task_trees.behaviours_base module
- class task_trees.behaviours_base.ConditionalBehaviour(*args: Any, **kwargs: Any)
Bases:
Behaviour
The base class that extends PyTrees Behaviour with support for the conditional behaviour model. The model significantly improves the reusability of behaviours and the readability of their roles in a behaviour tree. This class should not be instantiated
- class ConditionSpec(fn, inverted, kwargs)
Bases:
tuple
- fn
Alias for field number 0
- inverted
Alias for field number 1
- kwargs
Alias for field number 2
- class Policies(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
- FAILURE_IF_FALSE_POLICY = 1
- SUCCESS_IF_FALSE_POLICY = 0
- update() py_trees.common.Status
- Specialized update function for ConditionalBehaviour. Maybe overrided by subclasses and in such case checks the condition
using the function _is_condition_satisfied()
- Returns:
the new PyTrees status
- Return type:
Status
- update_if_true() py_trees.common.Status
A placeholder function that should be overridden in a subclass :return: The new PyTrees status :rtype: Status
- class task_trees.behaviours_base.ConditionalCommanderBehaviour(*args: Any, **kwargs: Any)
Bases:
ConditionalBehaviour
The base Behaviour class supporting the implementation of Behaviour subclasses that uses the General Commander, and it has included logic for managing the states of the General Commander
- initialise()
- terminate(new_status)
- tidy_up()
- update()
- Specialized update function for ConditionalBehaviour. Maybe overrided by subclasses and in such case checks the condition
using the function _is_condition_satisfied()
- Returns:
the new PyTrees status
- Return type:
Status
- update_when_busy()
- update_when_ready()
- class task_trees.behaviours_base.HandleTaskCancelled(*args: Any, **kwargs: Any)
Bases:
Behaviour
A utility Behaviour that handles task cancelled placed after the EternalGuard (with FailureIsSuccess)
- terminate(new_status)
- update()
- class task_trees.behaviours_base.HandleTaskFailure(*args: Any, **kwargs: Any)
Bases:
Behaviour
A utility Behaviour that handles task failure situation that has happened in a subclass of CommanderBehaviour or ConditionalCommanderBehaviour
- terminate(new_status)
- update()
- class task_trees.behaviours_base.Print(*args: Any, **kwargs: Any)
Bases:
Behaviour
a utility Behaviour used for tracing and debugging. It prints a string message from a constant or a function that returns a string and optionally the status of the subtree rooted at the parent of this behaviour.
- update()
- class task_trees.behaviours_base.PrintPose(*args: Any, **kwargs: Any)
Bases:
Behaviour
a utility Behaviour used for tracing and debugging. It prints the pose of the end-effector in the world frame and the joint values
- update()
- class task_trees.behaviours_base.PrintPosesInFrame(*args: Any, **kwargs: Any)
Bases:
PrintPose
A utility Behaviour used for tracing and debugging. It prints a string message from a constant or a function that returns a string and optionally the status of the subtree rooted at the parent of this behaviour.
- update()
- class task_trees.behaviours_base.SceneConditionalCommanderBehaviour(*args: Any, **kwargs: Any)
Bases:
ConditionalCommanderBehaviour
The base Behaviour class supporting the implementation of Behaviour subclasses that uses the General Commander and the Scene Configuration
- compute_physical_target(composite_target, logical_lookup_fn=None, default_target=None) list
- class task_trees.behaviours_base.SimAttachObject(*args: Any, **kwargs: Any)
Bases:
ConditionalCommanderBehaviour
This behaviour attachs a collision object to the end effector
- update_when_ready()
- class task_trees.behaviours_base.SimDetachObject(*args: Any, **kwargs: Any)
Bases:
ConditionalCommanderBehaviour
This behaviour detachs a collision object from the behaviour
- update_when_ready()
task_trees.task_scene module
- class task_trees.task_scene.FrameConfig(name, type, xyz, rpy, parent_frame)
Bases:
tuple
- name
Alias for field number 0
- parent_frame
Alias for field number 4
- rpy
Alias for field number 3
- type
Alias for field number 1
- xyz
Alias for field number 2
- class task_trees.task_scene.LinkConfig(name, type, model_file, dimensions, xyz, rpy, parent_frame)
Bases:
tuple
- dimensions
Alias for field number 3
- model_file
Alias for field number 2
- name
Alias for field number 0
- parent_frame
Alias for field number 6
- rpy
Alias for field number 5
- type
Alias for field number 1
- xyz
Alias for field number 4
- class task_trees.task_scene.Scene(scene_config_file: str = None)
Bases:
object
The base model provides mapping between physical/joint-space pose and various named/logical poses.
- exists_config(key: str) bool
returns True of the given config name exists :param key: The config name :type key: str :return: True if the given config name exists :rtype: bool
- get_frame_config_as_dict(frame_name: str) dict
return the frame configuration as a dict, or None if the scene not exists :param frame_name: name of the frame :type frame_name: str :return: the configuration of the frame type scene or None if not exists :rtype: dict
- get_link_of_frame(frame_name: str) LinkConfig
return the object configuration as ObjectConfig tuple, or None if the name not exists :param frame_name: name of the frame :type frame_name: str :return: the LinkConfig of the frame or None if not exists :rtype: LinkConfig
- get_link_of_scene(scene_name: str) LinkConfig
return the object configuration as ObjectConfig tuple, or None if the name not exists :param scene_name: name of the scene :type scene_name: str :return: the LinkConfig of the scene or None if not exists :rtype: LinkConfig
- get_named_poses_of_root_as_dict() dict
return the named poses defined in the scene configuration as a dict
- Returns:
dict containing key value pairs of named poses
- get_scene_config_as_dict(scene_name: str) dict
return the scene configuration as a dict, or None if the scene not exists :param scene_name: name of the object :type scene_name: str :return: the configuration of the scene as a dict or None if not exists :rtype: dict
- key_list_under_config_key(key: str) list
returns a list of keys specified under the config name or an empty list :param key: The config name :type key: str :return: a list of keys specified under the config name :rtype: list
- len_of_key_list_under_config_key(key: str) int
returns the length of the list under the config name :param key: The config name :type key: str :return: the length of the list the config name :rtype: int
- list_frame_names() list
return the list of frame type scene defined in the scene configuration :return: a list of frame names as strings :rtype: list
- list_scene_names() list
return the list of objects defined in the scene configuration :return: a list of object names as strings :rtype: list
- query_config(key: str, default=None)
returns the value of any named config given as a dot-separated path :param key: the dot-separated key, the root scene may have the “root” omitted :type key: str :param default: the default value if nothing is found in the key, defaults to None :type default: any :return: the value of the config :rtype: any