OpTaS  1.0.7
An optimization-based task specification library for trajectory optimization and model predictive control.
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
optas.visualize.Visualizer Class Reference

This class defines the Visualizer for simple visualization. More...

Public Member Functions

def __init__ (self, List[int] window_size=[1440, 810], ArrayType background_color=[0.0, 0.0, 0.0], ArrayType camera_position=[2, 2, 2], ArrayType camera_focal_point=[0, 0, 0], ArrayType camera_view_up=[0, 0, 1], Union[None, float] quit_after_delay=None)
 Initializer for the Visualizer class. More...
 
def reset_camera (self, position, view_dir, view_up)
 Reset the camera pose. More...
 
vtk.vtkActor line (self, ArrayType start=[0.0, 0.0, 0.0], ArrayType end=[1.0, 0.0, 0.0], Union[None, ArrayType] rgb=None, float alpha=1.0, float linewidth=1.0)
 Draw a line. More...
 
vtk.vtkActor sphere (self, float radius=1.0, ArrayType position=[0.0, 0.0, 0.0], Union[None, ArrayType] rgb=None, float alpha=1.0, int theta_resolution=20, int phi_resolution=20)
 Draw a sphere. More...
 
List[vtk.vtkActor] sphere_traj (self, ArrayType position_traj, float radius=1.0, Union[None, ArrayType] rgb=None, int theta_resolution=20, int phi_resolution=20, Union[None, Dict] alpha_spec=None, animate=False, duration=5.0)
 Draw a sphere trajectory. More...
 
vtk.vtkActor box (self, ArrayType scale=[1, 1, 1], Union[None, ArrayType] rgb=None, float alpha=1.0, ArrayType position=[0.0, 0.0, 0.0], ArrayType orientation=[0.0, 0.0, 0.0], str euler_seq="xyz", bool euler_degrees=False)
 Draw a box. More...
 
vtk.vtkActor cylinder (self, float radius=1.0, float height=1.0, Union[None, ArrayType] rgb=None, float alpha=1.0, int resolution=20, ArrayType position=[0.0, 0.0, 0.0], ArrayType orientation=[0.0, 0.0, 0.0], str euler_seq="xyz", bool euler_degrees=False)
 Draw a cylinder (with main axis along y-axis). More...
 
