mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
TrajMath: replace type placeholder with floats
This commit is contained in:
committed by
Mathieu Bresciani
parent
e9ab6a75ba
commit
e6b7062442
@@ -54,12 +54,11 @@ namespace trajmath
|
|||||||
*
|
*
|
||||||
* @return maximum speed
|
* @return maximum speed
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
float computeMaxSpeedFromBrakingDistance(const float jerk, const float accel, const float braking_distance)
|
||||||
const T computeMaxSpeedFromBrakingDistance(T jerk, T accel, T braking_distance)
|
|
||||||
{
|
{
|
||||||
T b = (T) 4 * accel * accel / jerk;
|
float b = 4.0f * accel * accel / jerk;
|
||||||
T c = - (T) 2 * accel * braking_distance;
|
float c = - 2.0f * accel * braking_distance;
|
||||||
T max_speed = (T) 0.5 * (-b + sqrtf(b * b - (T) 4 * c));
|
float max_speed = 0.5f * (-b + sqrtf(b * b - 4.0f * c));
|
||||||
|
|
||||||
return max_speed;
|
return max_speed;
|
||||||
}
|
}
|
||||||
@@ -78,11 +77,10 @@ const T computeMaxSpeedFromBrakingDistance(T jerk, T accel, T braking_distance)
|
|||||||
*
|
*
|
||||||
* @return maximum tangential speed
|
* @return maximum tangential speed
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
float computeMaxSpeedInWaypoint(const float alpha, const float accel, const float d)
|
||||||
const T computeMaxSpeedInWaypoint(T alpha, T accel, T d)
|
|
||||||
{
|
{
|
||||||
T tan_alpha = tan(alpha / (T) 2);
|
float tan_alpha = tanf(alpha / 2.0f);
|
||||||
T max_speed_in_turn = sqrtf(accel * d * tan_alpha);
|
float max_speed_in_turn = sqrtf(accel * d * tan_alpha);
|
||||||
|
|
||||||
return max_speed_in_turn;
|
return max_speed_in_turn;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user