Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SITL: add simulated slung payload #27536

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions libraries/SITL/SIM_Aircraft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,11 @@ void Aircraft::update_dynamics(const Vector3f &rot_accel)
}
}

// update slung payload
#if AP_SIM_SLUNGPAYLOAD_ENABLED
sitl->models.slung_payload_sim.update(get_position_relhome(), velocity_ef, accel_earth);
#endif

// allow for changes in physics step
adjust_frame_time(constrain_float(sitl->loop_rate_hz, rate_hz-1, rate_hz+1));
}
Expand Down Expand Up @@ -1227,6 +1232,19 @@ void Aircraft::add_twist_forces(Vector3f &rot_accel)
}
}

#if AP_SIM_SLUNGPAYLOAD_ENABLED
// add body-frame force due to slung payload
void Aircraft::add_slungpayload_forces(Vector3f &body_accel)
{
Vector3f forces_ef;
sitl->models.slung_payload_sim.get_forces_on_vehicle(forces_ef);

// convert ef forces to body-frame accelerations (acceleration = force / mass)
const Vector3f accel_bf = dcm.transposed() * forces_ef / mass;
body_accel += accel_bf;
}
#endif

/*
get position relative to home
*/
Expand Down
5 changes: 5 additions & 0 deletions libraries/SITL/SIM_Aircraft.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ class Aircraft {
void add_shove_forces(Vector3f &rot_accel, Vector3f &body_accel);
void add_twist_forces(Vector3f &rot_accel);

#if AP_SIM_SLUNGPAYLOAD_ENABLED
// add body-frame force due to slung payload
void add_slungpayload_forces(Vector3f &body_accel);
#endif

// get local thermal updraft
float get_local_updraft(const Vector3d &currentPos);

Expand Down
5 changes: 5 additions & 0 deletions libraries/SITL/SIM_Multicopter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ void MultiCopter::calculate_forces(const struct sitl_input &input, Vector3f &rot

add_shove_forces(rot_accel, body_accel);
add_twist_forces(rot_accel);

#if AP_SIM_SLUNGPAYLOAD_ENABLED
// add forces from slung payload
rmackay9 marked this conversation as resolved.
Show resolved Hide resolved
add_slungpayload_forces(body_accel);
#endif
}

/*
Expand Down
Loading
Loading