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

irobot/master-events-executor features #87

Open
wants to merge 23 commits into
base: irobot/master-events-executor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
43db06d
Use spin() in component_manager_isolated.hpp (#1881)
alsora Feb 9, 2022
891fff0
fix one subscription can wait_for_message twice (#1870)
Feb 10, 2022
4c8cfa3
use universal reference to support rvalue. (#1883)
fujitatomoya Feb 10, 2022
025cd5c
Use ament_generate_version_header (#1886)
sloretz Feb 15, 2022
4f77819
Install headers to include/${PROJECT_NAME} (#1888)
sloretz Feb 16, 2022
32c03dd
small improvements to node_main.cpp.in
alsora Feb 19, 2022
c5a16dc
Remove fastrtps customization on tests (#1887)
MiguelCompany Feb 22, 2022
558e9bc
Support action expire timers with callbacks approach
Feb 23, 2022
d8e1aed
Add RMW listener APIs (#1579)
Feb 24, 2022
68ccdd4
Merge stuff
Feb 24, 2022
9c5ad79
Merge pull request #1889 from ros2/asoragna/improve-components-main
alsora Feb 24, 2022
79241a3
spin_all with a zero timeout. (#1878)
fujitatomoya Feb 25, 2022
7b7f23a
Merge branch 'master' into mauro/master-events-executor-expire-goal-m…
Feb 28, 2022
e820c3c
time_until_trigger returns max time if timer is cancelled
Feb 28, 2022
360d853
Add test for timer time_until_trigger api
Feb 28, 2022
76a6dfe
create timer as part as server base
Feb 28, 2022
4e3c6be
Changelog.
clalancette Mar 1, 2022
16914e3
15.1.0
clalancette Mar 1, 2022
f2f7ffd
fix bugprone-exception-escape in node_main.cpp.in (#1895)
alsora Mar 8, 2022
3bd6900
Micro-optimizations in rclcpp (#1896)
clalancette Mar 9, 2022
91f0b64
time_until_trigger returns max time if timer is cancelled (#1893)
mauropasse Mar 11, 2022
f26f88e
Merge branch 'master' into mauro/master-events-executor-expire-goal-m…
Mar 11, 2022
c83b51b
Add timers on_reset callback
Mar 14, 2022
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
14 changes: 14 additions & 0 deletions rclcpp/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
Changelog for package rclcpp
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

15.1.0 (2022-03-01)
-------------------
* spin_all with a zero timeout. (`#1878 <https://github.com/ros2/rclcpp/issues/1878>`_)
* Add RMW listener APIs (`#1579 <https://github.com/ros2/rclcpp/issues/1579>`_)
* Remove fastrtps customization on tests (`#1887 <https://github.com/ros2/rclcpp/issues/1887>`_)
* Install headers to include/${PROJECT_NAME} (`#1888 <https://github.com/ros2/rclcpp/issues/1888>`_)
* Use ament_generate_version_header (`#1886 <https://github.com/ros2/rclcpp/issues/1886>`_)
* use universal reference to support rvalue. (`#1883 <https://github.com/ros2/rclcpp/issues/1883>`_)
* fix one subscription can wait_for_message twice (`#1870 <https://github.com/ros2/rclcpp/issues/1870>`_)
* Add return value version of get_parameter_or (`#1813 <https://github.com/ros2/rclcpp/issues/1813>`_)
* Cleanup time source object lifetimes (`#1867 <https://github.com/ros2/rclcpp/issues/1867>`_)
* add is_spinning() method to executor base class
* Contributors: Alberto Soragna, Chen Lihui, Chris Lalancette, Kenji Miyake, Miguel Company, Shane Loretz, Tomoya Fujita, iRobot ROS

15.0.0 (2022-01-14)
-------------------
* Cleanup the TypeAdapt tests (`#1858 <https://github.com/ros2/rclcpp/issues/1858>`_)
Expand Down
13 changes: 8 additions & 5 deletions rclcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ endif()
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
# specific order: dependents before dependencies
ament_target_dependencies(${PROJECT_NAME}
Expand Down Expand Up @@ -221,11 +221,14 @@ install(
RUNTIME DESTINATION bin
)

# specific order: dependents before dependencies
ament_export_include_directories(include)
# Export old-style CMake variables
ament_export_include_directories("include/${PROJECT_NAME}")
ament_export_libraries(${PROJECT_NAME})

# Export modern CMake targets
ament_export_targets(${PROJECT_NAME})

# specific order: dependents before dependencies
ament_export_dependencies(ament_index_cpp)
ament_export_dependencies(libstatistics_collector)
ament_export_dependencies(rcl)
Expand All @@ -251,12 +254,12 @@ ament_package()

install(
DIRECTORY include/ ${CMAKE_CURRENT_BINARY_DIR}/include/
DESTINATION include
DESTINATION include/${PROJECT_NAME}
)

if(TEST cppcheck)
# must set the property after ament_package()
set_tests_properties(cppcheck PROPERTIES TIMEOUT 500)
endif()

ament_cmake_gen_version_h()
ament_generate_version_header(${PROJECT_NAME})
8 changes: 8 additions & 0 deletions rclcpp/include/rclcpp/callback_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ class CallbackGroup
const CallbackGroupType &
type() const;

RCLCPP_PUBLIC
void collect_all_ptrs(
std::function<void(const rclcpp::SubscriptionBase::SharedPtr &)> sub_func,
std::function<void(const rclcpp::ServiceBase::SharedPtr &)> service_func,
std::function<void(const rclcpp::ClientBase::SharedPtr &)> client_func,
std::function<void(const rclcpp::TimerBase::SharedPtr &)> timer_func,
std::function<void(const rclcpp::Waitable::SharedPtr &)> waitable_func) const;

/// Return a reference to the 'associated with executor' atomic boolean.
/**
* When a callback group is added to an executor this boolean is checked
Expand Down
6 changes: 3 additions & 3 deletions rclcpp/include/rclcpp/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class ClientBase
}
};

std::lock_guard<std::recursive_mutex> lock(listener_mutex_);
std::lock_guard<std::recursive_mutex> lock(callback_mutex_);

// Set it temporarily to the new callback, while we replace the old one.
// This two-step setting, prevents a gap where the old std::function has
Expand All @@ -295,7 +295,7 @@ class ClientBase
void
clear_on_new_response_callback()
{
std::lock_guard<std::recursive_mutex> lock(listener_mutex_);
std::lock_guard<std::recursive_mutex> lock(callback_mutex_);
if (on_new_response_callback_) {
set_on_new_response_callback(nullptr, nullptr);
on_new_response_callback_ = nullptr;
Expand Down Expand Up @@ -330,7 +330,7 @@ class ClientBase

std::atomic<bool> in_use_by_wait_set_{false};

std::recursive_mutex listener_mutex_;
std::recursive_mutex callback_mutex_;
std::function<void(size_t)> on_new_response_callback_{nullptr};
};

Expand Down
2 changes: 1 addition & 1 deletion rclcpp/include/rclcpp/create_publisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ template<
typename NodeT>
std::shared_ptr<PublisherT>
create_publisher(
NodeT & node,
NodeT && node,
const std::string & topic_name,
const rclcpp::QoS & qos,
const rclcpp::PublisherOptionsWithAllocator<AllocatorT> & options = (
Expand Down
2 changes: 1 addition & 1 deletion rclcpp/include/rclcpp/detail/cpp_callback_trampoline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace detail
* captures, and various kinds of std::bind instances.
*
* The interior of this function is likely to be executed within a C runtime,
* so no exceptins should be thrown at this point, and doing so results in
* so no exceptions should be thrown at this point, and doing so results in
* undefined behavior.
*
* \tparam UserDataT Deduced type based on what is passed for user data,
Expand Down
4 changes: 3 additions & 1 deletion rclcpp/include/rclcpp/executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ class Executor
* If the time that waitables take to be executed is longer than the period on which new waitables
* become ready, this method will execute work repeatedly until `max_duration` has elapsed.
*
* \param[in] max_duration The maximum amount of time to spend executing work. Must be positive.
* \param[in] max_duration The maximum amount of time to spend executing work, must be >= 0.
* `0` is potentially block forever until no more work is available.
* \throw throw std::invalid_argument if max_duration is less than 0.
* Note that spin_all() may take longer than this time as it only returns once max_duration has
* been exceeded.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ class StaticSingleThreadedExecutor : public rclcpp::Executor

/// Static executor implementation of spin all
/**
* This non-blocking function will execute entities until
* timeout or no more work available. If new entities get ready
* while executing work available, they will be executed
* This non-blocking function will execute entities until timeout (must be >= 0)
* or no more work available.
* If timeout is `0`, potentially it blocks forever until no more work is available.
* If new entities get ready while executing work available, they will be executed
* as long as the timeout hasn't expired.
*
* Example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class SubscriptionIntraProcessBase : public rclcpp::Waitable
* The application should provide a generic callback function that will be then
* forwarded by the waitable to all of its entities.
* Before forwarding, a different value for the identifier argument will be
* bond to the function.
* bound to the function.
* This implies that the provided callback can use the identifier to behave
* differently depending on which entity triggered the waitable to become ready.
*
Expand Down Expand Up @@ -149,11 +149,11 @@ class SubscriptionIntraProcessBase : public rclcpp::Waitable
}
};

std::lock_guard<std::recursive_mutex> lock(listener_mutex_);
std::lock_guard<std::recursive_mutex> lock(callback_mutex_);
on_new_message_callback_ = new_callback;

if (unread_count_ > 0) {
if (qos_profile_.history() == HistoryPolicy::KeepLast || qos_profile_.depth() == 0) {
if (qos_profile_.history() == HistoryPolicy::KeepAll) {
on_new_message_callback_(unread_count_);
} else {
// Use qos profile depth as upper bound for unread_count_
Expand All @@ -167,19 +167,30 @@ class SubscriptionIntraProcessBase : public rclcpp::Waitable
void
clear_on_ready_callback() override
{
std::lock_guard<std::recursive_mutex> lock(listener_mutex_);
std::lock_guard<std::recursive_mutex> lock(callback_mutex_);
on_new_message_callback_ = nullptr;
}

protected:
std::recursive_mutex listener_mutex_;
std::recursive_mutex callback_mutex_;
std::function<void(size_t)> on_new_message_callback_ {nullptr};
size_t unread_count_{0};
rclcpp::GuardCondition gc_;

virtual void
trigger_guard_condition() = 0;

void
invoke_on_new_message()
{
std::lock_guard<std::recursive_mutex> lock(this->callback_mutex_);
if (this->on_new_message_callback_) {
this->on_new_message_callback_(1);
} else {
this->unread_count_++;
}
}

private:
std::string topic_name_;
QoS qos_profile_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class SubscriptionIntraProcessBuffer : public SubscriptionROSMsgIntraProcessBuff
buffer_->add_shared(convert_ros_message_to_subscribed_type_unique_ptr(*message));
trigger_guard_condition();
}
invoke_on_new_message_listener();
this->invoke_on_new_message();
}

void
Expand All @@ -138,23 +138,23 @@ class SubscriptionIntraProcessBuffer : public SubscriptionROSMsgIntraProcessBuff
buffer_->add_unique(convert_ros_message_to_subscribed_type_unique_ptr(*message));
trigger_guard_condition();
}
invoke_on_new_message_listener();
this->invoke_on_new_message();
}

void
provide_intra_process_data(ConstDataSharedPtr message)
{
buffer_->add_shared(std::move(message));
trigger_guard_condition();
invoke_on_new_message_listener();
this->invoke_on_new_message();
}

void
provide_intra_process_data(SubscribedTypeUniquePtr message)
{
buffer_->add_unique(std::move(message));
trigger_guard_condition();
invoke_on_new_message_listener();
this->invoke_on_new_message();
}

bool
Expand Down
20 changes: 10 additions & 10 deletions rclcpp/include/rclcpp/memory_strategy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,52 +100,52 @@ class RCLCPP_PUBLIC MemoryStrategy

static rclcpp::SubscriptionBase::SharedPtr
get_subscription_by_handle(
std::shared_ptr<const rcl_subscription_t> subscriber_handle,
const std::shared_ptr<const rcl_subscription_t> & subscriber_handle,
const WeakCallbackGroupsToNodesMap & weak_groups_to_nodes);

static rclcpp::ServiceBase::SharedPtr
get_service_by_handle(
std::shared_ptr<const rcl_service_t> service_handle,
const std::shared_ptr<const rcl_service_t> & service_handle,
const WeakCallbackGroupsToNodesMap & weak_groups_to_nodes);

static rclcpp::ClientBase::SharedPtr
get_client_by_handle(
std::shared_ptr<const rcl_client_t> client_handle,
const std::shared_ptr<const rcl_client_t> & client_handle,
const WeakCallbackGroupsToNodesMap & weak_groups_to_nodes);

static rclcpp::TimerBase::SharedPtr
get_timer_by_handle(
std::shared_ptr<const rcl_timer_t> timer_handle,
const std::shared_ptr<const rcl_timer_t> & timer_handle,
const WeakCallbackGroupsToNodesMap & weak_groups_to_nodes);

static rclcpp::node_interfaces::NodeBaseInterface::SharedPtr
get_node_by_group(
rclcpp::CallbackGroup::SharedPtr group,
const rclcpp::CallbackGroup::SharedPtr & group,
const WeakCallbackGroupsToNodesMap & weak_groups_to_nodes);

static rclcpp::CallbackGroup::SharedPtr
get_group_by_subscription(
rclcpp::SubscriptionBase::SharedPtr subscription,
const rclcpp::SubscriptionBase::SharedPtr & subscription,
const WeakCallbackGroupsToNodesMap & weak_groups_to_nodes);

static rclcpp::CallbackGroup::SharedPtr
get_group_by_service(
rclcpp::ServiceBase::SharedPtr service,
const rclcpp::ServiceBase::SharedPtr & service,
const WeakCallbackGroupsToNodesMap & weak_groups_to_nodes);

static rclcpp::CallbackGroup::SharedPtr
get_group_by_client(
rclcpp::ClientBase::SharedPtr client,
const rclcpp::ClientBase::SharedPtr & client,
const WeakCallbackGroupsToNodesMap & weak_groups_to_nodes);

static rclcpp::CallbackGroup::SharedPtr
get_group_by_timer(
rclcpp::TimerBase::SharedPtr timer,
const rclcpp::TimerBase::SharedPtr & timer,
const WeakCallbackGroupsToNodesMap & weak_groups_to_nodes);

static rclcpp::CallbackGroup::SharedPtr
get_group_by_waitable(
rclcpp::Waitable::SharedPtr waitable,
const rclcpp::Waitable::SharedPtr & waitable,
const WeakCallbackGroupsToNodesMap & weak_groups_to_nodes);
};

Expand Down
6 changes: 3 additions & 3 deletions rclcpp/include/rclcpp/qos_event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class QOSEventHandlerBase : public Waitable
}
};

std::lock_guard<std::recursive_mutex> lock(listener_mutex_);
std::lock_guard<std::recursive_mutex> lock(callback_mutex_);

// Set it temporarily to the new callback, while we replace the old one.
// This two-step setting, prevents a gap where the old std::function has
Expand All @@ -201,7 +201,7 @@ class QOSEventHandlerBase : public Waitable
void
clear_on_ready_callback() override
{
std::lock_guard<std::recursive_mutex> lock(listener_mutex_);
std::lock_guard<std::recursive_mutex> lock(callback_mutex_);
if (on_new_event_callback_) {
set_on_new_event_callback(nullptr, nullptr);
on_new_event_callback_ = nullptr;
Expand All @@ -215,7 +215,7 @@ class QOSEventHandlerBase : public Waitable

rcl_event_t event_handle_;
size_t wait_set_event_index_;
std::recursive_mutex listener_mutex_;
std::recursive_mutex callback_mutex_;
std::function<void(size_t)> on_new_event_callback_{nullptr};
};

Expand Down
6 changes: 3 additions & 3 deletions rclcpp/include/rclcpp/service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class ServiceBase
}
};

std::lock_guard<std::recursive_mutex> lock(listener_mutex_);
std::lock_guard<std::recursive_mutex> lock(callback_mutex_);

// Set it temporarily to the new callback, while we replace the old one.
// This two-step setting, prevents a gap where the old std::function has
Expand All @@ -205,7 +205,7 @@ class ServiceBase
void
clear_on_new_request_callback()
{
std::lock_guard<std::recursive_mutex> lock(listener_mutex_);
std::lock_guard<std::recursive_mutex> lock(callback_mutex_);
if (on_new_request_callback_) {
set_on_new_request_callback(nullptr, nullptr);
on_new_request_callback_ = nullptr;
Expand Down Expand Up @@ -236,7 +236,7 @@ class ServiceBase

std::atomic<bool> in_use_by_wait_set_{false};

std::recursive_mutex listener_mutex_;
std::recursive_mutex callback_mutex_;
std::function<void(size_t)> on_new_request_callback_{nullptr};
};

Expand Down
Loading