vtk.vtkActor cylinder_urdf (self, radius=1.0, height=1.0, rgb=None, alpha=1.0, resolution=20, position=[0.0, 0.0, 0.0], orientation=[0.0, 0.0, 0.0], euler_seq="xyz", euler_degrees=False)
 Draw a cylinder (with main axis along the z-axis, i.e. More...
 
vtk.vtkFollower text (self, str msg="Hello, world!", ArrayType position=[0.0, 0.0, 0.0], ArrayType scale=[1.0, 1.0, 1.0], Union[None, ArrayType] rgb=None, float alpha=1.0)
 Draw text. More...
 
List[vtk.vtkActor] link (self, ArrayType T=None, float axis_scale=0.1, float axis_linewidth=1.0, float center_radius=0.01, Union[None, ArrayType] center_rgb=None, float center_alpha=1.0, int center_theta_resolution=20, int center_phi_resolution=20, float axis_alpha=1.0)
 Draw a link. More...
 
List[vtk.vtkActor] grid_floor (self, int num_cells=10, Union[None, ArrayType] rgb=None, float alpha=1.0, float linewidth=3.0, Union[None, ArrayType] inner_rgb=None, Union[None, float] inner_alpha=None, float inner_linewidth=1.0, float stride=1.0, ArrayType euler=[0, 0, 0], str euler_seq="xyz", bool euler_degrees=True)
 Draw a grid floor. More...
 
def obj (self, str obj_filename, str png_texture_filename=None, ArrayType position=[0.0, 0.0, 0.0], ArrayType orientation=[0.0, 0.0, 0.0], str euler_seq="xyz", bool euler_degrees=False)
 Load .obj file. More...
 
vtk.vtkActor stl (self, filename, scale=None, rgb=None, alpha=1.0, position=[0.0, 0.0, 0.0], orientation=[0.0, 0.0, 0.0], euler_seq="xyz", euler_degrees=False)
 Load .stl file. More...
 
List[vtk.vtkActor] robot (self, RobotModel robot_model, ArrayType q=None, float alpha=1.0, bool show_links=False, float link_axis_scale=0.2, float link_axis_linewidth=1.0, float link_center_radius=0.01, Union[None, ArrayType] link_center_rgb=None, Union[None, ArrayType] link_center_alpha=None, bool display_link_names=False, ArrayType link_names_scale=[0.005, 0.005, 0.005], ArrayType link_names_rgb=[1, 1, 1], float link_names_alpha=1.0)
 Draw a robot. More...
 
def robot_traj (self, robot_model, Q, alpha_spec=None, show_links=False, link_axis_scale=0.2, link_axis_linewidth=1.0, link_center_rgb=1, link_center_alpha=None, link_center_radius=0.01, display_link_names=False, link_names_scale=[0.01, 0.01, 0.01], link_names_rgb=[1, 1, 1], link_names_alpha=1.0, animate=False, duration=5.0)
 Draw a robot through a trajectory. More...
 
def save (self, file_name)
 Save the visualizer window as png image. More...
 
None start (self)
 Start the visualizer. More...
 
None close (self, obj, event)
 Close the visualizer. More...
 

Static Public Member Functions

DM cvt_orientation_to_rotation_matrix (ArrayType orientation, str euler_seq, bool euler_degrees)
 Convert an orientation input to a rotation matrix. More...
 
None set_tf (vtk.vtkActor actor, ArrayType position, ArrayType orientation, str euler_seq, bool euler_degrees)
 Sets a transform to a vtk Actor. More...
 
None set_transformation (vtk.vtkActor actor, ArrayType tf)
 Sets a transformation to a vtk Actor. More...
 
None set_rgba (vtk.vtkActor actor, ArrayType rgb, float alpha)
 Set the RGB and alpha channels for an actor. More...
 
None set_translation (vtk.vtkActor actor, ArrayType translation)
 Set translation for an actor. More...
 

Public Attributes

 ren
 
 renWin
 
 camera
 
 iren
 
 actors
 
 animate_callbacks
 

Detailed Description

This class defines the Visualizer for simple visualization.

Constructor & Destructor Documentation

◆ __init__()

def optas.visualize.Visualizer.__init__ (   self,
List[int]   window_size = [1440, 810],
ArrayType   background_color = [0.0, 0.0, 0.0],
ArrayType   camera_position = [2, 2, 2],
ArrayType   camera_focal_point = [0, 0, 0],
ArrayType   camera_view_up = [0, 0, 1],
Union[None, float]   quit_after_delay = None 
)

Initializer for the Visualizer class.

   @param window_size The window size [W, H] for the visualizer.
   @param background_color The color of the background (RGB), default is black.
   @param camera_position The position of the camera in the global frame.
   @param camera_focal_point The focus point of the camera.
   @param camera_view_up Direction of the up direction for the camera.
   @param quit_after_delay Number of seconds to keep visualizer running, if None then the visualizer is run indefinitely until the user quits the window.
   @return An instance of the Visualizer class.

Member Function Documentation

◆ box()

vtk.vtkActor optas.visualize.Visualizer.box (   self,
ArrayType   scale = [1, 1, 1],
Union[None, ArrayType]   rgb = None,
float   alpha = 1.0,
ArrayType   position = [0.0, 0.0, 0.0],
ArrayType   orientation = [0.0, 0.0, 0.0],
str   euler_seq = "xyz",
bool   euler_degrees = False 
)

Draw a box.

   @param scale The length, width, and height for the box [L, W, H].
   @param rgb The Red-Green-Blue values in range [0, 1].
   @param alpha Transparency of the actor in range [0, 1].
   @param position The position of the transformation.
   @param orientation Orientation of the transformation, either a quaternion or Euler angles.
   @param euler_seq When orientation are Euler angles, specifies sequence of axes for rotations. Up to 3 characters belonging to the set {'X', 'Y', 'Z'} for intrinsic rotations, or {'x', 'y', 'z'} for extrinsic rotations. When orientation are Euler angles, extrinsic and intrinsic rotations cannot be mixed in one function call.
   @param euler_degrees If True, then the given angles are assumed to be in degrees. Default is False.
   @return The box actor.

◆ close()

None optas.visualize.Visualizer.close (   self,
  obj,
  event 
)

Close the visualizer.

◆ cvt_orientation_to_rotation_matrix()

DM optas.visualize.Visualizer.cvt_orientation_to_rotation_matrix ( ArrayType  orientation,
str  euler_seq,
bool   euler_degrees 
)
static

Convert an orientation input to a rotation matrix.

   @param orientation Either a quaternion or Euler angles.
   @param euler_seq When orientation are Euler angles, specifies sequence of axes for rotations. Up to 3 characters belonging to the set {'X', 'Y', 'Z'} for intrinsic rotations, or {'x', 'y', 'z'} for extrinsic rotations. When orientation are Euler angles, extrinsic and intrinsic rotations cannot be mixed in one function call.
   @param euler_degrees If True, then the given angles are assumed to be in degrees. Default is False.
   @return Rotation matrix.

◆ cylinder()

vtk.vtkActor optas.visualize.Visualizer.cylinder (   self,
float   radius = 1.0,
float   height = 1.0,
Union[None, ArrayType]   rgb = None,
float   alpha = 1.0,
int   resolution = 20,
ArrayType   position = [0.0, 0.0, 0.0],
ArrayType   orientation = [0.0, 0.0, 0.0],
str   euler_seq = "xyz",
bool   euler_degrees = False 
)

Draw a cylinder (with main axis along y-axis).

   @param radius The cylinder radius.
   @param height The height of the cylinder.
   @param rgb The Red-Green-Blue values in range [0, 1].
   @param alpha Transparency of the actor in range [0, 1].
   @param resolution The number of facets used to define cylinder.
   @param position The position of the object.
   @param orientation Orientation of the object, either a quaternion or Euler angles.
   @param euler_seq When orientation are Euler angles, specifies sequence of axes for rotations. Up to 3 characters belonging to the set {'X', 'Y', 'Z'} for intrinsic rotations, or {'x', 'y', 'z'} for extrinsic rotations. When orientation are Euler angles, extrinsic and intrinsic rotations cannot be mixed in one function call.
   @param euler_degrees If True, then the given angles are assumed to be in degrees. Default is False.
   @return The cylinder actor.

◆ cylinder_urdf()

vtk.vtkActor optas.visualize.Visualizer.cylinder_urdf (   self,
  radius = 1.0,
  height = 1.0,
  rgb = None,
  alpha = 1.0,
  resolution = 20,
  position = [0.0, 0.0, 0.0],
  orientation = [0.0, 0.0, 0.0],
  euler_seq = "xyz",
  euler_degrees = False 
)

Draw a cylinder (with main axis along the z-axis, i.e.

similar to URDF).

   @param radius The cylinder radius.
   @param height The height of the cylinder.
   @param rgb The Red-Green-Blue values in range [0, 1].
   @param alpha Transparency of the actor in range [0, 1].
   @param resolution The number of facets used to define cylinder.
   @param position The position of the object.
   @param orientation Orientation of the object, either a quaternion or Euler angles.
   @param euler_seq When orientation are Euler angles, specifies sequence of axes for rotations. Up to 3 characters belonging to the set {'X', 'Y', 'Z'} for intrinsic rotations, or {'x', 'y', 'z'} for extrinsic rotations. When orientation are Euler angles, extrinsic and intrinsic rotations cannot be mixed in one function call.
   @param euler_degrees If True, then the given angles are assumed to be in degrees. Default is False.
   @return The cylinder actor.

◆ grid_floor()

List[vtk.vtkActor] optas.visualize.Visualizer.grid_floor (   self,
int   num_cells = 10,
Union[None, ArrayType]   rgb = None,
float   alpha = 1.0,
float   linewidth = 3.0,
Union[None, ArrayType]   inner_rgb = None,
Union[None, float]   inner_alpha = None,
float   inner_linewidth = 1.0,
float   stride = 1.0,
ArrayType   euler = [0, 0, 0],
str   euler_seq = "xyz",
bool   euler_degrees = True 
)

Draw a grid floor.

   @param num_cells The number of cells for the grid floor.
   @param rgb The Red-Green-Blue values in range [0, 1].
   @param alpha Transparency of the actor in range [0, 1].
   @param linewidth The line width for the grid.
   @param inner_rgb The Red-Green-Blue values in range [0, 1] for the inner lines at half the stride length.
   @param inner_alpha Transparency of the actor in range [0, 1] for the inner lines at half the stride length.
   @param inner_linewidth The line width for the grid for the inner lines at half the stride length.
   @param stride The length of each main grid cell.
   @param euler The Euler angles that defines the orientation of the plane the grid is defined on.
   @param euler_seq When orientation are Euler angles, specifies sequence of axes for rotations. Up to 3 characters belonging to the set {'X', 'Y', 'Z'} for intrinsic rotations, or {'x', 'y', 'z'} for extrinsic rotations. When orientation are Euler angles, extrinsic and intrinsic rotations cannot be mixed in one function call.
   @param euler_degrees If True, then the given angles are assumed to be in degrees. Default is False.
   @return The grid actors.

◆ line()

vtk.vtkActor optas.visualize.Visualizer.line (   self,
ArrayType   start = [0.0, 0.0, 0.0],
ArrayType   end = [1.0, 0.0, 0.0],
Union[None, ArrayType]   rgb = None,
float   alpha = 1.0,
float   linewidth = 1.0 
)

Draw a line.

   @param start The start of the line.
   @param end The end of the line.
   @param rgb The Red-Green-Blue values in range [0, 1].
   @param alpha Transparency of the actor in range [0, 1].
   @param linewidth The width of the line.
   @return The line actor.

◆ link()

List[vtk.vtkActor] optas.visualize.Visualizer.link (   self,
ArrayType   T = None,
float   axis_scale = 0.1,
float   axis_linewidth = 1.0,
float   center_radius = 0.01,
Union[None, ArrayType]   center_rgb = None,
float   center_alpha = 1.0,
int   center_theta_resolution = 20,
int   center_phi_resolution = 20,
float   axis_alpha = 1.0 
)

Draw a link.

   @param T Homogeneous transformation matrix.
   @param axis_scale The axis length.
   @param axis_linewidth Width of the axis lines.
   @param center_radius The radius of the central sphere.
   @param center_rgb The Red-Green-Blue values in range [0, 1].
   @param center_alpha Transparency of the centeral sphere in range [0, 1].
   @param center_theta_resolution The number of points in the longitude direction.
   @param center_phi_resolution The number of points in the latitude direction.
   @param axis_alpha Transparency of the axes in range [0, 1].
   @return The link actors.

◆ obj()

def optas.visualize.Visualizer.obj (   self,
str  obj_filename,
str   png_texture_filename = None,
ArrayType   position = [0.0, 0.0, 0.0],
ArrayType   orientation = [0.0, 0.0, 0.0],
str   euler_seq = "xyz",
bool   euler_degrees = False 
)

Load .obj file.

   @param obj_filename The filename for the .obj file.
   @param png_texture_filename The texture filename.
   @param position The position of the object.
   @param orientation Orientation of the object, either a quaternion or Euler angles.
   @param euler_seq When orientation are Euler angles, specifies sequence of axes for rotations. Up to 3 characters belonging to the set {'X', 'Y', 'Z'} for intrinsic rotations, or {'x', 'y', 'z'} for extrinsic rotations. When orientation are Euler angles, extrinsic and intrinsic rotations cannot be mixed in one function call.
   @param euler_degrees If True, then the given angles are assumed to be in degrees. Default is False.
   @return The actor representing the .obj file.

◆ reset_camera()

def optas.visualize.Visualizer.reset_camera (   self,
  position,
  view_dir,
  view_up 
)

Reset the camera pose.

   @param position The position of the camera.
   @param view_dir The direction that the camera should view.
   @param view_up The up direction for the image.

◆ robot()

List[vtk.vtkActor] optas.visualize.Visualizer.robot (   self,
RobotModel  robot_model,
ArrayType   q = None,
float   alpha = 1.0,
bool   show_links = False,
float   link_axis_scale = 0.2,
float   link_axis_linewidth = 1.0,
float   link_center_radius = 0.01,
Union[None, ArrayType]   link_center_rgb = None,
Union[None, ArrayType]   link_center_alpha = None,
bool   display_link_names = False,
ArrayType   link_names_scale = [0.005, 0.005, 0.005],
ArrayType   link_names_rgb = [1, 1, 1],
float   link_names_alpha = 1.0 
)

Draw a robot.

   @param robot_model The robot model defining the robot kinematics and visuals.
   @param q Joint configuration to draw robot.
   @param alpha Transparency of the actor in range [0, 1].
   @param show_links When true, the robot links are shown.
   @param link_axis_scale The scale for the link axes when shown.
   @param link_axis_linewidth The linewidth for the axes of the robot links when shown.
   @param link_center_radius The radius of the axis central sphere when shown.
   @param link_center_rgb The RGB values for the central sphere in range [0, 1] when shown.
   @param link_center_alpha The transparency for the central sphere in the range [0, 1] when shown.
   @param display_link_names When true, the names of the robot link are shown.
   @param link_names_scale The size of the link names text when shown.
   @param link_names_rgb The RGB values in range [0, 1] for the robot link names text when shown.
   @param link_names_alpha The transparency in range [0, 1] for the robot link names when shown.
   @return The actors representing the robot.

◆ robot_traj()

def optas.visualize.Visualizer.robot_traj (   self,
  robot_model,
  Q,
  alpha_spec = None,
  show_links = False,
  link_axis_scale = 0.2,
  link_axis_linewidth = 1.0,
  link_center_rgb = 1,
  link_center_alpha = None,
  link_center_radius = 0.01,
  display_link_names = False,
  link_names_scale = [0.01, 0.01, 0.01],
  link_names_rgb = [1, 1, 1],
  link_names_alpha = 1.0,
  animate = False,
  duration = 5.0 
)

Draw a robot through a trajectory.

   @param robot_model The robot model defining the robot kinematics and visuals.
   @param Q Joint configuration trajectory to draw robot.
   @param alpha_spec Transparency specification of the robots in motion.
   @param show_links When true, the robot links are shown.
   @param link_axis_scale The scale for the link axes when shown.
   @param link_axis_linewidth The linewidth for the axes of the robot links when shown.
   @param link_center_radius The radius of the axis central sphere when shown.
   @param link_center_rgb The RGB values for the central sphere in range [0, 1] when shown.
   @param link_center_alpha The transparency for the central sphere in the range [0, 1] when shown.
   @param display_link_names When true, the names of the robot link are shown.
   @param link_names_scale The size of the link names text when shown.
   @param link_names_rgb The RGB values in range [0, 1] for the robot link names text when shown.
   @param link_names_alpha The transparency in range [0, 1] for the robot link names when shown.
   @return The actors representing the robot.

◆ save()

def optas.visualize.Visualizer.save (   self,
  file_name 
)

Save the visualizer window as png image.

Note, saving animations is currently not supported.

◆ set_rgba()

None optas.visualize.Visualizer.set_rgba ( vtk.vtkActor  actor,
ArrayType  rgb,
float  alpha 
)
static

Set the RGB and alpha channels for an actor.

   @param actor A vtk actor object.
   @param rgb The Red-Green-Blue values in range [0, 1].
   @param alpha Transparency of the actor in range [0, 1].

◆ set_tf()

None optas.visualize.Visualizer.set_tf ( vtk.vtkActor  actor,
ArrayType  position,
ArrayType  orientation,
str  euler_seq,
bool  euler_degrees 
)
static

Sets a transform to a vtk Actor.

   @param actor A vtk actor object.
   @param position The position of the transformation.
   @param orientation Orientation of the transformation, either a quaternion or Euler angles.
   @param euler_seq When orientation are Euler angles, specifies sequence of axes for rotations. Up to 3 characters belonging to the set {'X', 'Y', 'Z'} for intrinsic rotations, or {'x', 'y', 'z'} for extrinsic rotations. When orientation are Euler angles, extrinsic and intrinsic rotations cannot be mixed in one function call.
   @param euler_degrees If True, then the given angles are assumed to be in degrees. Default is False.

◆ set_transformation()

None optas.visualize.Visualizer.set_transformation ( vtk.vtkActor  actor,
ArrayType  tf 
)
static

Sets a transformation to a vtk Actor.

   @param actor A vtk actor object.
   @param tf A homogenous transformation matrix.

◆ set_translation()

None optas.visualize.Visualizer.set_translation ( vtk.vtkActor  actor,
ArrayType  translation 
)
static

Set translation for an actor.

   @param actor A vtk actor object.
   @param translation The translation in the global frame.

◆ sphere()

vtk.vtkActor optas.visualize.Visualizer.sphere (   self,
float   radius = 1.0,
ArrayType   position = [0.0, 0.0, 0.0],
Union[None, ArrayType]   rgb = None,
float   alpha = 1.0,
int   theta_resolution = 20,
int   phi_resolution = 20 
)

Draw a sphere.

   @param radius The radius of the sphere.
   @param position The position of the sphere.
   @param rgb The Red-Green-Blue values in range [0, 1].
   @param alpha Transparency of the actor in range [0, 1].
   @param theta_resolution The number of points in the longitude direction.
   @param phi_resolution The number of points in the latitude direction.
   @return The sphere actor.

◆ sphere_traj()

List[vtk.vtkActor] optas.visualize.Visualizer.sphere_traj (   self,
ArrayType  position_traj,
float   radius = 1.0,
Union[None, ArrayType]   rgb = None,
int   theta_resolution = 20,
int   phi_resolution = 20,
Union[None, Dict]   alpha_spec = None,
  animate = False,
  duration = 5.0 
)

Draw a sphere trajectory.

   @param position_traj The position trajectory for the spheres.
   @param radius The radius of the spheres.
   @param rgb The Red-Green-Blue values in range [0, 1].
   @param theta_resolution The number of points in the longitude direction.
   @param phi_resolution The number of points in the latitude direction.
   @param The alpha specification.
   @return The sphere actors.

◆ start()

None optas.visualize.Visualizer.start (   self)

Start the visualizer.

◆ stl()

vtk.vtkActor optas.visualize.Visualizer.stl (   self,
  filename,
  scale = None,
  rgb = None,
  alpha = 1.0,
  position = [0.0, 0.0, 0.0],
  orientation = [0.0, 0.0, 0.0],
  euler_seq = "xyz",
  euler_degrees = False 
)

Load .stl file.

   @param filename The filename for the .stl file.
   @param scale Scale applied to the mesh file in the xyz directions.
   @param rgb The Red-Green-Blue values in range [0, 1].
   @param alpha Transparency of the actor in range [0, 1].
   @param position The position of the object.
   @param orientation Orientation of the object, either a quaternion or Euler angles.
   @param euler_seq When orientation are Euler angles, specifies sequence of axes for rotations. Up to 3 characters belonging to the set {'X', 'Y', 'Z'} for intrinsic rotations, or {'x', 'y', 'z'} for extrinsic rotations. When orientation are Euler angles, extrinsic and intrinsic rotations cannot be mixed in one function call.
   @param euler_degrees If True, then the given angles are assumed to be in degrees. Default is False.
   @return The actor representing the .stl file.

◆ text()

vtk.vtkFollower optas.visualize.Visualizer.text (   self,
str   msg = "Hello, world!",
ArrayType   position = [0.0, 0.0, 0.0],
ArrayType   scale = [1.0, 1.0, 1.0],
Union[None, ArrayType]   rgb = None,
float   alpha = 1.0 
)

Draw text.

   @param msg The text to draw.
   @param position The position to draw the text in the global frame.
   @param scale The size of the text.
   @param rgb The Red-Green-Blue values in range [0, 1].
   @param alpha Transparency of the actor in range [0, 1].
   @return The text actor.

Member Data Documentation

◆ actors

optas.visualize.Visualizer.actors

◆ animate_callbacks

optas.visualize.Visualizer.animate_callbacks

◆ camera

optas.visualize.Visualizer.camera

◆ iren

optas.visualize.Visualizer.iren

◆ ren

optas.visualize.Visualizer.ren

◆ renWin

optas.visualize.Visualizer.renWin

The documentation for this class was generated from the following file: