Custom Function in copter.cpp's AP_Scheduler

Hello everyone,

I want to use ArduPilot to enable the ballistic launch of a multicopter.
For this I want to be able to read accelerometer data and arm the motors when the craft has left the launch tube, however have been unable to access raw accelerometer data within the C++ code.
Inside the scheduler I’ve added the function

SCHED_TASK(check_launch, 50, 200, 14),

which should check the accelerometer value 50 times a second, taking around 200ms to complete. If a certain acceleration is measured the motors should be armed once a) a certain time has elapsed b) once the maximum ballistic height is reached and acceleration is measured to be standard 1g.

I have found a code snippet coming close to what I want but it doesn’t access the current accelerometer object, it is just a function expecting to be given a memory address to an accelerometer object.

void GCS_MAVLINK::send_raw_imu(const AP_InertialSensor &ins, const Compass &compass)
    const Vector3f &accel = ins.get_accel(0);
    const Vector3f &gyro = ins.get_gyro(0);
    const Vector3f &mag = compass.get_field(0);

Is there a repo with all syntax and functions? How can I access accelerometer data and how do I tell the motors to arm?

Any help is appreciated, thanks!

Have a look at throw mode - that’s got to be close to what you need


Thanks, I though I already looked at the Throw mode .cpp but welp, I didn’t. Yes, that does seem like what I need, tyvm.

1 Like