MCPcopy Create free account
hub / github.com/AutonomousFieldRoboticsLab/SVIn / Subscriber

Method Subscriber

pose_graph/src/pose_graph/Subscriber.cpp:13–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#include "utils/UtilsOpenCV.h"
12
13Subscriber::Subscriber(std::shared_ptr<rclcpp::Node> node, Parameters& params) : node_(node), params_(params) {
14 // TODO(bjoshi): pass as params from roslaunch file
15 kf_image_topic_ = "/keyframe_imageL";
16 kf_pose_topic_ = "/keyframe_pose";
17 kf_points_topic_ = "/keyframe_points";
18 svin_reloc_odom_topic_ = "/relocalization_odometry";
19 svin_health_topic_ = "/svin_health";
20 primitive_estimator_topic_ = "/aqua_primitive_estimator/odometry";
21 last_image_time_ = -1;
22 raw_image_topic_ = "/cam0/image_raw";
23
24 rclcpp::QoS qos(10);
25 auto rmw_qos_profile = qos.get_rmw_qos_profile();
26
27 keyframe_image_subscriber_.subscribe(node_, kf_image_topic_, rmw_qos_profile);
28 keyframe_points_subscriber_.subscribe(node_, kf_points_topic_, rmw_qos_profile);
29 keyframe_pose_subscriber_.subscribe(node_, kf_pose_topic_, rmw_qos_profile);
30 svin_health_subscriber_.subscribe(node_, svin_health_topic_, rmw_qos_profile);
31
32 static constexpr size_t kMaxKeyframeSynchronizerQueueSize = 10u;
33 sync_keyframe_ = std::make_unique<message_filters::Synchronizer<keyframe_sync_policy>>(
34 keyframe_sync_policy(kMaxKeyframeSynchronizerQueueSize),
35 keyframe_image_subscriber_,
36 keyframe_pose_subscriber_,
37 keyframe_points_subscriber_,
38 svin_health_subscriber_);
39 sync_keyframe_->registerCallback(std::bind(&Subscriber::keyframeCallback,
40 this,
41 std::placeholders::_1,
42 std::placeholders::_2,
43 std::placeholders::_3,
44 std::placeholders::_4));
45
46 if (params_.global_mapping_params_.enabled) {
47 sub_orig_image_ = node_->create_subscription<sensor_msgs::msg::Image>(
48 raw_image_topic_, 100, std::bind(&Subscriber::imageCallback, this, std::placeholders::_1));
49 }
50 if (params_.health_params_.enabled) {
51 sub_primitive_estimator_ = node_->create_subscription<nav_msgs::msg::Odometry>(
52 primitive_estimator_topic_,
53 100,
54 std::bind(&Subscriber::primitiveEstimatorCallback, this, std::placeholders::_1));
55 }
56
57 // Watchdog: parameter and timer setup (uses steady clock)
58 try {
59 if (!node_->has_parameter("freeze_timeout_sec")) {
60 node_->declare_parameter<double>("freeze_timeout_sec", 60.0);
61 }
62 node_->get_parameter("freeze_timeout_sec", freeze_timeout_sec_);
63 } catch (const std::exception&) {
64 freeze_timeout_sec_ = 240.0;
65 }
66 last_keyframe_tp_ = std::chrono::steady_clock::now();
67 frozen_ = false;
68 seen_first_keyframe_ = false;
69 using namespace std::chrono_literals; // NOLINT
70 watchdog_timer_ = node_->create_wall_timer(500ms, std::bind(&Subscriber::watchdogTick, this));

Callers 2

__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected