Skip to content

Robot Model Visualization

Indy Description Package

1
2
3
4
5
6
├── indy_description
    ├── urdf
    ├── launch
    ├── rviz_config
    ├── meshes
    └──  ...

The indy_description package includes the model files (URDF) for use with RViz and Gazebo simulator.

Robot Model

URDF (The Universal Robotic Description Format)is an XML-format file describing the kinematic and dynamic elements of the robot. Xacro is an XML macro language that constructs shorter and more readable XML files by using macros that expand to larger XML expressions. In the urdf folder of the indy_description package, There's a config folder which contains all config for Indy models (Indy7, Indy7 V2, Indy12, Indy12 v2, IndyRP, IndyRP V2) The other xacro files read the config files and build the description of the robot.

The diagram below show the relationship of the files

1
2
3
4
5
6
7
joint_limits ────────┐
kinematics ──────────┤
physical_parameters ─┤
visual_parameters ───┴─ indy_common ─┐
                  indy.ros2_control ─┤
                  indy_transmission ─┤
                          materials ─┴─ indy_macro─indy.urdf

For more information about urdf and xacro, please visit ROS2 build model tutorial

Launching RViz

Indy models can be visualized with RViz2. launch file is a file for launching a number of ROS nodes at the same time. The following command is used to launch the robot description and visualization for the Indy7 robot model in ROS2.

By specifying the robot type as "indy7", the launch file will load the appropriate configuration files and launch the necessary nodes to display the robot in a visualization tool like RViz.

1
$ ros2 launch indy_description indy_display.launch.py indy_type:=indy7

Now you should see windows launched.


Launch with indy eye option.

1
$ ros2 launch indy_description indy_display.launch.py indy_type:=indy7 indy_eye:=true


by tweaking the joint position value of joint_states_publisher, the position of the robot in RViz can be changed.

Launch File

The code below is indy_display.launch.py, from the command above.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/python3
#-*- coding: utf-8 -*-

from launch_ros.actions import Node
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch_ros.substitutions import FindPackageShare
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution


def generate_launch_description():
    # Declare arguments
    declared_arguments = []

    declared_arguments.append(
        DeclareLaunchArgument(
            "name",
            default_value="indy"
        )
    )

    declared_arguments.append(
        DeclareLaunchArgument(
            "indy_type",
            default_value="indy7",
            description="Type of Indy robot.",
            choices=["indy7", "indy7_v2" , "indy12", "indy12_v2", "indyrp2", "indyrp2_v2"]
        )
    )

    declared_arguments.append(
        DeclareLaunchArgument(
            "indy_eye",
            default_value="false",
            description="Work with Indy Eye",
        )
    )

    declared_arguments.append(
        DeclareLaunchArgument(
            "prefix",
            default_value='""',
            description="Prefix of the joint names, useful for \
            multi-robot setup. If changed than also joint names in the controllers configuration \
            have to be updated."
        )
    )

    # Initialize Arguments
    name = LaunchConfiguration("name")
    indy_type = LaunchConfiguration("indy_type")
    indy_eye = LaunchConfiguration("indy_eye")
    prefix = LaunchConfiguration("prefix")

    description_package = FindPackageShare('indy_description')

    robot_description_content = Command(
        [
            PathJoinSubstitution([FindExecutable(name="xacro")]),
            " ",
            PathJoinSubstitution([description_package, "urdf", 'indy.urdf.xacro']),
            " ",
            "name:=",
            name,
            " ",
            "indy_type:=",
            indy_type,
            " ",
            "indy_eye:=",
            indy_eye,
            " ",
            "prefix:=",
            prefix
        ]
    )

    robot_description = {"robot_description": robot_description_content}

    rviz_config_file = PathJoinSubstitution(
        [description_package, "rviz_config", "indy.rviz"]
    )

    robot_state_publisher_node = Node(
        package="robot_state_publisher",
        executable="robot_state_publisher",
        output="screen",
        parameters=[robot_description]
    )

    joint_state_publisher_gui_node = Node(
        package='joint_state_publisher_gui',
        executable='joint_state_publisher_gui'
    )

    rviz_node = Node(
        package="rviz2",
        executable="rviz2",
        name="rviz2",
        output="log",
        arguments=["-d", rviz_config_file]
    )

    nodes = [
        joint_state_publisher_gui_node,
        robot_state_publisher_node,
        rviz_node,
    ]

    return LaunchDescription(declared_arguments + nodes)
  • robot_description: Reads indy.urdf.xacro also, It is a parameter for joint_state_publisher node.

  • joint_state_publisher: publishes the joint positions of robot_description, with /joint_states topic.

  • robot_state_publisher: subscribes /joint_states topic, and publishes transform of each link.

  • rviz : launches RViz node, loading rviz configuration file (indy_description/rviz_config/indy.rviz). Subscribes tf published by robot_state_publisher node, and visualizes them.