Autonomous Racing  1
f1tenth Project Group of Technical University Dortmund, Germany
wall.cpp
Go to the documentation of this file.
1 #include "wall.h"
2 
3 Wall::Wall(float angle1, float angle2, float range1, float range2)
4  : m_angle1{ angle1 }
5  , m_angle2{ angle2 }
6  , m_range1{ range1 }
7  , m_range2{ range2 }
8 {
9 }
10 
12 {
13  return std::atan((m_range1 * std::cos(std::abs(m_angle1 - m_angle2)) - m_range2) / m_range1 *
14  std::sin(std::abs(m_angle1 - m_angle2)));
15 }
16 
17 float Wall::predictDistance(float distancce_to_current_position)
18 {
19  float angle = this->getAngle();
20  float currentWallDistance = m_range2 * std::cos(angle);
21  return currentWallDistance + distancce_to_current_position * std::sin(angle);
22 }
23 
24 void Wall::draw(RvizGeometryPublisher& geometry, int id, std_msgs::ColorRGBA color)
25 {
26  geometry.drawLine(id, createPoint(m_range1 * std::cos(m_angle1), m_range1 * std::sin(m_angle1), 0.0f),
27  createPoint(m_range2 * std::cos(m_angle2), m_range2 * std::sin(m_angle2), 0.0f), color, 0.03);
28 }
float m_angle1
Definition: wall.h:10
Wall(float angle1, float angle2, float range1, float range2)
Definition: wall.cpp:3
float m_angle2
Definition: wall.h:11
float getAngle()
Definition: wall.cpp:11
float m_range1
Definition: wall.h:12
float predictDistance(float distancce_to_current_position)
Definition: wall.cpp:17
void draw(RvizGeometryPublisher &geometry, int id, std_msgs::ColorRGBA color)
Definition: wall.cpp:24
float m_range2
Definition: wall.h:13
void drawLine(int id, geometry_msgs::Point point1, geometry_msgs::Point point2, std_msgs::ColorRGBA color, float width)
geometry_msgs::Point createPoint(float x, float y, float z)