Autoware.Auto
point_cloud_mutation_spoofer.hpp
Go to the documentation of this file.
1 // Copyright 2018 the Autoware Foundation
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 // Co-developed by Tier IV, Inc. and Apex.AI, Inc.
16 #ifndef LIDAR_INTEGRATION__POINT_CLOUD_MUTATION_SPOOFER_HPP_
17 #define LIDAR_INTEGRATION__POINT_CLOUD_MUTATION_SPOOFER_HPP_
18 
19 #include <rclcpp/rclcpp.hpp>
20 #include <common/types.hpp>
21 #include <sensor_msgs/msg/point_cloud2.hpp>
23 
24 #include <memory>
25 #include <random>
26 
27 namespace lidar_integration
28 {
33 
36 class LIDAR_INTEGRATION_PUBLIC PointCloudMutationSpooferNode : public rclcpp::Node
37 {
38 public:
40  const char8_t * topic,
41  const uint32_t step_mean,
42  const uint32_t step_std,
43  const uint32_t width_mean,
44  const uint32_t width_std,
45  const float32_t freq);
46 
47  void init();
48 
49  void start();
50 
51  void stop();
52 
53 protected:
54  void wait_for_matched(
55  const uint32_t num_expected_subs,
56  std::chrono::milliseconds match_timeout);
57 
58  void task_function();
59 
60 private:
61  rclcpp::Publisher<sensor_msgs::msg::PointCloud2>::SharedPtr m_pub;
62  sensor_msgs::msg::PointCloud2 m_msg;
63 
64  std::mt19937 m_mt;
65  std::random_device m_rd;
66  std::normal_distribution<> m_dis_width;
67  std::normal_distribution<> m_dis_row_step;
68  std::uniform_int_distribution<uint16_t> m_dis_data;
69  std::uniform_int_distribution<uint16_t> m_dice;
70 
71  uint32_t m_sleep_time;
72  std::thread m_thread;
73  std::atomic_bool m_running;
74 }; // Spoofer
75 } // namespace lidar_integration
76 #endif // LIDAR_INTEGRATION__POINT_CLOUD_MUTATION_SPOOFER_HPP_
lidar_integration
Definition: lidar_integration.hpp:26
types.hpp
This file includes common type definition.
visibility_control.hpp
autoware::common::types::char8_t
char char8_t
Definition: types.hpp:40
autoware::common::types::bool8_t
bool bool8_t
Definition: types.hpp:39
motion::motion_testing_nodes::details::wait_for_matched
std::chrono::nanoseconds wait_for_matched(const std::chrono::nanoseconds timeout, const std::chrono::nanoseconds poll_period, const ConditionF &condition)
Implementation of wait_for_matched.
Definition: wait_for_matched.hpp:34
lidar_integration::PointCloudMutationSpooferNode
Spoofs random point clouds which may or may not be properly formatted. Intended for use with mutation...
Definition: point_cloud_mutation_spoofer.hpp:36
autoware::common::types::float32_t
float float32_t
Definition: types.hpp:45
autoware::common::types::float64_t
double float64_t
Definition: types.hpp:47