cmower/optas

Visualizer missing functionality and updates

cmower opened this issue · 0 comments

Currently the following are missing from the visualizer

  • the link names should be optionally displayed
  • currently the user can visualize the robot links, but cannot customize their properties
  • move functions like

    optas/optas/visualize.py

    Lines 19 to 51 in 17f1a18

    def line(start, end, rgb, alpha, linewidth):
    points = vtk.vtkPoints()
    points.InsertNextPoint(*start)
    points.InsertNextPoint(*end)
    line = vtk.vtkLine()
    line.GetPointIds().SetId(0, 0)
    line.GetPointIds().SetId(0, 1)
    lines = vtk.vtkCellArray()
    lines.InsertNextCell(line)
    polydata = vtk.vtkPolyData()
    polydata.SetPoints(points)
    polydata.SetLines(lines)
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputData(polydata)
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    actor.GetProperty().SetLineWidth(linewidth)
    if isinstance(rgb, list):
    assert len(rgb) == 3, f"rgb is incorrect length, got {len(rgb)} expected 3"
    actor.GetProperty().SetColor(*rgb)
    if alpha < 1.0:
    assert alpha >= 0.0, "the scalar alpha must be in the range [0, 1]"
    actor.GetProperty().SetOpacity(alpha)
    return actor
    into the main visualizer class, see #106
  • in

    optas/optas/visualize.py

    Lines 622 to 654 in 17f1a18

    if urdf_link.visual is None:
    continue
    material = urdf_link.visual.material
    rgb = None
    if isinstance(material.name, str) and material.name in material_names:
    rgba = get_material_rgba(urdf_link.visual.material.name)
    rgb = rgba[:3]
    if isinstance(geometry, Mesh):
    if geometry.filename.lower().endswith(".stl"):
    filename = geometry.filename
    if not os.path.exists(filename):
    relpath = robot_model.get_urdf_dirname()
    filename = os.path.join(relpath, filename)
    scale = None
    if geometry.scale is not None:
    scale = geometry.scale
    actors.append(
    stl(
    filename,
    scale=scale,
    rgb=rgb,
    alpha=alpha,
    position=position,
    orientation=orientation,
    euler_seq="xyz",
    euler_degrees=True,
    )
    )
    we potentially miss out other visuals, need to iterate over urdf_link.visuals.
  • Add documentation to visualize.py