Feature request
There should be a c++ file importable by #include <package_name/action/actionname.hpp> which contains everything needed to use an action type in c++.
Feature description
It needs to be possible to generate a header file that describes an action, and has all the information needed to create topics and services. Since services already are an example of a typesupport that needs to include messages, actions should use the same strategy.
Implementation considerations
Output files
Services have a top level header which includes two files: traits and struct. Traits indicates whether either the request or response is bounded or unbounded in size. I don't think there needs to be a traits file for the whole action.
|
#include "@(spec.pkg_name)/srv/@(get_header_filename_from_msg_name(spec.srv_name))__traits.hpp" |
|
#include "@(spec.pkg_name)/srv/@(get_header_filename_from_msg_name(spec.srv_name))__struct.hpp" |
The struct file includes the request and response message, as well as defines a struct with a using directive that indicates which message is which
|
struct @(spec.srv_name) |
|
{ |
|
using Request = @(spec.pkg_name)::srv::@(spec.srv_name)_Request; |
|
using Response = @(spec.pkg_name)::srv::@(spec.srv_name)_Response; |
|
}; |
The action struct template could look something like this
#include "@(spec.pkg_name)/action/@(get_header_filename_from_msg_name(spec.action_name))__sendgoal.hpp"
#include "@(spec.pkg_name)/action/@(get_header_filename_from_msg_name(spec.action_name))__get_result.hpp"
#include "@(spec.pkg_name)/action/@(get_header_filename_from_msg_name(spec.action_name))__feedback.hpp"
// Convenience include for common service and message definition
#include <rcl_interfaces/srv/cancel_action.hpp>
#include <rcl_interfaces/srv/goal_status.hpp>
struct @(spec.action_name)
{
using SendGoalService = @(spec.pkg_name)::action::@(spec.action_name)_SendGoal;
using GetResultService = @(spec.pkg_name)::action::@(spec.action_name)_GetResult;
using FeedbacMessage = @(spec.pkg_name)::action::@(spec.action_name)_Feedback;
};
CMake targets
The CMake target needs to be aware of the generated output files so that it can rebuild stuff downstream when they change. Awareness of the files generated by .action needs to be included here
|
if(_parent_folder STREQUAL "msg") |
|
list(APPEND _generated_msg_files |
|
"${_output_path}/${_parent_folder}/${_header_name}.hpp" |
|
"${_output_path}/${_parent_folder}/${_header_name}__struct.hpp" |
|
"${_output_path}/${_parent_folder}/${_header_name}__traits.hpp" |
|
) |
|
elseif(_parent_folder STREQUAL "srv") |
|
list(APPEND _generated_srv_files |
|
"${_output_path}/${_parent_folder}/${_header_name}.hpp" |
|
"${_output_path}/${_parent_folder}/${_header_name}__struct.hpp" |
|
"${_output_path}/${_parent_folder}/${_header_name}__traits.hpp" |
|
) |
connects to ros2/ros2#583
Feature request
There should be a c++ file importable by
#include <package_name/action/actionname.hpp>which contains everything needed to use an action type in c++.Feature description
It needs to be possible to generate a header file that describes an action, and has all the information needed to create topics and services. Since services already are an example of a typesupport that needs to include messages, actions should use the same strategy.
Implementation considerations
Output files
Services have a top level header which includes two files:
traitsandstruct. Traits indicates whether either the request or response is bounded or unbounded in size. I don't think there needs to be a traits file for the whole action.rosidl/rosidl_generator_cpp/resource/srv.hpp.em
Lines 22 to 23 in 206dd2b
The struct file includes the request and response message, as well as defines a struct with a
usingdirective that indicates which message is whichrosidl/rosidl_generator_cpp/resource/srv__struct.hpp.em
Lines 31 to 35 in 206dd2b
The action struct template could look something like this
CMake targets
The CMake target needs to be aware of the generated output files so that it can rebuild stuff downstream when they change. Awareness of the files generated by
.actionneeds to be included hererosidl/rosidl_generator_cpp/cmake/rosidl_generator_cpp_generate_interfaces.cmake
Lines 25 to 36 in 206dd2b
connects to ros2/ros2#583