compas_robots.scene
¤
This package provides the base scene objects used to visualize robot models across the different CAD backends.
Classes¤
AbstractRobotModelObject
¤
Defines the interface for robot model scene objects.
Functions¤
create_geometry
¤
Draw geometry in the respective CAD environment.
Parameters:
-
geometry(Mesh) –Instance of a mesh data structure
-
name(str | None, default:None) –The name of the mesh to draw.
-
color–The color of the object.
Returns:
-
CAD-specific geometry–
Notes
This is an abstract method that needs to be implemented by derived classes.
transform
¤
transform(geometry: object, transformation: Transformation) -> None
Transforms a CAD-specific geometry using a Transformation.
Parameters:
-
geometry(object) –A CAD-specific (i.e. native) geometry object as returned by
create_geometry. -
transformation(Transformation) –Transformation to update the geometry object.
BaseRobotModelObject
¤
Provides common functionality to most robot model scene object implementations.
In COMPAS, SceneObjects are classes that assist with the visualization of
datastructures and models, in a way that maintains the data separated from the
specific CAD interfaces, while providing a way to leverage native performance
of the CAD environment.
There are two methods that implementers of this base class should provide, one
is concerned with the actual creation of geometry in the native format of the
CAD environment (create_geometry) and the other is one to apply a transformation
to geometry (transform).
Attributes:
-
model(RobotModel) –Instance of a robot model.
Attributes¤
attached_tool_model
property
¤
attached_tool_model: ToolModel | None
For backwards compatibility. Returns the tool attached to the first end effector link or, if not available, the first tool from the dictionary. Returns None if no tool are attached.
Functions¤
attach_mesh
¤
Rigidly attaches a compas mesh to a given link for visualization.
Parameters:
-
mesh(Mesh) –The mesh to attach to the robot model.
-
name(str) –The identifier of the mesh.
-
link(Link | None, default:None) –The link within the robot model or tool model to attach the mesh to. Optional. Defaults to the model's end effector link.
-
frame(Frame | None, default:None) –The frame of the mesh. Defaults to compas.geometry.Frame.worldXY.
attach_tool_model
¤
attach_tool_model(tool_model: ToolModel) -> None
Attach a tool to the robot scene object for visualization.
Parameters:
-
tool_model(ToolModel) –The tool that should be attached to the robot's flange.
create
¤
Recursive function that triggers the drawing of the robot model's geometry.
This method delegates the geometry drawing to the create_geometry
method. It transforms the geometry based on the saved initial
transformation from the robot model.
Parameters:
detach_mesh
¤
detach_mesh(name: str) -> None
Removes attached collision meshes with a given name.
Parameters:
-
name(str) –The identifier of the mesh.
detach_tool_model
¤
detach_tool_model(tool_model: ToolModel | None = None) -> None
Detach tool_model from this robot model. If tool_model is None, all attached tools are detached.
Parameters:
-
tool_model(ToolModel | None, default:None) –The tool that should be detached from the robot's flange. If None, all attached tools tools are removed.
draw_attached_meshes
¤
Draws all meshes attached to the robot model.
Returns:
-
A list of context-specific mesh representations.–
draw_collision
¤
Draws all collision geometry of the robot model.
Returns:
-
A list of context-specific mesh representations.–
draw_visual
¤
Draws all visual geometry of the robot model.
Returns:
-
A list of context-specific mesh representations.–
meshes
¤
meshes(
link: Link | None = None,
visual: bool = True,
collision: bool = False,
attached_meshes: bool = True,
) -> list[Mesh]
Returns all compas meshes of the model.
Parameters:
-
link(Link | None, default:None) –Base link instance. Defaults to the robot model's root.
-
visual(bool, default:True) –Whether to include the robot's visual meshes.
-
collision(bool, default:False) –Whether to include the robot's collision meshes.
-
attached_meshes(bool, default:True) –Whether to include the robot's attached meshes.
scale
¤
scale(factor: float) -> None
Scales the robot model's geometry by factor (absolute).
Parameters:
-
factor(float) –The factor to scale the robot with.
scale_link
¤
scale_link(link: Link, transformation: Transformation) -> None
Recursive function to apply the scale transformation on each link.
Parameters:
-
link(Link) –A link.
-
transformation(Transformation) –A transformation to apply to th link's geometry.
update
¤
update(
joint_state: Configuration | dict[str, float],
visual: bool = True,
collision: bool = True,
) -> None
Triggers the update of the robot geometry.
Parameters:
update_tool
¤
update_tool(
tool: ToolModel,
joint_state: Configuration | dict[str, float] | None = None,
visual: bool = True,
collision: bool = True,
transformation: Transformation | None = None,
) -> None
Triggers the update of the robot geometry of the tool.
Parameters:
-
joint_state(Configuration | dict[str, float] | None, default:None) –A dictionary with joint names as keys and joint positions as values. Defaults to an empty dictionary.
-
transformation(Transformation | None, default:None) –The (absolute) transformation to apply to the entire tool's geometry. If None is given, no additional transformation will be applied. Defaults to None.
-
visual(bool, default:True) –If True, the visual geometry will also be updated.
-
collision(bool, default:True) –If True, the collision geometry will also be updated.