Autonomous Racing  1
f1tenth Project Group of Technical University Dortmund, Germany
crash_detector.cpp
Go to the documentation of this file.
1 #include "crash_detector.h"
2 
4 {
5  this->m_crash_publisher = this->m_ros_node_handle.advertise<std_msgs::Empty>(TOPIC_CRASH, 1);
6  this->m_gazebo_node = gazebo::transport::NodePtr(new gazebo::transport::Node());
7  this->m_gazebo_node->Init();
8  this->m_walls_sensor_subscriber =
9  this->m_gazebo_node->Subscribe(TOPIC_GAZEBO_SENSOR_WALLS, &CrashDetector::gazeboTopicCallback, this);
10  this->m_decoration_sensor_subscriber =
11  this->m_gazebo_node->Subscribe(TOPIC_GAZEBO_SENSOR_DECORATION, &CrashDetector::gazeboTopicCallback, this);
12 }
13 
14 void CrashDetector::gazeboTopicCallback(ConstContactsPtr& gazebo_message)
15 {
16  if (gazebo_message->contact_size() != 0)
17  {
18  std_msgs::Empty ros_message;
19  this->m_crash_publisher.publish(ros_message);
20  }
21 }
22 
23 int main(int argc, char** argv)
24 {
25  ros::init(argc, argv, "crash_detector");
26  gazebo::client::setup(argc, argv);
27 
28  CrashDetector crash_detector;
29 
30  ros::spin();
31 
32  gazebo::client::shutdown();
33  return EXIT_SUCCESS;
34 }
int main(int argc, char **argv)
constexpr const char * TOPIC_GAZEBO_SENSOR_DECORATION
constexpr const char * TOPIC_CRASH
ROS node that listens on a gazebo topic for collisions and publishes to a ROS topic.
constexpr const char * TOPIC_GAZEBO_SENSOR_WALLS