ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Please tell me the meaning of the description in the launch file

asked 2023-01-03 13:11:35 -0500

Renox gravatar image

updated 2023-01-03 13:13:01 -0500

I couldn't understand the meaning of the following description(value) in the launch file. I couldn't understand a description that combines eval, if and else.

<arg name="uf_traj_controller" value="$(eval 'lite6_traj_controller_velocity' if arg('velocity_control') else 'lite6_traj_controller')" />

Please tell me the meaning of description of value.

A part of launch file

<launch>   
  <arg name="run_demo_traj" default="false"/>
  <arg name="effort_control" default="false"/>
  <arg name="velocity_control" default="false"/>
  <arg name="namespace" default="ufactory"/>
  <arg name="add_gripper" default="false" />

  <!-- Load joint controller configurations from YAML file to parameter server -->
  <!-- Load trajectory controller for xArm by default -->
  <rosparam unless="$(arg run_demo_traj)" file="$(find xarm_controller)/config/lite6_traj_controller.yaml" command="load" ns="$(arg namespace)"/>
  <arg name="uf_traj_controller" value="$(eval 'lite6_traj_controller_velocity' if arg('velocity_control') else 'lite6_traj_controller')" />
  <node unless="$(arg run_demo_traj)"
    name="traj_controller_spawner"
    pkg="controller_manager"
    type="controller_manager"
    respawn="false"
    output="screen"
    ns="/$(arg namespace)"
    args="spawn $(arg uf_traj_controller) joint_state_controller"/>

  <!-- run_demo: load the position controllers -->
  <rosparam if="$(arg run_demo_traj)"
    file="$(find xarm_controller)/config/lite6_position_controllers.yaml" command="load" ns="$(arg namespace)"/>
  <node if="$(arg run_demo_traj)" name="position_controller_spawner"
    pkg="controller_manager"
    type="spawner"
    respawn="false"
    output="screen"
    ns="/$(arg namespace)"
    args="joint1_position_controller joint2_position_controller
          joint3_position_controller joint4_position_controller
          joint5_position_controller joint6_position_controller
          joint_state_controller"/>


</launch>
edit retag flag offensive close merge delete

Comments

if arg('velocity_control') else ...

I didn't test it, but I do not think this reads the variable. I'd have written it: $(arg velocity_control)

Update: nope, looks like I'm wrong. According to https://wiki.ros.org/roslaunch/XML inside an eval the syntax is different, so this will work.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2023-01-07 10:21:43 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2023-01-14 11:46:09 -0500

Renox gravatar image

My question solved. When I run the following command,

roslaunch xarm_gazebo lite6_beside_table.launch

I got the following result.

Started ['lite6_traj_controller'] successfully
Started ['joint_state_controller'] successfully

When I run the following command,

roslaunch xarm_gazebo lite6_beside_table.launch velocity_control:=true

I got the following result.

Started ['lite6_traj_controller_velocity'] successfully
Started ['joint_state_controller'] successfully

Thank you for your reply.

edit flag offensive delete link more
1

answered 2023-01-04 02:19:16 -0500

Vic gravatar image

updated 2023-01-04 02:21:47 -0500

Let's look at the top of the file

 <arg name="velocity_control" default="false"/>

I think that if you launch with a "velocity_control" at value true, your controller launched will be "lite6_trajectory_controller_velocity", but a default launch will launch "lite6_trajectory_controller"

Your value is evaluated according to the condition, thus mixing eval, if and else

edit flag offensive delete link more

Comments

1

Thank you for your reply. At first, I thought that if I input velocity_controller at value true, "lite6_traj_controller_velocty" in "lite6_traj_controller.yaml" will launch.

But your description is that if "velocity_controller" at value default(=false), lite6_traj_controller_velocity will launch, not "lite6_traj_controller(position_controllers/JointTrajectoryController)".

I feel conflicted now....(velocity_controller true, but position_controllers/JTC launch?)

A part of "lite6_traj_controller.yaml"

joint_state_controller:
  type: joint_state_controller/JointStateController
  <abbreviation>
lite6_traj_controller:
  type: position_controllers/JointTrajectoryController
  <abbreviation>
lite6_traj_controller_velocty:
  type: velocity_controllers/JointTrajectoryController
  <abbreviation>
Renox gravatar image Renox  ( 2023-01-04 03:53:51 -0500 )edit

Well, code doesn't lie, sometime our interpretation does. Do you have the possibility to launch the system with and without argument, and list controllers launched to check which one is running?

Vic gravatar image Vic  ( 2023-01-04 03:58:24 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2023-01-03 13:11:35 -0500

Seen: 92 times

Last updated: Jan 14 '23