Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Switch take_response and take_request to rmw_service_info_t (#53)
Browse files Browse the repository at this point in the history
* Switch take_response and take_request to rmw_service_info_t

Signed-off-by: Luetkebohle Ingo (CR/AEX3) <ingo.luetkebohle@de.bosch.com>

* line break

Signed-off-by: Karsten Knese <karsten@openrobotics.org>

Co-authored-by: Karsten Knese <karsten@openrobotics.org>
  • Loading branch information
iluetkeb and Karsten1987 committed Apr 24, 2020
1 parent 4e37df3 commit 2a408f8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
14 changes: 9 additions & 5 deletions rosidl_typesupport_connext_c/resource/srv__type_support_c.cpp.em
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static const char * destroy_replier__@(service.namespaced_type.name)(

static bool take_request__@(service.namespaced_type.name)(
void * untyped_replier,
rmw_request_id_t * request_header,
rmw_service_info_t * request_header,
void * untyped_ros_request)
{
using ReplierType = connext::Replier<
Expand Down Expand Up @@ -227,15 +227,17 @@ static bool take_request__@(service.namespaced_type.name)(
}

size_t SAMPLE_IDENTITY_SIZE = 16;
memcpy(&(request_header->writer_guid[0]), request.identity().writer_guid.value, SAMPLE_IDENTITY_SIZE);
memcpy(&(request_header->request_id.writer_guid[0]), request.identity().writer_guid.value, SAMPLE_IDENTITY_SIZE);

request_header->sequence_number = ((int64_t)request.identity().sequence_number.high) << 32 | request.identity().sequence_number.low;
request_header->request_id.sequence_number = ((int64_t)request.identity().sequence_number.high) << 32 | request.identity().sequence_number.low;
request_header->source_timestamp = 0;
request_header->received_timestamp = 0;
return true;
}

static bool take_response__@(service.namespaced_type.name)(
void * untyped_requester,
rmw_request_id_t * request_header,
rmw_service_info_t * request_header,
void * untyped_ros_response)
{
using RequesterType = connext::Requester<
Expand All @@ -260,7 +262,9 @@ static bool take_response__@(service.namespaced_type.name)(
int64_t sequence_number =
(((int64_t)response.related_identity().sequence_number.high) << 32) |
response.related_identity().sequence_number.low;
request_header->sequence_number = sequence_number;
request_header->request_id.sequence_number = sequence_number;
request_header->source_timestamp = 0;
request_header->received_timestamp = 0;

const rosidl_message_type_support_t * ts =
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ typedef struct service_type_support_callbacks_t
// Function to send ROS requests
int64_t (* send_request)(void * requester, const void * ros_request);
// Function to read a ROS request from the wire
bool (* take_request)(void * replier, rmw_request_id_t * request_header, void * ros_request);
bool (* take_request)(void * replier, rmw_service_info_t * request_header, void * ros_request);
// Function to send ROS responses
bool (* send_response)(
void * replier, const rmw_request_id_t * request_header,
const void * ros_response);
// Function to read a ROS response from the wire
bool (* take_response)(void * requester, rmw_request_id_t * request_header, void * ros_response);
bool (* take_response)(
void * requester, rmw_service_info_t * request_header, void * ros_response);
// Function to get the type erased dds request datawriter for the requester
void *
(*get_request_datawriter)(void * untyped_requester);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ ROSIDL_TYPESUPPORT_CONNEXT_CPP_PUBLIC_@(package_name)
bool
take_request__@(service.namespaced_type.name)(
void * untyped_replier,
rmw_request_id_t * request_header,
rmw_service_info_t * request_header,
void * untyped_ros_request);

ROSIDL_TYPESUPPORT_CONNEXT_CPP_PUBLIC_@(package_name)
bool
take_response__@(service.namespaced_type.name)(
void * untyped_requester,
rmw_request_id_t * request_header,
rmw_service_info_t * request_header,
void * untyped_ros_response);

ROSIDL_TYPESUPPORT_CONNEXT_CPP_PUBLIC_@(package_name)
Expand Down
14 changes: 9 additions & 5 deletions rosidl_typesupport_connext_cpp/resource/srv__type_support.cpp.em
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ const char * destroy_replier__@(service.namespaced_type.name)(

bool take_request__@(service.namespaced_type.name)(
void * untyped_replier,
rmw_request_id_t * request_header,
rmw_service_info_t * request_header,
void * untyped_ros_request)
{
using ReplierType = connext::Replier<
Expand Down Expand Up @@ -317,15 +317,17 @@ bool take_request__@(service.namespaced_type.name)(
}

size_t SAMPLE_IDENTITY_SIZE = 16;
memcpy(&(request_header->writer_guid[0]), request.identity().writer_guid.value, SAMPLE_IDENTITY_SIZE);
memcpy(&(request_header->request_id.writer_guid[0]), request.identity().writer_guid.value, SAMPLE_IDENTITY_SIZE);

request_header->sequence_number = ((int64_t)request.identity().sequence_number.high) << 32 | request.identity().sequence_number.low;
request_header->request_id.sequence_number = ((int64_t)request.identity().sequence_number.high) << 32 | request.identity().sequence_number.low;
request_header->source_timestamp = 0;
request_header->received_timestamp = 0;
return true;
}

bool take_response__@(service.namespaced_type.name)(
void * untyped_requester,
rmw_request_id_t * request_header,
rmw_service_info_t * request_header,
void * untyped_ros_response)
{
using RequesterType = connext::Requester<
Expand Down Expand Up @@ -353,7 +355,9 @@ bool take_response__@(service.namespaced_type.name)(
int64_t sequence_number =
(((int64_t)response.related_identity().sequence_number.high) << 32) |
response.related_identity().sequence_number.low;
request_header->sequence_number = sequence_number;
request_header->request_id.sequence_number = sequence_number;
request_header->source_timestamp = 0;
request_header->received_timestamp = 0;

bool converted =
@(__ros_srv_pkg_prefix)::typesupport_connext_cpp::convert_dds_message_to_ros(response.data(), ros_response);
Expand Down

0 comments on commit 2a408f8

Please sign in to comment.