Skip to content

7. Setting up the environment in Rviz

Rutvik Kevadiya edited this page Aug 8, 2022 · 1 revision

Environment Setup

To recreate the environment of our manipulator, we need to add collision objects which are in our manipulator environment to our move group explained earlier. The collision objects are already of known dimensions so the dimensions have been hard coded while creating the object. But, what if we want take the dimensions from the user?

Run the following command to set up the table and walls in rviz for collision avoidance:

roslaunch ur3e_setup setup.launch dist:=1.0 wid:=2.0

Code Walk Through

Getting user arguments using the launch file

Here, we get the dimensions of the walls(length and width) around the manipulator from the user as arguments in the launch file and use them in our ros node to create the environment. we take these arguments in the launch file. scene_setup is the name of our cpp executable node initlaized by using ros::init(argc, argv, "scene_setup")

<launch>
    <arg name="dist" default="0.5"/>
    <arg name="wid" default="1.05"/>

    <node name="scene_setup" pkg="ur3e_examples" type="scene_setup" output="screen">
        <param name="distance" value="$(arg dist)"/>
        <param name="width" value="$(arg wid)"/>
    </node>
</launch>

In our ros node, we get these arguments by using:

ros::NodeHandle n;
n.getParam("/scene_setup/distance", distance);
n.getParam("/scene_setup/width", width);

Adding collision objects

This has been explained here.