...
This commit is contained in:
@@ -92,23 +92,26 @@ std::pair<double, double> mcc_compute_distance(mcc_telemetry_data_c auto const&
|
||||
{
|
||||
std::pair<double, double> res;
|
||||
|
||||
// first, check if the mount will stop after given time_in_secs to prevent traveled path to be
|
||||
// negative
|
||||
// first, check if the mount stops before time_in_secs
|
||||
//
|
||||
// the time to stop mount: (V_ini - a*t) = 0 => t = V_ini/a
|
||||
//
|
||||
// the traveled path: s = V_ini*t - a*t*t/2, V_ini - initial speed, a - braking accel, t - the time
|
||||
// then, for s>=0, t <= 2*V_ini/a
|
||||
//
|
||||
|
||||
double term_x = 2.0 * std::abs(tdata.speedX) / braking_accelX;
|
||||
double term_y = 2.0 * std::abs(tdata.speedY) / braking_accelY;
|
||||
|
||||
// time to stop mount with given current speed and braking acceleration
|
||||
double tx_stop = std::abs(tdata.speedX) / braking_accelX;
|
||||
double ty_stop = std::abs(tdata.speedY) / braking_accelY;
|
||||
|
||||
double tx = time_in_secs;
|
||||
double ty = time_in_secs;
|
||||
|
||||
if (std::isfinite(term_x) && (time_in_secs > term_x)) {
|
||||
tx = term_x;
|
||||
if (std::isfinite(tx_stop) && (time_in_secs > tx_stop)) {
|
||||
tx = tx_stop;
|
||||
}
|
||||
if (std::isfinite(term_y) && (time_in_secs > term_y)) {
|
||||
ty = term_y;
|
||||
if (std::isfinite(ty_stop) && (time_in_secs > ty_stop)) {
|
||||
ty = ty_stop;
|
||||
}
|
||||
|
||||
// here, one must take into account the sign of the speed!!!
|
||||
|
||||
Reference in New Issue
Block a user