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

Method Subscriber

okvis_ros/src/Subscriber.cpp:55–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53Subscriber::~Subscriber() { imgTransport_.release(); }
54
55Subscriber::Subscriber(std::shared_ptr<rclcpp::Node> node,
56 okvis::VioInterface* vioInterfacePtr,
57 const okvis::VioParametersReader& param_reader)
58 : node_(node), vioInterface_(vioInterfacePtr), imgTransport_(nullptr) {
59 /// @Sharmin
60 param_reader.getParameters(vioParameters_);
61
62 imageSubscribers_.resize(vioParameters_.nCameraSystem.numCameras());
63
64 imgTransport_ = std::make_unique<image_transport::ImageTransport>(node);
65
66 // setup callback groups
67 auto svin2_callback_group = node->create_callback_group(rclcpp::CallbackGroupType::Reentrant);
68 auto options = rclcpp::SubscriptionOptions();
69 options.callback_group = svin2_callback_group;
70
71 // Set up Camera callbacks
72 for (size_t i = 0; i < vioParameters_.nCameraSystem.numCameras(); ++i) {
73 imageSubscribers_[i] =
74 imgTransport_->subscribe("camera" + std::to_string(i),
75 30 * vioParameters_.nCameraSystem.numCameras(),
76 std::bind(&Subscriber::imageCallback, this, std::placeholders::_1, i));
77 }
78
79 // Set up IMU callback
80 subImu_ = node->create_subscription<sensor_msgs::msg::Imu>(
81 "imu", 1000, std::bind(&Subscriber::imuCallback, this, std::placeholders::_1));
82 //subImu_ = node->create_subscription<sensor_msgs::msg::Imu>(
83 // "imu", rclcpp::SensorDataQoS(), std::bind(&Subscriber::imuCallback, this, std::placeholders::_1), options);
84
85 // Sharmin
86 // if (vioParameters_.sensorList.isSonarUsed) {
87 // subSonarRange_ = nh_->subscribe("/imagenex831l/range", 1000, &Subscriber::sonarCallback, this);
88 // }
89 // Sharmin
90 // if (vioParameters_.sensorList.isDepthUsed){
91 // subDepth_ = nh_->subscribe("/bar30/depth", 1000, &Subscriber::depthCallback, this);
92 // subDepth_ = nh_->subscribe("/aqua/state", 1000, &Subscriber::depthCallback, this); // Aqua depth topic
93 // }
94
95 // Sharmin
96 // if (vioParameters_.relocParameters.isRelocalization) {
97 // std::cout << "Subscribing to /pose_graph/match_points topic" << std::endl;
98 // subReloPoints_ = node->create_subscription<sensor_msgs::msg::PointCloud>(
99 // "/pose_graph/match_points", 1000, std::bind(&Subscriber::relocCallback, this, std::placeholders::_1));
100 // }
101
102 tfBuffer_ = std::make_shared<tf2_ros::Buffer>(node_->get_clock());
103 tfListener_ = std::make_shared<tf2_ros::TransformListener>(*tfBuffer_);
104 imgTransport_ = 0;
105
106 imgLeftCounter = 0; // @Sharmin
107 imgRightCounter = 0; // @Sharmin
108 // Added by Sharmin
109 if (vioParameters_.histogramParams.histogramMethod == HistogramMethod::CLAHE) {
110 clahe = cv::createCLAHE();
111 clahe->setClipLimit(vioParameters_.histogramParams.claheClipLimit);
112 clahe->setTilesGridSize(

Callers

nothing calls this directly

Calls 2

numCamerasMethod · 0.80
getParametersMethod · 0.45

Tested by

no test coverage detected