ROS2 C++ Part 3 Action Client Implementation

Hello

I am currently doing part 3 of the C++ ROS2 Project.

To have a better readability, I would like to separate my action client from my wall follower file.

So I have a file called “odometry_action_client.cpp” where all the things regarding goal, feedback and results are.

And I want to start it from my “follow_wall.cpp” file.

So I imagined, that I have to include my odometry_action_client.cpp as a header into my follow_wall file and then there start the action client.

So I added the following into my follow_wall file:

{

#include "my_ros2ject/src/odometry_action_client.hpp"
......
int main(int argc, char * argv[])
{
  //Start Action Client
  auto action_client = std::make_shared<OdometryActionClient>("odometry_action_client");
  action_client->start();
}

}

And I did the following adjustments in the cMakeList.txt

{
rosidl_generate_interfaces(${PROJECT_NAME}
  "srv/FindWall.srv"
  "action/OdomRecord.action"
  DEPENDENCIES geometry_msgs)

ament_package()

add_executable(follow_wall_node src/follow_wall.cpp)
ament_target_dependencies(follow_wall_node rclcpp std_msgs geometry_msgs sensor_msgs my_ros2ject rosidl_default_runtime)

......

add_executable(odometry_action_client_node src/odometry_action_client.cpp)
ament_target_dependencies(odometry_action_client_node rclcpp rclcpp_action std_msgs nav_msgs geometry_msgs sensor_msgs my_ros2ject)

install(TARGETS
   follow_wall_node
   find_wall_node
   odom_record_action_server_node
   odometry_action_client_node
   DESTINATION lib/${PROJECT_NAME}
 )

}

So I now have the problem that when I compile I get the following error message:

{
/home/user/ros2_ws/src/my_ros2ject/src/follow_wall.cpp:19:10: fatal error: my_ros2ject/src/odometry_action_client.hpp: No such file or directory
   19 | #include "my_ros2ject/src/odometry_action_client.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

}

Therefore it can not find and execute the action client. Does somebody know how to correclty include the odometry_action_client.cpp and how to probably start it?

Thanks for the help in advance.

Cheers

Hi, maybe the path of #include is wrong? try doing an absolute path