forked from rpng/open_vins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/nodelet'
- Loading branch information
Showing
6 changed files
with
189 additions
and
61 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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<library path="lib/libRunSubscribeMsckf"> | ||
<class name="run_subscribe_msckf/RunSubscribeMsckf" type="run_subscribe_msckf::RunSubscribeMsckf" base_class_type="nodelet::Nodelet"> | ||
<description>RunSubscribeMsckf nodelet</description> | ||
</class> | ||
</library> |
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 |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/* | ||
* OpenVINS: An Open Platform for Visual-Inertial Research | ||
* Copyright (C) 2018-2023 Patrick Geneva | ||
* Copyright (C) 2018-2023 Guoquan Huang | ||
* Copyright (C) 2018-2023 OpenVINS Contributors | ||
* Copyright (C) 2018-2019 Kevin Eckenhoff | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <memory> | ||
|
||
#include "core/VioManager.h" | ||
#include "core/VioManagerOptions.h" | ||
#include "utils/dataset_reader.h" | ||
|
||
#if ROS_AVAILABLE == 1 | ||
#include "ros/ROS1Visualizer.h" | ||
#include <ros/ros.h> | ||
#elif ROS_AVAILABLE == 2 | ||
#include "ros/ROS2Visualizer.h" | ||
#include <rclcpp/rclcpp.hpp> | ||
#endif | ||
|
||
using namespace ov_msckf; | ||
|
||
std::shared_ptr<VioManager> sys; | ||
#if ROS_AVAILABLE == 1 | ||
std::shared_ptr<ROS1Visualizer> viz; | ||
#elif ROS_AVAILABLE == 2 | ||
std::shared_ptr<ROS2Visualizer> viz; | ||
#endif | ||
|
||
// Main function | ||
int main(int argc, char **argv) { | ||
|
||
// Ensure we have a path, if the user passes it then we should use it | ||
std::string config_path = "unset_path_to_config.yaml"; | ||
if (argc > 1) { | ||
config_path = argv[1]; | ||
} | ||
|
||
#if ROS_AVAILABLE == 1 | ||
// Launch our ros node | ||
ros::init(argc, argv, "run_subscribe_msckf"); | ||
auto nh = std::make_shared<ros::NodeHandle>("~"); | ||
nh->param<std::string>("config_path", config_path, config_path); | ||
#elif ROS_AVAILABLE == 2 | ||
// Launch our ros node | ||
rclcpp::init(argc, argv); | ||
rclcpp::NodeOptions options; | ||
options.allow_undeclared_parameters(true); | ||
options.automatically_declare_parameters_from_overrides(true); | ||
auto node = std::make_shared<rclcpp::Node>("run_subscribe_msckf", options); | ||
node->get_parameter<std::string>("config_path", config_path); | ||
#endif | ||
|
||
// Load the config | ||
auto parser = std::make_shared<ov_core::YamlParser>(config_path); | ||
#if ROS_AVAILABLE == 1 | ||
parser->set_node_handler(nh); | ||
#elif ROS_AVAILABLE == 2 | ||
parser->set_node(node); | ||
#endif | ||
|
||
// Verbosity | ||
std::string verbosity = "DEBUG"; | ||
parser->parse_config("verbosity", verbosity); | ||
ov_core::Printer::setPrintLevel(verbosity); | ||
|
||
// Create our VIO system | ||
VioManagerOptions params; | ||
params.print_and_load(parser); | ||
params.use_multi_threading_subs = true; | ||
sys = std::make_shared<VioManager>(params); | ||
#if ROS_AVAILABLE == 1 | ||
viz = std::make_shared<ROS1Visualizer>(nh, sys); | ||
viz->setup_subscribers(parser); | ||
#elif ROS_AVAILABLE == 2 | ||
viz = std::make_shared<ROS2Visualizer>(node, sys); | ||
viz->setup_subscribers(parser); | ||
#endif | ||
|
||
// Ensure we read in all parameters required | ||
if (!parser->successful()) { | ||
PRINT_ERROR(RED "unable to parse all parameters, please fix\n" RESET); | ||
std::exit(EXIT_FAILURE); | ||
} | ||
|
||
// Spin off to ROS | ||
PRINT_DEBUG("done...spinning to ros\n"); | ||
#if ROS_AVAILABLE == 1 | ||
// ros::spin(); | ||
ros::AsyncSpinner spinner(0); | ||
spinner.start(); | ||
ros::waitForShutdown(); | ||
#elif ROS_AVAILABLE == 2 | ||
// rclcpp::spin(node); | ||
rclcpp::executors::MultiThreadedExecutor executor; | ||
executor.add_node(node); | ||
executor.spin(); | ||
#endif | ||
|
||
// Final visualization | ||
viz->visualize_final(); | ||
#if ROS_AVAILABLE == 1 | ||
ros::shutdown(); | ||
#elif ROS_AVAILABLE == 2 | ||
rclcpp::shutdown(); | ||
#endif | ||
|
||
// Done! | ||
return EXIT_SUCCESS; | ||
} |