Jason Short has made it easy for ArduPilot users. In the Events tab of 2.7, there is an example of egg-drop code that even has an equation to calculate the proper distance from the target. It assumes you've added Channel 4 control to your ArduPilot. Just set a waypoint for your egg (it's waypoint 3 in the sample code below), hook Channel 4 to a servo that releases the egg, and start dropping!
"void mediumLoop_event(void)
{
/*
float temp = (float)(current_loc.alt - home.alt) * .01;
egg_dist = sqrt(temp / 4.903) * (float)ground_speed *.01;
if(wp_index == 3){
wp_radius = 10;
if(wp_distance < egg_dist){
servo_out[CH_RUDDER] = PAYLOAD_OPEN;
}
}else{
wp_radius = 20;
servo_out[CH_RUDDER] = PAYLOAD_CLOSED;
}
*/
}
Comments
1.)