mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-03-03 04:03:59 -04:00
SITL: attach a string with a mass on the end to servo gripper
This commit is contained in:
parent
f8918d15b1
commit
b751f836bb
@ -29,6 +29,8 @@ namespace SITL {
|
|||||||
parent class for all simulator types
|
parent class for all simulator types
|
||||||
*/
|
*/
|
||||||
class Aircraft {
|
class Aircraft {
|
||||||
|
friend class Gripper_Servo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Aircraft(const char *home_str, const char *frame_str);
|
Aircraft(const char *home_str, const char *frame_str);
|
||||||
|
|
||||||
|
@ -63,3 +63,11 @@ bool Gripper_Servo::should_report()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float Gripper_Servo::payload_mass() const
|
||||||
|
{
|
||||||
|
if (aircraft->hagl() < string_length) {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
return load_mass;
|
||||||
|
}
|
||||||
|
@ -33,8 +33,14 @@ public:
|
|||||||
// update Gripper state
|
// update Gripper state
|
||||||
void update(const struct Aircraft::sitl_input &input);
|
void update(const struct Aircraft::sitl_input &input);
|
||||||
|
|
||||||
|
float payload_mass() const; // kg
|
||||||
|
|
||||||
|
void set_aircraft(Aircraft *_aircraft) { aircraft = _aircraft; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Aircraft *aircraft;
|
||||||
|
|
||||||
const uint32_t report_interval = 1000000; // microseconds
|
const uint32_t report_interval = 1000000; // microseconds
|
||||||
uint64_t last_report_us;
|
uint64_t last_report_us;
|
||||||
|
|
||||||
@ -48,6 +54,10 @@ private:
|
|||||||
|
|
||||||
bool should_report();
|
bool should_report();
|
||||||
bool zero_report_done = false;
|
bool zero_report_done = false;
|
||||||
|
|
||||||
|
// dangle load from a string:
|
||||||
|
const float string_length = 2.0f; // metres
|
||||||
|
const float load_mass = 0.0f; // kilograms
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,8 @@ MultiCopter::MultiCopter(const char *home_str, const char *frame_str) :
|
|||||||
{
|
{
|
||||||
mass = 1.5f;
|
mass = 1.5f;
|
||||||
|
|
||||||
|
gripper.set_aircraft(this);
|
||||||
|
|
||||||
frame = Frame::find_frame(frame_str);
|
frame = Frame::find_frame(frame_str);
|
||||||
if (frame == nullptr) {
|
if (frame == nullptr) {
|
||||||
printf("Frame '%s' not found", frame_str);
|
printf("Frame '%s' not found", frame_str);
|
||||||
@ -81,5 +83,5 @@ void MultiCopter::update(const struct sitl_input &input)
|
|||||||
|
|
||||||
float MultiCopter::gross_mass() const
|
float MultiCopter::gross_mass() const
|
||||||
{
|
{
|
||||||
return Aircraft::gross_mass() + sprayer.payload_mass();
|
return Aircraft::gross_mass() + sprayer.payload_mass() + gripper.payload_mass();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user