# ROS2 c++ project part 3 calling action server

**URL:** <https://get-help.theconstruct.ai/t/ros2-c-project-part-3-calling-action-server/19026>\
**Category:** ROS2 in 5 Days C++\
**Created:** [September 2, 2022, 8:39pm UTC](https://get-help.theconstruct.ai/t/ros2-c-project-part-3-calling-action-server/19026 "2022-09-02T20:39:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![reallen](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/r/b19c9b/32.png) [@reallen](https://get-help.theconstruct.ai/u/reallen)\
**Post date:** [September 2, 2022, 8:39pm UTC](https://get-help.theconstruct.ai/t/ros2-c-project-part-3-calling-action-server/19026/1 "2022-09-02T20:39:00Z")

</div>

I’m currently on part 3 of the rosject that’s focused on actions. I was able to build the package with no errors, but I get this when I try to send a goal to the action server. Note: I understand that my code may not be functional, but I can’t decipher this error message in order to figure out where to start debugging. Any advice is appreciated

```auto
user:~/ros2_ws$ ros2 action send_goal /odom_action_server ros2_project/action/OdomRecord "{}"
Traceback (most recent call last):
  File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_py/import_type_support_impl.py", line 46, in import_type_support
    return importlib.import_module(module_name, package=pkg_name)
  File "/usr/lib/python3.8/importlib/ __init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 657, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 556, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1166, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: /home/user/ros2_ws/install/ros2_project/lib/libros2_project __rosidl_generator_c.so: undefined symbol: geometry_msgs__ msg __Point32__ Sequence__init

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/ros/foxy/bin/ros2", line 11, in <module>
    load_entry_point('ros2cli==0.9.9', 'console_scripts', 'ros2')()
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2cli/cli.py", line 67, in main
    rc = extension.main(parser=parser, args=args)
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2action/command/action.py", line 37, in main
    return extension.main(args=args)
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2action/verb/send_goal.py", line 54, in main
    return send_goal(args.action_name, args.action_type, args.goal, feedback_callback)
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2action/verb/send_goal.py", line 95, in send_goal
    action_client = ActionClient(node, action_module, action_name)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/action/client.py", line 148, in __init__
    check_for_type_support(action_type)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/type_support.py", line 29, in check_for_type_support
    msg_type. __class__. __import_type_support__ ()
  File "/home/user/ros2_ws/install/ros2_project/lib/python3.8/site-packages/ros2_project/action/_odom_record.py", line 1162, in __import_type_support__
    module = import_type_support('ros2_project')
  File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_py/import_type_support_impl.py", line 48, in import_type_support
    raise UnsupportedTypeSupport(pkg_name)
rosidl_generator_py.import_type_support_impl.UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'ros2_project'
Exception ignored in: <function ActionClient. __del__ at 0x7f972d44b040>
Traceback (most recent call last):
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/action/client.py", line 596, in __del__
    self.destroy()
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/action/client.py", line 587, in destroy
    if self._client_handle is None:
AttributeError: 'ActionClient' object has no attribute '_client_handle'

```

Here’s my code:

```auto
# scrubbed

```

---

<div class="post-metadata">

**Author:** ![reallen](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/r/b19c9b/32.png) [@reallen](https://get-help.theconstruct.ai/u/reallen)\
**Post date:** [September 2, 2022, 9:14pm UTC](https://get-help.theconstruct.ai/t/ros2-c-project-part-3-calling-action-server/19026/2 "2022-09-02T21:14:31Z")

</div>

Cmake:

```auto
# scrubbed

```

---

<div class="post-metadata">

**Author:** ![reallen](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/r/b19c9b/32.png) [@reallen](https://get-help.theconstruct.ai/u/reallen)\
**Post date:** [September 2, 2022, 9:14pm UTC](https://get-help.theconstruct.ai/t/ros2-c-project-part-3-calling-action-server/19026/3 "2022-09-02T21:14:53Z")

</div>

package:

```auto
# scrubbed

```

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [September 5, 2022, 9:01am UTC](https://get-help.theconstruct.ai/t/ros2-c-project-part-3-calling-action-server/19026/4 "2022-09-05T09:01:35Z")

</div>

Are you doing the Python or C++ part of the project? Are you familiar with C++?

The error messages are point pointing to `rclpy` - the Python API. I suggest you go with the Python version if you are not that familiar with C++.

---

<div class="post-metadata">

**Author:** ![reallen](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/r/b19c9b/32.png) [@reallen](https://get-help.theconstruct.ai/u/reallen)\
**Post date:** [September 5, 2022, 5:24pm UTC](https://get-help.theconstruct.ai/t/ros2-c-project-part-3-calling-action-server/19026/5 "2022-09-05T17:24:32Z")

</div>

could you elaborate on this? This is for the c++ ros2 course, I don’t recall there being anything python related except for the launch files…

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [September 6, 2022, 4:22pm UTC](https://get-help.theconstruct.ai/t/ros2-c-project-part-3-calling-action-server/19026/6 "2022-09-06T16:22:32Z")

</div>

The error messages seem to suggest that your code has been written in Python.

I’ll ask one of our C++ experts (@rzegers) to have a look.

---

<div class="post-metadata">

**Author:** ![rzegers](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/rzegers/32/7010_2.png) [@rzegers](https://get-help.theconstruct.ai/u/rzegers)\
**Post date:** [September 7, 2022, 8:26am UTC](https://get-help.theconstruct.ai/t/ros2-c-project-part-3-calling-action-server/19026/7 "2022-09-07T08:26:50Z")

</div>

Hi @reallen,

my first guess is that there might be something wrong with the command you are executing (`ros2 action send_goal /odom_action_server ros2_project/action/OdomRecord "{}"`) rather than the code itself, but I might be as well wrong.

Regardless let’s start there, confirming that the command is correct.

To recap, the structure of the command is the following:  
`ros2 action send_goal <action_name> <action_type> <values>`

So for confirming that the values are correct please run this command:  
`ros2 action list -t`  
Verify that you can find the action that you want to call in the list. Please compare the action name and action type with the ones that you are using (in brackets to the right of each action name is the action type).

Also please post the output here.

Finally please also verify that the structure of the action values is correct.  
To do so enter the following command with the action type in your terminal:  
`ros2 interface show <action_type>`  
then post the output here.

Cheers,

Roberto

---

<div class="post-metadata">

**Author:** ![reallen](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/r/b19c9b/32.png) [@reallen](https://get-help.theconstruct.ai/u/reallen)\
**Post date:** [September 7, 2022, 10:19pm UTC](https://get-help.theconstruct.ai/t/ros2-c-project-part-3-calling-action-server/19026/8 "2022-09-07T22:19:26Z")

</div>

So I’ve made a few changes since I posted this. Originally, I had created my custom action interface in the same package where I wrote my action server (ros2\_project). Since then, I created a custom interface package to see if that could fix the error that I was initially having. I’m still running into the same problem when I run a command similar to the one from before.

```auto
user:~$ ros2 action list
/record_odom
user:~$ ros2 action list -t
/record_odom [project_action_msgs/action/OdomRecord]
user:~$ ros2 action send_goal /record_odom
--feedback project_action_msgs/action/OdomRecord
-f
user:~$ ros2 action send_goal /record_odom project_action_msgs/action/OdomRecord "{}"
Traceback (most recent call last):
  File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_py/import_type_support_impl.py", line 46, in import_type_support
    return importlib.import_module(module_name, package=pkg_name)
  File "/usr/lib/python3.8/importlib/ __init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 657, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 556, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1166, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: /home/user/ros2_ws/install/project_action_msgs/lib/libproject_action_msgs __rosidl_generator_c.so: undefined symbol: geometry_msgs__ msg __Point32__ Sequence__init

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/ros/foxy/bin/ros2", line 11, in <module>
    load_entry_point('ros2cli==0.9.9', 'console_scripts', 'ros2')()
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2cli/cli.py", line 67, in main
    rc = extension.main(parser=parser, args=args)
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2action/command/action.py", line 37, in main
    return extension.main(args=args)
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2action/verb/send_goal.py", line 54, in main
    return send_goal(args.action_name, args.action_type, args.goal, feedback_callback)
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2action/verb/send_goal.py", line 95, in send_goal
    action_client = ActionClient(node, action_module, action_name)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/action/client.py", line 148, in __init__
    check_for_type_support(action_type)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/type_support.py", line 29, in check_for_type_support
    msg_type. __class__. __import_type_support__ ()
  File "/home/user/ros2_ws/install/project_action_msgs/lib/python3.8/site-packages/project_action_msgs/action/_odom_record.py", line 1162, in __import_type_support__
    module = import_type_support('project_action_msgs')
  File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_py/import_type_support_impl.py", line 48, in import_type_support
    raise UnsupportedTypeSupport(pkg_name)
rosidl_generator_py.import_type_support_impl.UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'project_action_msgs'
Exception ignored in: <function ActionClient. __del__ at 0x7f3fe544ff70>
Traceback (most recent call last):
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/action/client.py", line 596, in __del__
    self.destroy()
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/action/client.py", line 587, in destroy
    if self._client_handle is None:
AttributeError: 'ActionClient' object has no attribute '_client_handle'
user:~$

```

And this is the custom interface:

```auto
user:~$ ros2 interface show project_action_msgs/action/OdomRecord

---
geometry_msgs/Point32[] list_of_odoms
---
float32 current_total

```

Thanks for the prompt reply, btw!

---

<div class="post-metadata">

**Author:** ![rzegers](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/rzegers/32/7010_2.png) [@rzegers](https://get-help.theconstruct.ai/u/rzegers)\
**Post date:** [September 8, 2022, 8:48am UTC](https://get-help.theconstruct.ai/t/ros2-c-project-part-3-calling-action-server/19026/9 "2022-09-08T08:48:25Z")

</div>

Hello @reallen, thanks for posting those command outputs.  
Now let us introspect this line here:  
` ImportError: /home/user/ros2_ws/install/project_action_msgs/lib/libproject_action_msgs __rosidl_generator_c.so: undefined symbol: geometry_msgs__ msg __Point32__ Sequence__init`

From my understanding “undefined symbol” generally means that the symbol shown can’t be found in any of the linked libraries.

Please verify that you have declared the dependency inside `package.xml`:

```auto
<depend>geometry_msgs</depend>

```

And in CMakeLists.txt:

```auto
find_package(geometry_msgs REQUIRED)

rosidl_generate_interfaces(${PROJECT_NAME}
  <write_msg_file_here>
  DEPENDENCIES geometry_msgs)

```

Also make sure you export the message runtime dependency:

`ament_export_dependencies(rosidl_default_runtime)`

Finally you also need to include the header of `Point32.msg` in your source code file:

`#include "geometry_msgs/msg/point32.hpp"`

Could you please confirm and verify with your code?

Regards,

Roberto

---

<div class="post-metadata">

**Author:** ![reallen](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/r/b19c9b/32.png) [@reallen](https://get-help.theconstruct.ai/u/reallen)\
**Post date:** [September 8, 2022, 9:21pm UTC](https://get-help.theconstruct.ai/t/ros2-c-project-part-3-calling-action-server/19026/10 "2022-09-08T21:21:59Z")

</div>

Hi Roberto, so it seems that I was missing the

> DEPENDENCIES geometry\_msgs

in the “rosidl\_generate\_interfaces” function. I don’t think it was mentioned in the action servers chapter of the course that you needed to add the dependencies of the action interface file if you’re not using the standard messages. But I might be mistaken.

And same case for the function:

> ament\_export\_dependencies(rosidl\_default\_runtime)

(Could you explain what ^ does?)  
I added those two lines to the CMake and everything works now. Thanks!

---

<div class="post-metadata">

**Author:** ![rzegers](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/rzegers/32/7010_2.png) [@rzegers](https://get-help.theconstruct.ai/u/rzegers)\
**Post date:** [September 9, 2022, 7:49am UTC](https://get-help.theconstruct.ai/t/ros2-c-project-part-3-calling-action-server/19026/11 "2022-09-09T07:49:16Z")

</div>

Hi @reallen,

I am glad you got it solved!

The `rosidl_default_runtime` package is needed for code generation of ROS messages at runtime. Specifically it gathers dependencies for all runtime related dependencies of ROS interface files (.idl). Your packages depends on `geometry_msgs` in order to generate its own message type. You use `ament_export_dependencies(rosidl_default_runtime)` so that ros2cli package (the one that you use for sending ros2 commands via the command line) knows where the `point32.hpp` header files are too. So basically it is needed for resolving dependencies.

I will check the course to see if this needs to be added.

Cheers,

Roberto
