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

fix api differences on executors in ROS2 humble #42

Open
wants to merge 1 commit into
base: fix/humble-compatibility
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions rtt_ros2_node/include/orocos/rtt_ros2_node/rtt_ros2_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ struct Node : public RTT::Service
virtual ~Node();

rclcpp::Node::SharedPtr node() {return node_;}
rclcpp::executor::Executor::SharedPtr executor() {return executor_;}
rclcpp::Executor::Executor::SharedPtr executor() {return executor_;}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rclcpp::Executor::Executor::SharedPtr executor() {return executor_;}
rclcpp::Executor::SharedPtr executor() {return executor_;}

The namespace executor was deprecated since ros2/rclcpp#1083 and removed in ros2/rclcpp#1622, so all ROS 2 versions since Foxy. So probably fine to drop support of older versions. Same for rclcpp::ExecutorOptions below.

But I don't see how rclcpp::Executor::Executor::SharedPtr should work? rclcpp::Executor::Executor would refer to the constructor of class rclcpp::Executor, no?


void spin(unsigned int number_of_threads = 1);
void cancel();

protected:
rclcpp::Node::SharedPtr node_;
rclcpp::executor::Executor::SharedPtr executor_;
rclcpp::Executor::Executor::SharedPtr executor_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rclcpp::Executor::Executor::SharedPtr executor_;
rclcpp::Executor::SharedPtr executor_;

std::thread thread_;
};

Expand Down
2 changes: 1 addition & 1 deletion rtt_ros2_node/src/rtt_ros2_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void Node::spin(unsigned int number_of_threads)
{
cancel();
const auto executor = std::make_shared<rclcpp::executors::MultiThreadedExecutor>(
rclcpp::executor::ExecutorArgs(),
rclcpp::ExecutorOptions(),
number_of_threads
);
executor->add_node(node_);
Expand Down
2 changes: 1 addition & 1 deletion rtt_ros2_node/src/rtt_ros2_node_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static void loadGlobalROSService()

// Call rclcpp::init()
rclcpp::InitOptions init_options;
init_options.shutdown_on_sigint = false;
init_options.shutdown_on_signal = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flag was renamed in version 13.1.0 of rclcpp (ros2/rclcpp#1771), so only since ROS 2 Humble. Even though Galactic and older have reached their end-of-life already, I suggest to add a preprocessor condition in this case, to still support older ROS versions without having to maintain multiple branches.

Something like

Suggested change
init_options.shutdown_on_signal = false;
#if RCLCPP_VERSION_GTE(13, 1, 0)
init_options.shutdown_on_signal = false;
#else
init_options.shutdown_on_sigint = false;
#endif

and

#include "rclcpp/version.h"

above should do.

RTT::log(RTT::Info) <<
"Initializing ROS context with " << __os_main_argc() << " command-line arguments." <<
RTT::endlog();
Expand Down