Visualization
# @FileName : Visualizer.py # @Time : 2024-08-03 15:09:53 # @Author : yk # @Email : yangkui1127@gmail.com # @Description: : Visualizer for pybullet
- class Visualization.Visualizer.Visualizer(client, visualizer_cfg)[source]
A class for visualizing objects and scenes in PyBullet.
- client
The PyBullet client object.
- Type:
object
- client_id
The client id returned by the PyBullet client.
- Type:
int
- set_camera_pose(camera_cfg)[source]
Sets the debug visualizer camera pose.
- Parameters:
camera_cfg (object) – Configuration for the camera pose.
- capture_screen(filename=None)[source]
Continuously captures the screens of PyBullet GUI and saves the images to files.
- Parameters:
filename (str, optional) – The filename to save the captured image. Defaults to None.
- draw_axes(length=1.0, lineWidth=2.0, textSize=1.0)[source]
Draws the x, y, and z axes in the PyBullet environment with text labels.
- Parameters:
length (float) – Length of the axes.
lineWidth (float) – Width of the axes lines.
textSize (float) – Size of the text labels.
- start_record(fileName)[source]
Starts recording a video of the PyBullet simulation.
- Parameters:
fileName (str) – The filename for the video file.
- draw_line(start_pos, target_pos, color=[1, 0, 0], width=3.0)[source]
Draws a line on the screen from the specified start position to the target position.
- Parameters:
start_pos (tuple) – The starting position of the line as a tuple of (x, y, z) coordinates.
target_pos (tuple) – The ending position of the line as a tuple of (x, y, z) coordinates.
color (list, optional) – A list representing the RGB values of the line’s color. Default is red [1, 0, 0].
width (float, optional) – The width of the line. Default is 3.0.
- draw_aabb(object)[source]
Draws an Axis-Aligned Bounding Box (AABB) around the specified object in the simulation.
- Parameters:
object (Union[int, str]) – The unique identifier of the object or its name.
- draw_aabb_link(object, link_id=-1)[source]
Draws an Axis-Aligned Bounding Box (AABB) around the specified link in the simulation.
- Parameters:
object (Union[int, str]) – The unique identifier of the object or its name.
link_id (int, optional) – The index of the link for which the AABB is to be drawn. Defaults to -1, which means the entire object.
- draw_object_pose(object, length=0.25, lineWidth=2.0, textSize=1.0)[source]
Draws the pose of an object in the PyBullet environment.
- Parameters:
object (Union[int, str]) – The unique identifier of the object or its name.
length (float, optional) – The length of the pose axes. Default is 0.25.
lineWidth (float, optional) – The width of the pose axes lines. Default is 2.0.
textSize (float, optional) – The size of the text labels. Default is 1.0.
- draw_pose(pose, length=0.25, lineWidth=2.0, textSize=1.0)[source]
Draws the pose of an object in the PyBullet environment.
- Parameters:
object (Union[int, str]) – The unique identifier of the object or its name.
length (float, optional) – The length of the pose axes. Default is 0.25.
lineWidth (float, optional) – The width of the pose axes lines. Default is 2.0.
textSize (float, optional) – The size of the text labels. Default is 1.0.
- draw_link_pose(object, link_id, length=0.25, lineWidth=2.0, textSize=1.0)[source]
Draws the pose of a specific link of an object in the PyBullet environment.
- Parameters:
object (Union[int, str]) – The unique identifier of the object or its name.
link_id (int) – The index of the link for which the pose is to be drawn.
length (float, optional) – The length of the pose axes. Default is 0.25.
lineWidth (float, optional) – The width of the pose axes lines. Default is 2.0.
textSize (float, optional) – The size of the text labels. Default is 1.0.
- change_robot_color(base_id, arm_id, light_color=True)[source]
Sets the color of the robot.
- Parameters:
base_id (int) – The unique identifier of the robot base.
arm_id (int) – The unique identifier of the robot arm.
light_color (bool, optional) – Flag to set the robot to light colors. Default is True.
- set_object_color(object_id, color)[source]
Sets the color of an object.
- Parameters:
object_id (int) – The unique identifier of the object.
color (str) – The color to set for the object.
# @FileName : Camera.py # @Time : 2024-08-03 15:09:34 # @Author : yk # @Email : yangkui1127@gmail.com # @Description: : Camera
- class Visualization.Camera.Camera(cfg, base_id, arm_place_height)[source]
Robotic Camera.
This class handles the camera functionalities for a robotic system, including capturing RGB and depth images.
- sim_update()[source]
Updates the camera view and projection matrices, captures images, and returns the captured data.
- Returns:
Width, height, RGB image, depth image, and segmentation mask.
- Return type:
tuple
- sim_get_rgb_image(enable_show=False, enable_save=False, filename=None)[source]
Captures an RGB image from the camera.
- Parameters:
enable_show (bool, optional) – Whether to display the captured image. Defaults to False.
enable_save (bool, optional) – Whether to save the captured image. Defaults to False.
- Returns:
Captured RGB image.
- Return type:
np.ndarray
- sim_get_depth_image(enable_show=False, enable_save=False, filename=None)[source]
Captures a depth image from the camera.
- Parameters:
enable_show (bool, optional) – Whether to display the captured image. Defaults to False.
enable_save (bool, optional) – Whether to save the captured image. Defaults to False.
- Returns:
Captured depth image.
- Return type:
np.ndarray
- sim_rotate_around_y(vector, angle)[source]
vector rotate around y axis
- Parameters:
vector (np.array) – vector
() (angle) – rotate angle
- Returns:
rotated vector
# @FileName : pyBulletSimRecorder.py # @Time : 2024-08-03 15:09:24 # @Author : yk # @Email : yangkui1127@gmail.com # @Description: : A recorder in pybullet sim and the result can be import into blender scene
- class Visualization.blender_render.pyBulletSimRecorder.PyBulletRecorder[source]
A class for recording PyBullet simulations.
- class LinkTracker(type, name, body_id, link_id, link_origin, mesh_path, mesh_scale)[source]
Tracks the state of a link in the simulation.
- register_object(body_id, urdf_path, global_scaling)[source]
Registers an object in the simulation for tracking.
- Parameters:
body_id (int) – The ID of the body to be registered.
urdf_path (str) – The path to the URDF file of the object.
global_scaling (float) – The global scaling factor for the object.