forked from microsoft/AirSim
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from wingman-ai/multi_threaded
Create a new MutuallyExclusive callback group for every timer, use a multithreaded executor
- Loading branch information
Showing
3 changed files
with
20 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,19 @@ | ||
#include <rclcpp/rclcpp.hpp> | ||
#include "airsim_ros_wrapper.h" | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
int main(int argc, char **argv) { | ||
rclcpp::init(argc, argv); | ||
rclcpp::NodeOptions node_options; | ||
node_options.automatically_declare_parameters_from_overrides(true); | ||
std::shared_ptr<rclcpp::Node> nh = rclcpp::Node::make_shared("airsim_node", node_options); | ||
std::shared_ptr<rclcpp::Node> nh_img = nh->create_sub_node("img"); | ||
std::shared_ptr<rclcpp::Node> nh_lidar = nh->create_sub_node("lidar"); | ||
std::shared_ptr <rclcpp::Node> nh = rclcpp::Node::make_shared("airsim_node", node_options); | ||
std::shared_ptr <rclcpp::Node> nh_img = nh->create_sub_node("img"); | ||
std::shared_ptr <rclcpp::Node> nh_lidar = nh->create_sub_node("lidar"); | ||
std::string host_ip; | ||
nh->get_parameter("host_ip", host_ip); | ||
AirsimROSWrapper airsim_ros_wrapper(nh, nh_img, nh_lidar, host_ip); | ||
|
||
if (airsim_ros_wrapper.is_used_img_timer_cb_queue_) { | ||
rclcpp::executors::SingleThreadedExecutor executor; | ||
executor.add_node(nh_img); | ||
while (rclcpp::ok()) { | ||
executor.spin(); | ||
} | ||
} | ||
|
||
if (airsim_ros_wrapper.is_used_lidar_timer_cb_queue_) { | ||
rclcpp::executors::SingleThreadedExecutor executor; | ||
executor.add_node(nh_lidar); | ||
while (rclcpp::ok()) { | ||
executor.spin(); | ||
} | ||
} | ||
|
||
rclcpp::spin(nh); | ||
rclcpp::executors::MultiThreadedExecutor executor; | ||
executor.add_node(nh); | ||
executor.spin(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters