pycram.object_descriptors.urdf#
Classes#
A class that represents a link description of an object. |
|
A class that represents the description of a joint. |
|
A class that represents an object description of an object. |
Module Contents#
- class pycram.object_descriptors.urdf.LinkDescription(urdf_description: urdf_parser_py.urdf.Link)#
Bases:
pycram.description.LinkDescriptionA class that represents a link description of an object.
- property geometry: typing_extensions.List[pycram.datastructures.dataclasses.VisualShape]#
- Returns:
The geometry type of the URDF collision element of this link.
- property visual_geometry: typing_extensions.List[pycram.datastructures.dataclasses.VisualShape]#
- Returns:
The geometry type of the URDF visual element of this link.
- static _get_visual_shape(urdf_geometry) typing_extensions.Union[pycram.datastructures.dataclasses.VisualShape, None]#
- Parameters:
urdf_geometry – The URDFGeometry for which the visual shape is returned.
- Returns:
the VisualShape of the given URDF geometry.
- property origin: typing_extensions.Optional[pycram.datastructures.pose.PoseStamped]#
The origin of this link
- Returns:
The origin of this link as a PoseStamped object.
- property name: str#
- Returns:
the name of this entity.
- property collision: typing_extensions.Union[urdf_parser_py.urdf.Collision, typing_extensions.List[urdf_parser_py.urdf.Collision], None]#
- property all_collisions: typing_extensions.List[urdf_parser_py.urdf.Collision]#
- class pycram.object_descriptors.urdf.JointDescription(urdf_description: urdf_parser_py.urdf.Joint, is_virtual: typing_extensions.Optional[bool] = False)#
Bases:
pycram.description.JointDescriptionA class that represents the description of a joint.
- urdf_type_map#
- pycram_type_map#
- property origin: pycram.datastructures.pose.PoseStamped#
- Returns:
the origin of this entity.
- property name: str#
- Returns:
the name of this entity.
- property has_limits: bool#
- Returns:
True if the joint has limits, False otherwise.
- property type: pycram.datastructures.enums.JointType#
- Returns:
The type of this joint.
- property axis: pycram.datastructures.pose.Point#
- Returns:
The axis of this joint, for example the rotation axis for a revolute joint.
- property lower_limit: typing_extensions.Union[float, None]#
- Returns:
The lower limit of this joint, or None if the joint has no limits.
- property upper_limit: typing_extensions.Union[float, None]#
- Returns:
The upper limit of this joint, or None if the joint has no limits.
- property parent: str#
- Returns:
The name of the parent link of this joint.
- property child: str#
- Returns:
The name of the child link of this joint.
- property damping: float#
- Returns:
The damping of this joint.
- property friction: float#
- Returns:
The friction of this joint.
- class pycram.object_descriptors.urdf.ObjectDescription(path: typing_extensions.Optional[str] = None)#
Bases:
pycram.description.ObjectDescriptionA class that represents an object description of an object.
- class Link(_id: int, link_description: LinkDescription, obj: pycram.world_concepts.world_object.Object, concept: typing_extensions.Type[pycrap.ontologies.Base] = pycrap.ontologies.Link, parse_name: bool = True)#
Bases:
pycram.description.ObjectDescription.Link,LinkDescriptionA link of an Object in the World.
- class RootLink(obj: pycram.world_concepts.world_object.Object)#
Bases:
pycram.description.ObjectDescription.RootLink,LinkThe root link of an Object in the World. This differs from the normal AbstractLink class in that the pose and the tf_frame is the same as that of the object.
- class Joint(_id: int, joint_description: JointDescription, obj: pycram.world_concepts.world_object.Object, is_virtual: typing_extensions.Optional[bool] = False, concept: typing_extensions.Type[pycrap.ontologies.Base] = pycrap.ontologies.Joint)#
Bases:
pycram.description.ObjectDescription.Joint,JointDescriptionRepresent a joint of an Object in the World.
- property child_map: typing_extensions.Dict[str, typing_extensions.List[typing_extensions.Tuple[str, str]]]#
- Returns:
A dictionary mapping the name of a link to its children which are represented as a tuple of the child joint name and the link name.
- property parent_map: typing_extensions.Dict[str, typing_extensions.Tuple[str, str]]#
- Returns:
A dictionary mapping the name of a link to its parent joint and link as a tuple.
- property link_map: typing_extensions.Dict[str, LinkDescription]#
- Returns:
A dictionary mapping the name of a link to its description.
- property joint_map: typing_extensions.Dict[str, JointDescription]#
- Returns:
A dictionary mapping the name of a joint to its description.
- _init_joints_map() None#
- _init_links_map() None#
- add_joint(name: str, child: str, joint_type: pycram.datastructures.enums.JointType, axis: typing_extensions.Optional[pycram.datastructures.pose.Point] = None, parent: typing_extensions.Optional[str] = None, origin: typing_extensions.Optional[pycram.datastructures.pose.PoseStamped] = None, lower_limit: typing_extensions.Optional[float] = None, upper_limit: typing_extensions.Optional[float] = None, is_virtual: typing_extensions.Optional[bool] = False) None#
Add a joint to the object description, could be a virtual joint as well. For documentation of the parameters, see
pycram.description.ObjectDescription.add_joint().
- add_joint_from_parsed_description(description: urdf_parser_py.urdf.Joint) None#
Add a joint to the object description from a parsed URDF joint description.
- Parameters:
description – The parsed URDF joint description.
- add_link_from_parsed_description(description: urdf_parser_py.urdf.Link) None#
Add a link to the object description from a parsed URDF link description.
- Parameters:
description – The parsed URDF link description.
- merge_description(other: ObjectDescription, parent_link: typing_extensions.Optional[str] = None, child_link: typing_extensions.Optional[str] = None, joint_type: pycram.datastructures.enums.JointType = JointType.FIXED, axis: typing_extensions.Optional[pycram.datastructures.pose.Point] = None, lower_limit: typing_extensions.Optional[float] = None, upper_limit: typing_extensions.Optional[float] = None, child_pose_wrt_parent: typing_extensions.Optional[pycram.datastructures.pose.PoseStamped] = None, in_place: bool = False, new_description_file: typing_extensions.Optional[str] = None) typing_extensions.Union[ObjectDescription, typing_extensions.Self]#
Merge the description of this object with the description of the other object.
- Parameters:
other – The object description to merge with this one.
parent_link – The name of the parent link of the joint connecting the two objects.
child_link – The name of the child link of the joint connecting the two objects.
joint_type – The type of the joint connecting the two objects.
axis – The axis of the joint connecting the two objects.
lower_limit – The lower limit of the joint connecting the two objects.
upper_limit – The upper limit of the joint connecting the two objects.
child_pose_wrt_parent – The pose of the child link with respect to the parent link.
in_place – True if the merge should be done in place, False otherwise.
new_description_file – If given, the new description will be saved to this file, otherwise the new description will be saved in place of the original file.
- Returns:
The merged object description, could be a new object description if in_place is False else self.
- _init_description() None#
- load_description(path) urdf_parser_py.urdf.URDF#
Load the description from the file at the given path.
- Parameters:
path – The path to the source file, if only a filename is provided then the resources directories will be searched.
- generate_from_mesh_file(path: str, name: str, save_path: str, color: typing_extensions.Optional[pycram.datastructures.dataclasses.Color] = Color(), scale: typing_extensions.Optional[float] = None) None#
- Generate a URDf file with the given .obj or .stl file as mesh. In addition, use the given rgba_color to create a
material tag in the URDF. The URDF file will be saved to the given save_path.
- Parameters:
path – The path to the mesh file.
name – The name of the object.
save_path – The path to save the URDF file to.
color – The color of the object.
scale – The scale of the mesh.
- generate_from_description_file(path: str, save_path: str, make_mesh_paths_absolute: bool = True) None#
Generates a loadable URDF file from the given URDF file. The method will fix the attributes of some links, replace relative paths with absolute paths and fix the missing inertial tags. The generated URDF file will be saved to the given save_path.
- Parameters:
path – Path to the URDF file which should be processed.
save_path – Path to where to save the processed URDF file.
make_mesh_paths_absolute – If mesh paths should be made absolute. This is needed for PyBullet to load the URDF file.
- generate_from_parameter_server(name: str, save_path: str) None#
Preprocess the description from the ROS parameter server and return the preprocessed description string. The preprocessed description will be saved at the given save_path.
- Parameters:
name – The name of the description on the parameter server.
save_path – The path to save the preprocessed description file.
- property joints: typing_extensions.List[JointDescription]#
- Returns:
A list of joints descriptions of this object.
- _init_joints() None#
- property links: typing_extensions.List[LinkDescription]#
- Returns:
A list of link descriptions of this object.
- _init_links() None#
- get_root() str#
- Returns:
the name of the root link of this object.
- get_tip() str#
- Returns:
the name of the tip link of this object.
- Raises:
MultiplePossibleTipLinks – If there are multiple possible tip links.
- get_chain(start_link_name: str, end_link_name: str, joints: typing_extensions.Optional[bool] = True, links: typing_extensions.Optional[bool] = True, fixed: typing_extensions.Optional[bool] = True) typing_extensions.List[str]#
- Parameters:
start_link_name – The name of the start link of the chain.
end_link_name – The name of the end link of the chain.
joints – Whether to include joints in the chain.
links – Whether to include links in the chain.
fixed – Whether to include fixed joints in the chain.
- Returns:
the chain of links from ‘start_link_name’ to ‘end_link_name’.
- static replace_relative_references_with_absolute_paths(urdf_string: str) str#
Change paths for files in the URDF from ROS paths and file dir references to paths in the file system. Since World (PyBullet legacy) can’t deal with ROS package paths.
- Parameters:
urdf_string – The name of the URDf on the parameter server
- Returns:
The URDF string with paths in the filesystem instead of ROS packages
- static make_mesh_paths_absolute(urdf_string: str, urdf_file_path: str) str#
Convert all relative mesh paths in the URDF to absolute paths.
- Parameters:
urdf_string – The URDF description as string
urdf_file_path – The path to the URDF file
- Returns:
The new URDF description as string.
- static fix_missing_inertial(urdf_string: str) str#
Insert inertial tags for every URDF link that has no inertia. This is used to prevent Legacy(PyBullet) from dumping warnings in the terminal
- Parameters:
urdf_string – The URDF description as string
- Returns:
The new, corrected URDF description as string.
- static remove_error_tags(urdf_string: str) str#
Remove all tags in the removing_tags list from the URDF since these tags are known to cause errors with the URDF_parser
- Parameters:
urdf_string – String of the URDF from which the tags should be removed
- Returns:
The URDF string with the tags removed
- static fix_link_attributes(urdf_string: str) str#
Remove the attribute ‘type’ from links since this is not parsable by the URDF parser.
- Parameters:
urdf_string – The string of the URDF from which the attributes should be removed
- Returns:
The URDF string with the attributes removed
- static get_file_extension() str#
- Returns:
The file extension of the URDF file.
- property origin: pycram.datastructures.pose.PoseStamped#
- Returns:
the origin of this entity.
- property name: str#
- Returns:
the name of this entity.