Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement QoS: liveliness, deadline, lifespan #171

Merged
merged 30 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7670c01
initial qos interface changes
mm318 Feb 27, 2019
e80a7b8
add creation of event waitable type
mm318 Feb 28, 2019
d2b076d
Add rmw take_event interface
ross-desmond Mar 4, 2019
8402cfe
add rmw event type enum
mm318 Mar 11, 2019
67880eb
Modify events type from void** to rmw_event_t**
ross-desmond Mar 12, 2019
6dbe51b
fix lint errors
mm318 Mar 15, 2019
3c84836
Added RMW QoS Event Definitions
dabonnie Mar 15, 2019
92c3025
Added RMW QoS Event Definitions
dabonnie Mar 15, 2019
3fe8f64
Code formatting fixes
dabonnie Mar 20, 2019
5c7a011
Change liveliness policy types to reflect actual settings
Mar 21, 2019
4a732ef
Comment out types of liveliness that will not be supported in this it…
Mar 26, 2019
41dac48
Re-enable manual liveliness, name to by_node
Mar 26, 2019
25db919
Fixed style issues
dabonnie Mar 27, 2019
d764efa
Removed extra QoS types
dabonnie Mar 27, 2019
5957a92
add an invalid enum in rmw_event_type_t for variables to default to
mm318 Mar 28, 2019
a0966fe
change rmw_event_t APIs from create()/destroy() to init()/fini() pattern
mm318 Mar 28, 2019
4cfb7a7
Move rmw_*_event_init implementation to rmw
ross-desmond Mar 28, 2019
f43f029
Fix uncrustify divergence in event.c
ross-desmond Mar 29, 2019
8987226
Remove erroneous rmw_delete_event
ross-desmond Mar 29, 2019
502f1b7
Added missing documentation
dabonnie Mar 29, 2019
77bd82a
Implement QoS: liveliness, deadline, lifespan
ross-desmond Mar 29, 2019
87c25fe
Edited added struct names for consistency
dabonnie Apr 1, 2019
c6cb6ea
add assert_liveliness() APIs
mm318 Apr 2, 2019
abf625c
address comments in PR (github.com/aws-robotics/rmw/pull/4)
mm318 Apr 2, 2019
c227f0b
Edited documentation to account for unexpected errors
dabonnie Apr 2, 2019
a3475f1
modify doc string regarding the requirement of asserting liveliness
mm318 Apr 2, 2019
182bf2d
Edit documentation block to fix linting errors
dabonnie Apr 2, 2019
57f926e
Addressed documentation issues found in review
dabonnie Apr 10, 2019
fedaaa8
Merge remote-tracking branch 'origin/master'
mm318 Apr 16, 2019
93b740c
Merge in 'ros2/master'
mm318 May 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rmw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ include_directories(include)
set(rmw_sources
"src/allocators.c"
"src/convert_rcutils_ret_to_rmw_ret.c"
"src/event.c"
"src/init.c"
"src/init_options.c"
"src/names_and_types.c"
Expand Down
128 changes: 128 additions & 0 deletions rmw/include/rmw/event.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// Copyright 2019 Open Source Robotics Foundation, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RMW__EVENT_H_
#define RMW__EVENT_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include <stdint.h>

#include "rcutils/allocator.h"

#include "rmw/macros.h"
#include "rmw/types.h"
#include "rmw/ret_types.h"
#include "rmw/visibility_control.h"

/// Define QoS policy events
typedef enum rmw_event_type_t
{
// subscription events
RMW_EVENT_LIVELINESS_CHANGED,
RMW_EVENT_REQUESTED_DEADLINE_MISSED,

// publisher events
RMW_EVENT_LIVELINESS_LOST,
RMW_EVENT_OFFERED_DEADLINE_MISSED,

// sentinel value
RMW_EVENT_INVALID
} rmw_event_type_t;

/// Encapsulate the RMW event implementation, data, and type.
typedef struct RMW_PUBLIC_TYPE rmw_event_t
{
/// Implementation identifier, used to ensure two different implementations are not being mixed.
const char * implementation_identifier;
/// Data specific to this event type from either the publisher or subscriber.
void * data;
/// The event type that occurred.
rmw_event_type_t event_type;
} rmw_event_t;

/// Return a zero initialized event structure.
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_event_t
rmw_get_zero_initialized_event(void);

/// Initialize a rmw publisher event.
/**
* \param[in|out] rmw_event to initialize
* \param publisher to initialize with
* \param event_type for the event to handle
* \return `RMW_RET_OK` if successful, or
* \return `RMW_RET_INVALID_ARGUMENT` if invalid argument
ross-desmond marked this conversation as resolved.
Show resolved Hide resolved
* \return `RMW_RET_ERROR` if an unexpected error occurs.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_publisher_event_init(
rmw_event_t * rmw_event,
const rmw_publisher_t * publisher,
rmw_event_type_t event_type);

/// Initialize a rmw subscription event.
/**
* \param[in|out] rmw_event to initialize
* \param subscription to initialize with
* \param event_type for the event to handle
* \return `RMW_RET_OK` if successful, or
* \return `RMW_RET_INVALID_ARGUMENT` if invalid argument
* \return `RMW_RET_ERROR` if an unexpected error occurs.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_subscription_event_init(
rmw_event_t * rmw_event,
const rmw_subscription_t * subscription,
rmw_event_type_t event_type);

/// Take an event from the event handle.
/**
* \param event_handle event object to take from
* \param event_info event info object to write taken data into
* \param taken boolean flag indicating if an event was taken or not
* \return `RMW_RET_OK` if successful, or
* \return `RMW_RET_BAD_ALLOC` if memory allocation failed, or
* \return `RMW_RET_ERROR` if an unexpected error occurs.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_take_event(
const rmw_event_t * event_handle,
void * event_info,
bool * taken);

/// Finalize an rmw_event_t.
/**
* \param event to finalize
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_event_fini(rmw_event_t * event);

#ifdef __cplusplus
}
#endif

#endif // RMW__EVENT_H_
28 changes: 28 additions & 0 deletions rmw/include/rmw/qos_profiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@ extern "C"

#include "rmw/types.h"

#define RMW_QOS_DEADLINE_DEFAULT {0, 0}
#define RMW_QOS_LIFESPAN_DEFAULT {0, 0}
#define RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT {0, 0}

static const rmw_qos_profile_t rmw_qos_profile_sensor_data =
{
RMW_QOS_POLICY_HISTORY_KEEP_LAST,
5,
RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT,
RMW_QOS_POLICY_DURABILITY_VOLATILE,
RMW_QOS_DEADLINE_DEFAULT,
RMW_QOS_LIFESPAN_DEFAULT,
RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT,
RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT,
false
};

Expand All @@ -37,6 +45,10 @@ static const rmw_qos_profile_t rmw_qos_profile_parameters =
1000,
RMW_QOS_POLICY_RELIABILITY_RELIABLE,
RMW_QOS_POLICY_DURABILITY_VOLATILE,
RMW_QOS_DEADLINE_DEFAULT,
RMW_QOS_LIFESPAN_DEFAULT,
RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT,
RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT,
false
};

Expand All @@ -46,6 +58,10 @@ static const rmw_qos_profile_t rmw_qos_profile_default =
10,
RMW_QOS_POLICY_RELIABILITY_RELIABLE,
RMW_QOS_POLICY_DURABILITY_VOLATILE,
RMW_QOS_DEADLINE_DEFAULT,
RMW_QOS_LIFESPAN_DEFAULT,
RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT,
RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT,
false
};

Expand All @@ -55,6 +71,10 @@ static const rmw_qos_profile_t rmw_qos_profile_services_default =
10,
RMW_QOS_POLICY_RELIABILITY_RELIABLE,
RMW_QOS_POLICY_DURABILITY_VOLATILE,
RMW_QOS_DEADLINE_DEFAULT,
RMW_QOS_LIFESPAN_DEFAULT,
RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT,
RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT,
false
};

Expand All @@ -64,6 +84,10 @@ static const rmw_qos_profile_t rmw_qos_profile_parameter_events =
1000,
RMW_QOS_POLICY_RELIABILITY_RELIABLE,
RMW_QOS_POLICY_DURABILITY_VOLATILE,
RMW_QOS_DEADLINE_DEFAULT,
RMW_QOS_LIFESPAN_DEFAULT,
RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT,
RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT,
false
};

Expand All @@ -73,6 +97,10 @@ static const rmw_qos_profile_t rmw_qos_profile_system_default =
RMW_QOS_POLICY_DEPTH_SYSTEM_DEFAULT,
RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT,
RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT,
RMW_QOS_DEADLINE_DEFAULT,
RMW_QOS_LIFESPAN_DEFAULT,
RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT,
RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT,
false
};

Expand Down
2 changes: 2 additions & 0 deletions rmw/include/rmw/ret_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ typedef int32_t rmw_ret_t;
#define RMW_RET_ERROR 1
#define RMW_RET_TIMEOUT 2

/// The operation or event handling is not supported.
#define RMW_RET_UNSUPPORTED 3
wjwwood marked this conversation as resolved.
Show resolved Hide resolved
/// Failed to allocate memory return code.
#define RMW_RET_BAD_ALLOC 10
/// Invalid argument return code.
Expand Down
49 changes: 49 additions & 0 deletions rmw/include/rmw/rmw.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,30 @@ RMW_WARN_UNUSED
rmw_ret_t
rmw_destroy_node(rmw_node_t * node);

/// Manually assert that this node is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE)
/**
* If the rmw Liveliness policy is set to RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE, the creator of
* this node may manually call `assert_liveliness` at some point in time to signal to the rest
* of the system that this Node is still alive.
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | Yes
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] node handle to the node that needs liveliness to be asserted
* \return `RMW_RET_OK` if the liveliness assertion was completed successfully, or
* \return `RMW_RET_ERROR` if an unspecified error occurs, or
* \return `RMW_RET_UNSUPPORTED` if the rmw implementation does not support asserting liveliness.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_node_assert_liveliness(const rmw_node_t * node);

/// Return a guard condition which is triggered when the ROS graph changes.
/**
* The handle returned is a pointer to an internally held rmw guard condition.
Expand Down Expand Up @@ -296,6 +320,30 @@ rmw_ret_t
rmw_publish_serialized_message(
const rmw_publisher_t * publisher, const rmw_serialized_message_t * serialized_message);

/// Manually assert that this Publisher is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC)
/**
* If the rmw Liveliness policy is set to RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC, the creator of
* this publisher may manually call `assert_liveliness` at some point in time to signal to the rest
* of the system that this Node is still alive.
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | Yes
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] publisher handle to the publisher that needs liveliness to be asserted
* \return `RMW_RET_OK` if the liveliness assertion was completed successfully, or
* \return `RMW_RET_ERROR` if an unspecified error occurs, or
* \return `RMW_RET_UNSUPPORTED` if the rmw implementation does not support asserting liveliness.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_publisher_assert_liveliness(const rmw_publisher_t * publisher);

/// Serialize a ROS message into a rmw_serialized_message_t.
/**
* The ROS message is serialized into a byte stream contained within the
Expand Down Expand Up @@ -615,6 +663,7 @@ rmw_wait(
rmw_guard_conditions_t * guard_conditions,
rmw_services_t * services,
rmw_clients_t * clients,
rmw_events_t * events,
rmw_wait_set_t * wait_set,
const rmw_time_t * wait_timeout);

Expand Down
Loading