API updates for rmw preallocation work (#711)

* API updates for rmw preallocation work.

Signed-off-by: Michael Carroll <michael@openrobotics.org>

* Adjust for allocation in serialized message method.

Signed-off-by: Michael Carroll <michael@openrobotics.org>

* Fix extra take call.

Signed-off-by: Michael Carroll <michael@openrobotics.org>
This commit is contained in:
Michael Carroll 2019-05-02 11:32:35 -05:00 committed by GitHub
parent a8a0788f81
commit 59d59b0c18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View file

@ -158,7 +158,7 @@ public:
// TODO(Karsten1987): support serialized message passed by intraprocess // TODO(Karsten1987): support serialized message passed by intraprocess
throw std::runtime_error("storing serialized messages in intra process is not supported yet"); throw std::runtime_error("storing serialized messages in intra process is not supported yet");
} }
auto status = rcl_publish_serialized_message(&publisher_handle_, serialized_msg); auto status = rcl_publish_serialized_message(&publisher_handle_, serialized_msg, nullptr);
if (RCL_RET_OK != status) { if (RCL_RET_OK != status) {
rclcpp::exceptions::throw_from_rcl_error(status, "failed to publish serialized message"); rclcpp::exceptions::throw_from_rcl_error(status, "failed to publish serialized message");
} }
@ -179,7 +179,7 @@ protected:
void void
do_inter_process_publish(const MessageT * msg) do_inter_process_publish(const MessageT * msg)
{ {
auto status = rcl_publish(&publisher_handle_, msg); auto status = rcl_publish(&publisher_handle_, msg, nullptr);
if (RCL_RET_PUBLISHER_INVALID == status) { if (RCL_RET_PUBLISHER_INVALID == status) {
rcl_reset_error(); // next call will reset error message if not context rcl_reset_error(); // next call will reset error message if not context
if (rcl_publisher_is_valid_except_context(&publisher_handle_)) { if (rcl_publisher_is_valid_except_context(&publisher_handle_)) {
@ -201,7 +201,7 @@ protected:
rcl_interfaces::msg::IntraProcessMessage ipm; rcl_interfaces::msg::IntraProcessMessage ipm;
ipm.publisher_id = intra_process_publisher_id_; ipm.publisher_id = intra_process_publisher_id_;
ipm.message_sequence = message_seq; ipm.message_sequence = message_seq;
auto status = rcl_publish(&intra_process_publisher_handle_, &ipm); auto status = rcl_publish(&intra_process_publisher_handle_, &ipm, nullptr);
if (RCL_RET_PUBLISHER_INVALID == status) { if (RCL_RET_PUBLISHER_INVALID == status) {
rcl_reset_error(); // next call will reset error message if not context rcl_reset_error(); // next call will reset error message if not context
if (rcl_publisher_is_valid_except_context(&intra_process_publisher_handle_)) { if (rcl_publisher_is_valid_except_context(&intra_process_publisher_handle_)) {

View file

@ -304,7 +304,7 @@ Executor::execute_subscription(
auto serialized_msg = subscription->create_serialized_message(); auto serialized_msg = subscription->create_serialized_message();
auto ret = rcl_take_serialized_message( auto ret = rcl_take_serialized_message(
subscription->get_subscription_handle().get(), subscription->get_subscription_handle().get(),
serialized_msg.get(), &message_info); serialized_msg.get(), &message_info, nullptr);
if (RCL_RET_OK == ret) { if (RCL_RET_OK == ret) {
auto void_serialized_msg = std::static_pointer_cast<void>(serialized_msg); auto void_serialized_msg = std::static_pointer_cast<void>(serialized_msg);
subscription->handle_message(void_serialized_msg, message_info); subscription->handle_message(void_serialized_msg, message_info);
@ -320,7 +320,7 @@ Executor::execute_subscription(
std::shared_ptr<void> message = subscription->create_message(); std::shared_ptr<void> message = subscription->create_message();
auto ret = rcl_take( auto ret = rcl_take(
subscription->get_subscription_handle().get(), subscription->get_subscription_handle().get(),
message.get(), &message_info); message.get(), &message_info, nullptr);
if (RCL_RET_OK == ret) { if (RCL_RET_OK == ret) {
subscription->handle_message(message, message_info); subscription->handle_message(message, message_info);
} else if (RCL_RET_SUBSCRIPTION_TAKE_FAILED != ret) { } else if (RCL_RET_SUBSCRIPTION_TAKE_FAILED != ret) {
@ -343,7 +343,8 @@ Executor::execute_intra_process_subscription(
rcl_ret_t status = rcl_take( rcl_ret_t status = rcl_take(
subscription->get_intra_process_subscription_handle().get(), subscription->get_intra_process_subscription_handle().get(),
&ipm, &ipm,
&message_info); &message_info,
nullptr);
if (status == RCL_RET_OK) { if (status == RCL_RET_OK) {
message_info.from_intra_process = true; message_info.from_intra_process = true;