-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed the asset file loading issue for object mesh marker in scene_to…
…_rviz and add_object_to_scene in the arm_commander, both are accepting the same formats including absolute file path, relative package file path, and file, package, http uri. Added definition of custom reference frames under the branch "frames" and added _define_frames in the task trees manager. Added a demo program rviz_display for illustraing displaying markers in rviz. Added publishing period to persistent objects and pointcloud in rviz_tools.
- Loading branch information
andrewluiqut
committed
Apr 10, 2024
1 parent
a5dd6bf
commit fdb8167
Showing
11 changed files
with
452 additions
and
42 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright 2024 - Andrew Kwok Fai LUI, | ||
# Robotics and Autonomous Systems Group, REF, RI | ||
# and the Queensland University of Technology | ||
|
||
__author__ = 'Andrew Lui' | ||
__copyright__ = 'Copyright 2024' | ||
__license__ = 'GPL' | ||
__version__ = '1.0' | ||
__email__ = '[email protected]' | ||
__status__ = 'Development' | ||
|
||
import os, random | ||
import py_trees | ||
from py_trees.composites import Sequence, Parallel, Composite, Selector | ||
# robot control module | ||
from arm_commander.commander_moveit import GeneralCommander, logger | ||
from task_trees_manager_rviz import * | ||
|
||
if __name__=='__main__': | ||
try: | ||
arm_commander = GeneralCommander('panda_arm') | ||
the_task_manager = RVizTaskTreesManager(arm_commander) | ||
|
||
logger.info('rviz_display demo is running') | ||
the_task_manager.spin() | ||
except Exception as e: | ||
logger.exception(e) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
scene: | ||
named_poses: | ||
stow: [0.0, -1.244, 0.0, -2.949, 0.0, 1.704, 0.785] # from base | ||
home: [0.0, -0.785, 0.0, -2.36, 0.0, 1.57, 0.785] # from base | ||
positions: | ||
default_z: [null, null, 0.5] | ||
objects: | ||
teapot: | ||
type: object | ||
# model_file: file://localhost/home/qcr/arm_commander_ws/src/task_trees/demos/rviz_display/utah_teapot.stl | ||
model_file: package://task_trees/demos/rviz_display/utah_teapot.stl | ||
dimensions: [0.01, 0.01, 0.01] | ||
xyz: [0.4, 0.20, 0.00] | ||
rpy: [0, 0, 3.14] | ||
frames: | ||
area: | ||
xyz: [0.4, -0.20, 0.00] | ||
rpy: [3.14, 0, 3.14] | ||
subscenes: | ||
area: | ||
frames: | ||
zone: | ||
xyz: [0.4, -0.20, 0.00] | ||
rpy: [3.14, 0, 3.14] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright 2024 - Andrew Kwok Fai LUI, | ||
# Robotics and Autonomous Systems Group, REF, RI | ||
# and the Queensland University of Technology | ||
|
||
__author__ = 'Andrew Lui' | ||
__copyright__ = 'Copyright 2024' | ||
__license__ = 'GPL' | ||
__version__ = '1.0' | ||
__email__ = '[email protected]' | ||
__status__ = 'Development' | ||
|
||
import os, math, random | ||
import py_trees | ||
from py_trees.composites import Sequence, Parallel, Composite, Selector | ||
|
||
# robot control module | ||
from arm_commander.commander_moveit import GeneralCommander, logger | ||
import arm_commander.tools.moveit_tools as moveit_tools | ||
|
||
from task_trees.states import TaskStates | ||
from task_trees.behaviours_base import SimAttachObject, SimDetachObject, PrintPosesInFrame, PrintPose | ||
from task_trees.behaviours_move import DoMoveNamedPose, DoMoveXYZ, DoMoveXYZRPY, DoRotate | ||
from task_trees.task_trees_manager import TaskTreesManager, BasicTask | ||
from task_trees.task_scene import Scene | ||
from task_trees.scene_to_rviz import SceneToRViz | ||
import tools.pose_tools as pose_tools | ||
# ------------------------------------- | ||
# Tasks specialized for this demo | ||
|
||
# A sequence of behaviours for moving the arm to one of the named pose | ||
class MoveNamedPoseTask(BasicTask): | ||
def __init__(self, named_pose:str): | ||
""" the constructor | ||
:param named_pose: one of the named pose defined in the configuration file | ||
:type named_pose: str | ||
""" | ||
if named_pose is None or type(named_pose) is not str or len(named_pose) == 0: | ||
logger.error(f'{__class__.__name__}: parameter (named_pose) is not an non-empty string -> fix the missing value at behaviour construction') | ||
raise AssertionError(f'A parameter is invalid') | ||
super(MoveNamedPoseTask, self).__init__(named_pose) | ||
|
||
# ---------------------------------------- | ||
# The TaskManager specialized for this application | ||
class RVizTaskTreesManager(TaskTreesManager): | ||
""" This is a subclass specialized for the pick-n-drop application | ||
""" | ||
def __init__(self, arm_commander:GeneralCommander, spin_period_ms:int=10): | ||
""" the constructor | ||
:param arm_commander: a general commander for a particular arm manipulator | ||
:type arm_commander: GeneralCommander | ||
:param spin_period_ms: the tick_tock period, defaults to 10 seconds | ||
:type spin_period_ms: int, optional | ||
""" | ||
super(RVizTaskTreesManager, self).__init__(arm_commander) | ||
# load the task scene | ||
config_file = os.path.join(os.path.dirname(__file__), 'task_scene.yaml') | ||
self.the_scene = Scene(config_file) | ||
# setup visualization in rviz | ||
self.scene_to_rviz = SceneToRViz(self.the_scene, arm_commander.get_world_reference_frame(), False) | ||
self.scene_to_rviz.display_object('objects.teapot') | ||
|
||
# setup the robotic manipulation platform through the commander | ||
self.arm_commander.abort_move(wait=True) | ||
self.arm_commander.reset_world() | ||
bird_object = self.the_scene.get_object_config('teapot') | ||
self.arm_commander.add_object_to_scene('teapot_another', bird_object.model_file, bird_object.dimensions, | ||
bird_object.xyz, bird_object.rpy, reference_frame='area') | ||
# self.arm_commander.set_workspace_walls(*(self.the_scene.query_config('regions.workspace'))) | ||
# setup name poses | ||
self._define_named_poses(self.the_scene) | ||
self._define_custom_frames(self.the_scene) | ||
|
||
# setup the blackboard and the two blackboard keys 'seen_object' | ||
self.the_blackboard.register_key(key='the_object', access=py_trees.common.Access.WRITE) | ||
|
||
# build and install the behavior tree | ||
self._set_initialize_branch(self.create_initialize_branch()) | ||
self._add_task_branch(self.create_move_namedpose_task_branch(), MoveNamedPoseTask) | ||
|
||
# install and unleash the behaviour tree | ||
self._install_bt_and_spin(self.bt, spin_period_ms) | ||
|
||
# return the logical pose of the accepted task, or raise TypeError if no task is submitted | ||
def query_logical_pose_of_task(self): | ||
""" return the goal, which is a logical pose, of the current task | ||
:raises TypeError: no task has been submitted | ||
:return: the logical pose | ||
:rtype: unspecified as defined by the specific subclass of BasicTask | ||
""" | ||
if self.the_blackboard.exists('task'): | ||
return self.the_blackboard.task.get_goal_as_logical_pose() | ||
raise TypeError(f'unable to query logical pose due to no task has been submitted') | ||
|
||
# ------------------------------------------------- | ||
# --- create the behaviour tree and its branches | ||
|
||
def create_move_namedpose_task_branch(self) -> Composite: | ||
# - the branch that executes the task MoveNamedPoseTask | ||
move_named_pose_branch = py_trees.decorators.Timeout( | ||
duration=60, | ||
name='move_named_pose_branch_timeout', | ||
child=py_trees.composites.Sequence( | ||
'move_named_pose_branch', | ||
memory=True, | ||
children=[ | ||
DoMoveNamedPose('move_home_first', True, arm_commander=self.arm_commander, scene=self.the_scene, named_pose='named_poses.home'), | ||
DoMoveNamedPose('move_task_pose', True, arm_commander=self.arm_commander, scene=self.the_scene, named_pose=self.query_logical_pose_of_task), | ||
], | ||
), | ||
) | ||
return move_named_pose_branch | ||
|
||
def create_initialize_branch(self) -> py_trees.decorators.OneShot: | ||
init_action_branch = py_trees.composites.Sequence( | ||
'init_action_branch', | ||
memory=True, | ||
children = [ | ||
DoMoveNamedPose('init_move_home', True, | ||
arm_commander=self.arm_commander, scene=self.the_scene, named_pose='named_poses.home'), | ||
] | ||
) | ||
return init_action_branch | ||
|
||
|
||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.