ROS2 Basics in 5 Days Humble (C++) - Action Quiz [goal via command is not working]

Hi

I just finished my action quiz and something happened. The server and client work correctly, but when I try to create the client through commands, it doesn’t work, what’s more, my meta variable “seconds” doesn’t even appear when I press [TAB] + [TAB].

  user:~$ ros2 action send_goal -f /distance_as actions_quiz_msg/action/Distance
  .__bashrc                  .config/                   .ros/
  .bash_aliases              .gazebo/                   .rviz/
  .bashrc                    .history                   .sdformat/
  .bashrc_bridge             .ignition/                 .sudo_as_admin_successful
  .bashrc_ros1               .labelImg/                 .theia/
  .bashrc_ros2               .npmrc                     .yarn/
  .cache/                    .py3venv                   ros2_ws/
  .catkin_ws_python3         .pylintrc
  .clangd                    .python3_ws

And when I try to send feedback is similar, this is the message that appears.

  user:~$ ros2 action send_goal -f /distance_as actions_quiz_msg/action/Distance  "{seconds: 10}"
  The passed action type is invalid

Everything works well except the command

That’s my Distance.action

  # goal
  int32 seconds
  ---
  # result
  bool status
  float64 total_dist
  ---
  # feedback
  float64 current_dist

Some advice?

Hi @Voltedge ,

The general form of command to perform an action in ROS2 is like:

ros2 action send_goal --feedback <action_server_name> <action_interface_type> <action_goal_data>

(-f is same as --feedback, I use the longer version)
TAB+TAB only works when all the arguments till the cursor position where you hit TAB+TAB are correct. If one of the previous arguments are wrong, TAB+TAB will not work.

If the interface data is not showing up, the only possible reason, I believe, would be that the action interface is not compiled properly.

Does the action interface show up when you do ros2 interface list ?
If it does not, then the action command will not work.
Build the custom action message properly and then try the action command again.
That should fix the problem.

Regards,
Girish

EDIT: Also make sure that you source your install directory from the terminal you call the action. Not sourcing will also not produce the action interface data for TAB+TAB autocompletion.

Hi @girishkumar.kannan

Is that okay? action_quiz_msg appears con actions, services and my install has a actions_quiz_msg package.

ros2 interface list

image

image

image

Another try with [TAB] + [TAB]

  user:~$ ros2 action send_goal
  --feedback      -f              /distance_as    /move_robot_as
  user:~$ ros2 action send_goal --feedback
  --feedback      -f              /distance_as    /move_robot_asuser:~$ ros2 action send_goal --feedback
  --feedback      -f              /distance_as    /move_robot_asuser:~$ ros2 action send_goal --feedback 
  user:~$ ros2 action send_goal --feedback /distance_as actions_quiz_msg/action/Distance
  .__bashrc                  .config/                   .ros/
  .bash_aliases              .gazebo/                   .rviz/
  .bashrc                    .history                   .sdformat/
  .bashrc_bridge             .ignition/                 .sudo_as_admin_successful
  .bashrc_ros1               .labelImg/                 .theia/
  .bashrc_ros2               .npmrc                     .yarn/
  .cache/                    .py3venv                   ros2_ws/
  .catkin_ws_python3         .pylintrc
  .clangd                    .python3_ws

  user:~$ ros2 action send_goal --feedback /distance_as actions_quiz_msg/action/Distance "{seconds:10}"
  The passed action type is invalid

The TAB+TAB just doesn´t work with action_goal_data

  user:~/ros2_ws$ colcon build --packages-select actions_quiz_msg
  Starting >>> actions_quiz_msg
  Finished <<< actions_quiz_msg [0.46s]
  
  Summary: 1 package finished [0.66s]

Hi @Voltedge ,

Did you do source install/setup.bash (from ~/ros2_ws) before calling
ros2 action send_goal ...?

– Girish

Hi @girishkumar.kannan

Yes.

user:~/ros2_ws$ source install/setup.bash
user:~/ros2_ws$ ros2 action send_goal --feedback /distance_as actions_quiz_msg/action/Distance "{seconds: 10}"
The passed action type is invalid
user:~/ros2_ws$

Hi @Voltedge ,

Ok. That is so strange! Try these step by step:

Close all programs.
Restart all the four webshells by clicking on the red X button on each tab.
Delete your build, install and log folders
Rebuild your packages using

cd ~/ros2_ws
colcon build && source install/setup.bash

Start the action server in webshell 1 if not already running
Source your install directory again and call action from webshell 2.

