Nav2 Navigation Stack - humble  humble
ROS 2 Navigation Stack
scan.hpp
1 // Copyright (c) 2022 Samsung R&D Institute Russia
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef NAV2_COLLISION_MONITOR__SCAN_HPP_
16 #define NAV2_COLLISION_MONITOR__SCAN_HPP_
17 
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 #include "sensor_msgs/msg/laser_scan.hpp"
23 #include "nav2_util/robot_utils.hpp"
24 
25 #include "nav2_collision_monitor/source.hpp"
26 
27 namespace nav2_collision_monitor
28 {
29 
33 class Scan : public Source
34 {
35 public:
48  Scan(
49  const nav2_util::LifecycleNode::WeakPtr & node,
50  const std::string & source_name,
51  const std::shared_ptr<tf2_ros::Buffer> tf_buffer,
52  const std::string & base_frame_id,
53  const std::string & global_frame_id,
54  const tf2::Duration & transform_tolerance,
55  const rclcpp::Duration & source_timeout,
56  const bool base_shift_correction);
60  ~Scan();
61 
66  void configure();
67 
74  void getData(
75  const rclcpp::Time & curr_time,
76  std::vector<Point> & data) const;
77 
78 protected:
83  void dataCallback(sensor_msgs::msg::LaserScan::ConstSharedPtr msg);
84 
85  // ----- Variables -----
86 
88  rclcpp::Subscription<sensor_msgs::msg::LaserScan>::SharedPtr data_sub_;
89 
91  sensor_msgs::msg::LaserScan::ConstSharedPtr data_;
92 }; // class Scan
93 
94 } // namespace nav2_collision_monitor
95 
96 #endif // NAV2_COLLISION_MONITOR__SCAN_HPP_
Implementation for laser scanner source.
Definition: scan.hpp:34
rclcpp::Subscription< sensor_msgs::msg::LaserScan >::SharedPtr data_sub_
Laser scanner data subscriber.
Definition: scan.hpp:88
void dataCallback(sensor_msgs::msg::LaserScan::ConstSharedPtr msg)
Laser scanner data callback.
Definition: scan.cpp:121
sensor_msgs::msg::LaserScan::ConstSharedPtr data_
Latest data obtained from laser scanner.
Definition: scan.hpp:91
Scan(const nav2_util::LifecycleNode::WeakPtr &node, const std::string &source_name, const std::shared_ptr< tf2_ros::Buffer > tf_buffer, const std::string &base_frame_id, const std::string &global_frame_id, const tf2::Duration &transform_tolerance, const rclcpp::Duration &source_timeout, const bool base_shift_correction)
Scan constructor.
Definition: scan.cpp:23
~Scan()
Scan destructor.
Definition: scan.cpp:40
void getData(const rclcpp::Time &curr_time, std::vector< Point > &data) const
Adds latest data from laser scanner to the data array.
Definition: scan.cpp:65
void configure()
Data source configuration routine. Obtains ROS-parameters and creates laser scanner subscriber.
Definition: scan.cpp:46
Basic data source class.
Definition: source.hpp:38