SIM_Aircraft: move advance in time from update_position to time_advance
This commit is contained in:
parent
579f655e76
commit
b176ba53d7
@ -159,17 +159,6 @@ void Aircraft::update_position(void)
|
||||
|
||||
location.alt = static_cast<int32_t>(home.alt - position.z * 100.0f);
|
||||
|
||||
// we only advance time if it hasn't been advanced already by the
|
||||
// backend
|
||||
// TODO : make this a function
|
||||
if (last_time_us == time_now_us) {
|
||||
time_now_us += frame_time_us;
|
||||
}
|
||||
last_time_us = time_now_us;
|
||||
if (use_time_sync) {
|
||||
sync_frame_time();
|
||||
}
|
||||
|
||||
#if 0
|
||||
// logging of raw sitl data
|
||||
Vector3f accel_ef = dcm * accel_body;
|
||||
@ -217,9 +206,17 @@ void Aircraft::update_mag_field_bf()
|
||||
}
|
||||
|
||||
/* advance time by deltat in seconds */
|
||||
void Aircraft::time_advance(float deltat)
|
||||
void Aircraft::time_advance()
|
||||
{
|
||||
time_now_us += deltat * 1.0e6f;
|
||||
// we only advance time if it hasn't been advanced already by the
|
||||
// backend
|
||||
if (last_time_us == time_now_us) {
|
||||
time_now_us += frame_time_us;
|
||||
}
|
||||
last_time_us = time_now_us;
|
||||
if (use_time_sync) {
|
||||
sync_frame_time();
|
||||
}
|
||||
}
|
||||
|
||||
/* setup the frame step time */
|
||||
|
@ -191,7 +191,7 @@ protected:
|
||||
void update_mag_field_bf(void);
|
||||
|
||||
/* advance time by deltat in seconds */
|
||||
void time_advance(float deltat);
|
||||
void time_advance();
|
||||
|
||||
/* setup the frame step time */
|
||||
void setup_frame_time(float rate, float speedup);
|
||||
|
@ -70,6 +70,7 @@ void Balloon::update(const struct sitl_input &input)
|
||||
|
||||
// update lat/lon/altitude
|
||||
update_position();
|
||||
time_advance();
|
||||
|
||||
// update magnetic field
|
||||
update_mag_field_bf();
|
||||
|
@ -151,6 +151,7 @@ void CRRCSim::update(const struct sitl_input &input)
|
||||
send_servos(input);
|
||||
recv_fdm(input);
|
||||
update_position();
|
||||
time_advance();
|
||||
|
||||
// update magnetic field
|
||||
update_mag_field_bf();
|
||||
|
@ -48,6 +48,7 @@ void SITL::Calibration::update(const struct sitl_input& input)
|
||||
accel_body(0, 0, 0);
|
||||
update_dynamics(rot_accel);
|
||||
update_position();
|
||||
time_advance();
|
||||
|
||||
// update magnetic field
|
||||
update_mag_field_bf();
|
||||
|
@ -366,6 +366,7 @@ void FlightAxis::update(const struct sitl_input &input)
|
||||
}
|
||||
|
||||
update_position();
|
||||
time_advance();
|
||||
time_now_us = (state.m_currentPhysicsTime_SEC - initial_time_s)*1.0e6;
|
||||
|
||||
if (frame_counter++ % 1000 == 0) {
|
||||
|
@ -164,6 +164,7 @@ void Gazebo::update(const struct sitl_input &input)
|
||||
recv_fdm(input);
|
||||
update_position();
|
||||
|
||||
time_advance();
|
||||
// update magnetic field
|
||||
update_mag_field_bf();
|
||||
drain_sockets();
|
||||
|
@ -164,6 +164,7 @@ void Helicopter::update(const struct sitl_input &input)
|
||||
|
||||
// update lat/lon/altitude
|
||||
update_position();
|
||||
time_advance();
|
||||
|
||||
// update magnetic field
|
||||
update_mag_field_bf();
|
||||
|
@ -69,6 +69,7 @@ void MultiCopter::update(const struct sitl_input &input)
|
||||
|
||||
// update lat/lon/altitude
|
||||
update_position();
|
||||
time_advance();
|
||||
|
||||
// update magnetic field
|
||||
update_mag_field_bf();
|
||||
|
@ -316,6 +316,7 @@ void Plane::update(const struct sitl_input &input)
|
||||
|
||||
// update lat/lon/altitude
|
||||
update_position();
|
||||
time_advance();
|
||||
|
||||
// update magnetic field
|
||||
update_mag_field_bf();
|
||||
|
@ -114,6 +114,7 @@ void QuadPlane::update(const struct sitl_input &input)
|
||||
|
||||
// update lat/lon/altitude
|
||||
update_position();
|
||||
time_advance();
|
||||
|
||||
// update magnetic field
|
||||
update_mag_field_bf();
|
||||
|
@ -151,6 +151,7 @@ void SimRover::update(const struct sitl_input &input)
|
||||
|
||||
// update lat/lon/altitude
|
||||
update_position();
|
||||
time_advance();
|
||||
|
||||
// update magnetic field
|
||||
update_mag_field_bf();
|
||||
|
@ -101,6 +101,7 @@ void SingleCopter::update(const struct sitl_input &input)
|
||||
|
||||
// update lat/lon/altitude
|
||||
update_position();
|
||||
time_advance();
|
||||
|
||||
// update magnetic field
|
||||
update_mag_field_bf();
|
||||
|
@ -107,6 +107,7 @@ void Submarine::update(const struct sitl_input &input)
|
||||
|
||||
// update lat/lon/altitude
|
||||
update_position();
|
||||
time_advance();
|
||||
|
||||
// update magnetic field
|
||||
update_mag_field_bf();
|
||||
|
@ -134,6 +134,7 @@ void Tracker::update(const struct sitl_input &input)
|
||||
// new velocity vector
|
||||
velocity_ef.zero();
|
||||
update_position();
|
||||
time_advance();
|
||||
|
||||
// update magnetic field
|
||||
update_mag_field_bf();
|
||||
|
@ -297,6 +297,7 @@ bool XPlane::receive_data(void)
|
||||
}
|
||||
position = pos + position_zero;
|
||||
update_position();
|
||||
time_advance();
|
||||
|
||||
accel_earth = dcm * accel_body;
|
||||
accel_earth.z += GRAVITY_MSS;
|
||||
@ -314,6 +315,7 @@ bool XPlane::receive_data(void)
|
||||
position.y = 0;
|
||||
position.z = 0;
|
||||
update_position();
|
||||
time_advance();
|
||||
}
|
||||
|
||||
update_mag_field_bf();
|
||||
@ -355,6 +357,7 @@ failed:
|
||||
velocity_air_bf = dcm.transposed() * velocity_air_ef;
|
||||
|
||||
update_position();
|
||||
time_advance();
|
||||
update_mag_field_bf();
|
||||
report.frame_count++;
|
||||
return false;
|
||||
|
@ -130,6 +130,7 @@ void last_letter::update(const struct sitl_input &input)
|
||||
sync_frame_time();
|
||||
|
||||
update_position();
|
||||
time_advance();
|
||||
// update magnetic field
|
||||
update_mag_field_bf();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user