Autonomous Racing  1
f1tenth Project Group of Technical University Dortmund, Germany
emergency_stop.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <array>
4 #include <cmath>
5 #include <cstdlib>
6 #include <iostream>
7 
8 #include "drive_msgs/drive_param.h"
10 #include "sensor_msgs/LaserScan.h"
11 #include <ros/console.h>
12 #include <ros/ros.h>
13 
14 #include <dynamic_reconfigure/server.h>
15 #include <emergency_stop/emergency_stopConfig.h>
16 
17 constexpr float DEG_TO_RAD = M_PI / 180.0;
18 
19 constexpr const char* TOPIC_LASER_SCAN = "/scan";
20 constexpr const char* TOPIC_EMERGENCY_STOP = "/input/emergencystop";
21 constexpr const char* TOPIC_VISUALIZATION = "/emergencystop_visualization";
22 
23 constexpr const char* LIDAR_FRAME = "laser";
24 
25 enum class EmergencyStatus : int
26 {
27  UNUSED = 0,
28  ACTIVATED = 1,
29  CLEARED = 2
30 };
31 
33 {
34  public:
35  EmergencyStop();
36 
37  private:
38  ros::NodeHandle m_node_handle;
39  ros::Subscriber m_lidar_subscriber;
40  ros::Publisher m_emergency_stop_publisher;
41 
42  EmergencyStatus m_emergency_status;
43  RvizGeometryPublisher m_debug_geometry;
44  dynamic_reconfigure::Server<emergency_stop::emergency_stopConfig> m_dyn_cfg_server;
45 
46  float m_range_threshold = 0.7;
47  float m_car_bumper_length = 0.35;
48  float m_max_range = 30;
49 
53  bool emergencyStop(const sensor_msgs::LaserScan::ConstPtr& lidar);
54 
55  void lidarCallback(const sensor_msgs::LaserScan::ConstPtr& lidar);
56 
57  void updateDynamicConfig();
58 };
constexpr const char * TOPIC_LASER_SCAN
constexpr const char * LIDAR_FRAME
constexpr const char * TOPIC_VISUALIZATION
EmergencyStatus
constexpr float DEG_TO_RAD
constexpr const char * TOPIC_EMERGENCY_STOP