// straight-fast - vehicle is moving, previous segment is straight. vehicle will fly straight through the waypoint before beginning it's spline path to the next wp
// _flag.segment_type holds whether prev segment is straight vs spline but we don't know if it has a delay
// spline-fast - vehicle is moving, previous segment is splined, vehicle will fly through waypoint but previous segment should have it flying in the correct direction (i.e. exactly parallel to position difference vector from previous segment's origin to this segment's destination)
// calculate spline velocity at origin
if(stopped_at_start){
// if vehicle is stopped at the origin, set origin velocity to 0.1 * distance vector from origin to destination
_spline_origin_vel=(destination-origin)*0.1f;
_spline_time=0.0f;
_spline_vel_scaler=0.0f;
}else{
// look at previous segment to determine velocity at origin
if(prev_segment_exists){
if(_flags.segment_type==SEGMENT_STRAIGHT){
// previous segment is straight, vehicle is moving so vehicle should fly straight through the origin
// before beginning it's spline path to the next waypoint. Note: we are using the previous segment's origin and destination
_spline_origin_vel=(_destination-_origin);
_spline_time=0.0f;// To-Do: this should be set based on how much overrun there was from straight segment?
_spline_vel_scaler=0.0f;// To-Do: this should be set based on speed at end of prev straight segment?
}else{
// previous segment is splined, vehicle will fly through origin
// we can use the previous segment's destination velocity as this segment's origin velocity
// Note: previous segment will leave destination velocity parallel to position difference vector
// from previous segment's origin to this segment's destination)
_spline_origin_vel=_spline_destination_vel;
if(_spline_time>1.0f&&_spline_time<1.1f){// To-Do: remove hard coded 1.1f
_spline_time-=1.0f;
}else{
_spline_time=0.0f;
}
_spline_vel_scaler=0.0f;
}
}
}
// calculate spline velocity at destination
switch(seg_end_type){
caseSEGMENT_END_STOP:
// if vehicle stops at the destination set destination velocity to 0.1 * distance vector from origin to destination
/// calculate_wp_leash_length - calculates track speed, acceleration and leash lengths for waypoint controller
voidcalculate_wp_leash_length();
///
/// spline methods
///
// segment start types
// stop - vehicle is not moving at origin
// straight-fast - vehicle is moving, previous segment is straight. vehicle will fly straight through the waypoint before beginning it's spline path to the next wp
// _flag.segment_type holds whether prev segment is straight vs spline but we don't know if it has a delay
// spline-fast - vehicle is moving, previous segment is splined, vehicle will fly through waypoint but previous segment should have it flying in the correct direction (i.e. exactly parallel to position difference vector from previous segment's origin to this segment's destination)
// segment end types
// stop - vehicle is not moving at destination
// straight-fast - next segment is straight, vehicle's destination velocity should be directly along track from this segment's destination to next segment's destination
// spline-fast - next segment is spline, vehicle's destination velocity should be parallel to position difference vector from previous segment's origin to this segment's destination
/// set_spline_destination waypoint using position vector (distance from home in cm)
/// stopped_at_start should be set to true if vehicle is stopped at the origin
/// seg_end_type should be set to stopped, straight or spline depending upon the next segment's type
/// next_destination should be set to the next segment's destination if the seg_end_type is SEGMENT_END_STRAIGHT or SEGMENT_END_SPLINE
/// advance_wp_target_along_track - move target location along track from origin to destination
voidadvance_wp_target_along_track(floatdt);
staticconststructAP_Param::GroupInfovar_info[];
protected:
// segment types, either straight or spine
enumSegmentType{
SEGMENT_STRAIGHT=0,
SEGMENT_SPLINE=1
};
// flags structure
structwpnav_flags{
uint8_treached_destination:1;// true if we have reached the destination
uint8_tfast_waypoint:1;// true if we should ignore the waypoint radius and consider the waypoint complete once the intermediate target has reached the waypoint
SegmentTypesegment_type:1;// active segment is either straight or spline
}_flags;
/// calc_loiter_desired_velocity - updates desired velocity (i.e. feed forward) with pilot requested acceleration and fake wind resistance