mh5_director
reference¶
class Director¶
-
class
Director
(portfolio_path=None)[source]¶ The Director class
Reads script definitions from YAML files and can execute them by passing the pose information to the
dynamixel_control/follow_joint_trajectory
action server.Listens to the
director/run
topic for commands to execute a script.-
load_scripts
()[source]¶ Loads XML definitions from the param server and stores them in the
portfolios
attribute.
-
setup_services
()[source]¶ Starts the subscriptions.
Director subscribes to: -
director/run
- used to trigger the execution of a script - …
-
setup_action_client
()[source]¶ Sets up the subscription to the
dynamixel_control/follow_joint_trajectory
action server.The function will wait for the action server to become available.
-
run_script_callback
(msg)[source]¶ Callback for
director/run
- The request script should be in the form: <portfolio.script>.
Will log errors if the requested portfolio or script in that portfolio doesn’t exist.
The information in the script is converted into a JointTrajectoryGoal and passed to the action server. If the
feedback
attribute in the message is True, the script_feedback_callback() will be also submitted to the send_goal() method of the action client. If thewait
attribute in the message is True the method will wait for the action server to finish before completing.
- Parameters
msg (RunScript) – message received
-
class Portfolio¶
-
class
Portfolio
[source]¶ A portfolio of scripts.
A Portfolio is a collection of scripts that can share certain elements like scenes and poses.
A portfolio is composed of the following elements:
-
name
¶ the name of the Portfolio
-
units
¶ Unit of measurements for positions angles. Only
rad
anddeg
allowed and by default it will berad
if no attribute is specified in the souce XACRO. :type str
-
joints
¶ The default list of joints to be used across the scripts in this portfolio. The order of joints is important as all the
positions
sppecifications will assume the same order. A portfolio can use a subset of all the joints of the robot and only the joints specified here will be passed when constructing the communcation messages with the robots’ controllers. :type list(str)
-
duration
¶ The default duration (in seconds) for poses in scenes. If scenes do not specify a
duration=
attribute, they will inherit automatically this duration from the portfolio. :type float
-
poses
¶ A dictionary of Pose() defined in this portfolio. type dict{name: Pose}
-
scenes
¶ A dictionary of Scene() defined in this portfolio. type dict{name: Scene}
-
scripts
¶ A dictionary of Script() defined in this portfolio. type dict{name: Script}
-
classmethod
from_xml
(xml_elem)[source]¶ Constructs a
Portfolio
object by reading an XML defintion and parsing it.- Parameters
xml_elem (xml.etree.ElementTree.ElementTree) – The XML element with the structure of the portfolio.
- Raises
ValueError: – If the data is incorrect. Additional details are provided in the exception text.
AssertionError: – If attributes are missing or missmatched with the expected ones.
-
class Pose¶
-
class
Pose
[source]¶ A Pose groups together the joints and the positions needed to produce a specific robot pose.
-
name
¶ Pose name
- Type
str
-
joints
¶ Joints used by the Pose. If the source XACRO did not use
joints=
the Pose will inherit by default all the joints defined in the portfolio- Type
list of str
-
positions
¶ Positions for each of the joints associated with this Pose. Each position matches the order of joints and is expressed in the unit of measures defined by the portfolio.
- Type
list of float
-
classmethod
from_xml
(xml_elem, portfolio)[source]¶ Initializes the Pose from an XML element tree structure.
- Parameters
xml_elem (xml.etree.ElementTree.ElementTree) – The XML element tree that contains the structure of the Pose
portfolio (
Portfolio
) – The top Portfolio object that ownes this Pose
- Returns
The initiazed Pose object.
- Return type
- Raises
ValueError – If values included in the XML are incorrect. More details are provided in the exception text.
AssertError – If certain attributes are not included in the XML. More details are provided in the exception text.
-