This time it should work. If it does not then let me know!

Regards,
Girish

Hi @girishkumar.kannan

I attach the shells, I deleted the packages install, log and build by hand

SHELL 1:

 user:~/ros2_ws$ colcon build
  Starting >>> actions_quiz_msg
  [0.708s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/services_quiz' in the environment variable AMENT_PREFIX_PATH doesn't exist
  [0.708s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/services_quiz_srv' in the environment variable AMENT_PREFIX_PATH doesn't exist
  [0.708s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/actions_quiz' in the environment variable AMENT_PREFIX_PATH doesn't exist
  [0.708s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/radio_shack' in the environment variable AMENT_PREFIX_PATH doesn't exist
  [0.709s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/my_action_server' in the environment variable AMENT_PREFIX_PATH doesn't exist
  [0.709s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/my_action_client' in the environment variable AMENT_PREFIX_PATH doesn't exist
  [0.709s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/user/ros2_ws/install/actions_quiz_msg' in the environment variable AMENT_PREFIX_PATH doesn't exist
  [0.709s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/services_quiz' in the environment variable CMAKE_PREFIX_PATH doesn't exist
  [0.709s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/services_quiz_srv' in the environment variable CMAKE_PREFIX_PATH doesn't exist
  [0.709s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/actions_quiz' in the environment variable CMAKE_PREFIX_PATH doesn't exist
  [0.710s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/radio_shack' in the environment variable CMAKE_PREFIX_PATH doesn't exist
  [0.710s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/my_action_server' in the environment variable CMAKE_PREFIX_PATH doesn't exist
  [0.710s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/my_action_client' in the environment variable CMAKE_PREFIX_PATH doesn't exist
  [0.710s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/user/ros2_ws/install/actions_quiz_msg' in the environment variable CMAKE_PREFIX_PATH doesn't exist
  Starting >>> radio_shack
  Starting >>> services_quiz_srv
  Starting >>> my_action_client
  Starting >>> my_action_server
  Finished <<< my_action_client [27.0s]
  Finished <<< my_action_server [31.6s]
  Finished <<< radio_shack [33.7s]
  Finished <<< services_quiz_srv [34.4s]
  Starting >>> services_quiz
  Finished <<< actions_quiz_msg [34.8s]
  Starting >>> actions_quiz
  Finished <<< services_quiz [18.5s]
  Finished <<< actions_quiz [30.1s]
  
  Summary: 7 packages finished [1min 5s]
  user:~/ros2_ws$ source install/setup.bash
  user:~/ros2_ws$ ros2 launch actions_quiz actions_quiz_server.launch.py
  [INFO] [launch]: All log files can be found below /home/user/.ros/log/2023-01-12-18-35-19-738510-4_xterm-7965
  [INFO] [launch]: Default logging verbosity is set to INFO
  [INFO] [action_server-1]: process started with pid [7966]

SHELL 2:

    user:~$ ros2 action list
    /distance_as
    /move_robot_as
    user:~$ ros2 action send_goal
    --feedback      -f              /distance_as    /move_robot_as
    user:~$ ros2 action send_goal /distance_as actions_quiz_msg/action/Distance
    .__bashrc                  .clangd                    .python3_ws
    .bash_aliases              .config/                   .ros/
    .bash_history              .gazebo/                   .rviz/
    .bashrc                    .history                   .sdformat/
    .bashrc_bridge             .ignition/                 .sudo_as_admin_successful
    .bashrc_ros1               .labelImg/                 .theia/
    .bashrc_ros2               .npmrc                     .yarn/
    .cache/                    .py3venv                   ros2_ws/
    .catkin_ws_python3         .pylintrc
    user:~$ ros2 action send_goal /distance_as actions_quiz_msg/action/Distance "{seconds: 10}"
    The passed action type is invalid

Still not working

Hi @Voltedge ,

You can ignore the warnings in shell 1.

It seems you did not source install directory on shell 2. But if you did source and you still get this error, then you should probably close the course and reopen after sometime, like after 30 minutes. Perhaps things would be back to normal then.

Sorry I could not help much with this particular case.

Regards,
Girish

Hi @girishkumar.kannan

I was waiting until now and still not working :confused:

Thanks for your advices.

I guess I communicate with The Construct team?

Hi @Voltedge ,

I think this would be your next step!

Regards,
Girish

Hello @Voltedge ,

Just tested this and it’s working of for me, with autocompletion and everything:

Are you still having this issue?

1 Like

Hi @albertoezquerro

Not anymore! It works, thanks!