Galaxis Codebase  1.0.0
Team Galaxis software stack for the Carolo Cup 2023 - ROS2 based software
galaxis::control Namespace Reference

Classes

class  CarPose
 
class  TwoAndAHalfCarrots
 

Typedefs

typedef std::vector< std::shared_ptr< CarPose > > CarPoseSeries
 

Functions

std::shared_ptr< CarPose > get_new_pose (std::shared_ptr< CarPose > const p_currentPoseSPtr, float p_carWheelbase, float p_distance, float p_yawDiff)
 
std::ostream & operator<< (std::ostream &strm, CarPose const &pose)
 

Typedef Documentation

◆ CarPoseSeries

typedef std::vector<std::shared_ptr<CarPose> > galaxis::control::CarPoseSeries

Definition at line 20 of file pose.hpp.

Function Documentation

◆ get_new_pose()

std::shared_ptr< CarPose > galaxis::control::get_new_pose ( std::shared_ptr< CarPose > const  p_currentPoseSPtr,
float  p_carWheelbase,
float  p_distance,
float  p_yawDiff 
)

Definition at line 168 of file control.cpp.

168  {
169  std::shared_ptr<CarPose> newPoseSPtr = std::make_shared<CarPose>();
170  newPoseSPtr->position = p_currentPoseSPtr->position;
171  newPoseSPtr->orientation = p_currentPoseSPtr->orientation;
172 
173  Eigen::Rotation2Df rotation(p_currentPoseSPtr->orientation);
174 
175  // filter edge case
176  if(std::sin(p_yawDiff) == 0) {
177  Eigen::Vector2f distance(p_distance, 0);
178  newPoseSPtr->position += rotation * distance;
179  return newPoseSPtr;
180  }
181 
182  // r = L/sin(steering_angle)
183  float radiusOfSteeringCircle = p_carWheelbase / std::sin(p_yawDiff);
184  // U = 2PI * r
185  float steeringCircumference = 2 * MATH_PI * radiusOfSteeringCircle;
186  // angle = distance / circumference * 2PI
187  float circleDrivenAngle = p_distance / steeringCircumference * 2 * MATH_PI;
188 
189  float directDistanceBetweenStartAndNewPose = 2 * std::sin(circleDrivenAngle / 2) * radiusOfSteeringCircle;
190 
191  Eigen::Vector2f position(0, 0);
192  position[0] = directDistanceBetweenStartAndNewPose * std::cos(circleDrivenAngle / 2);
193  position[1] = directDistanceBetweenStartAndNewPose * std::sin(circleDrivenAngle / 2);
194 
195  // Rotate new position with old orientation
196  position = rotation * position;
197 
198  newPoseSPtr->position += position;
199  newPoseSPtr->orientation += circleDrivenAngle;
200 
201  return newPoseSPtr;
202 }

References MATH_PI.

Referenced by galaxis::control::TwoAndAHalfCarrots::get_pose_series(), and SimulationAdapterNode::updatePose().

Here is the caller graph for this function:

◆ operator<<()

std::ostream& galaxis::control::operator<< ( std::ostream &  strm,
CarPose const &  pose 
)

Definition at line 13 of file pose.cpp.

13  {
14  return strm << "(" << pose.position[0] << ", " << pose.position[1] << "; " << pose.orientation << ")";
15 }

References galaxis::control::CarPose::orientation, and galaxis::control::CarPose::position.

galaxis::lina::Vector2f
Eigen::Vector2f Vector2f
Definition: linatypes.hpp:14
MATH_PI
constexpr float MATH_PI
Definition: control.hpp:16