Dear Bitcraze,
we would like to use CPPM Receiver with Position Hold for our Application, therefore we are using the Flowdeck for that.
While flying with Crazy Radio the Position Hold works flawlessly, I can't figure out how to use Position Hold with CPPM Input though.
What can I do to configure Channel 5 or 6 of the CPPM Lib ( extra.c) to activate Position Hold (through Optical Flow / FlowDeck)?
Thank you in Advance.
4things
Position Hold with Flowdeck and CPPM input
Re: Position Hold with Flowdeck and CPPM input
Easiest is probably if you rewrite the ALT hold part and change it to Position hold. This mode is the hoverDecoder in crtp_commander_generic.c. You would have to scale the CPPM input properly.
Without testing it, I think it would look something like this:
Without testing it, I think it would look something like this:
Code: Select all
if (extRxAltHold)
{
extrxSetpoint.thrust = 0;
extrxSetpoint.mode.z = modeVelocity;
extrxSetpoint.velocity.z = cppmConvert2Float(ch[EXTRX_CH_THRUST], -1, 1, EXTRX_DEADBAND_ZVEL);
extrxSetpoint->mode.yaw = modeVelocity;
extrxSetpoint->attitudeRate.yaw = EXTRX_SIGN_YAW * EXTRX_SCALE_YAW *cppmConvert2Float(ch[EXTRX_CH_YAW], -1, 1, EXTRX_DEADBAND_YAW);
extrxSetpoint->mode.x = modeVelocity;
extrxSetpoint->mode.y = modeVelocity;
extrxSetpoint->velocity.x = cppmConvert2Float(ch[EXTRX_CH_ROLL], -1, 1, EXTRX_DEADBAND_ZVEL);
extrxSetpoint->velocity.y = cppmConvert2Float(ch[EXTRX_CH_PITCH], -1, 1, EXTRX_DEADBAND_ZVEL);
extrxSetpoint->velocity_body = true;
}
else
{
extrxSetpoint.mode.z = modeDisable;
extrxSetpoint.thrust = cppmConvert2uint16(ch[EXTRX_CH_THRUST]);
extrxSetpoint.attitude.roll = EXTRX_SIGN_ROLL * EXTRX_SCALE_ROLL * cppmConvert2Float(ch[EXTRX_CH_ROLL], -1, 1, EXTRX_DEADBAND_ROLL);
extrxSetpoint.attitude.pitch = EXTRX_SIGN_PITCH * EXTRX_SCALE_PITCH * cppmConvert2Float(ch[EXTRX_CH_PITCH], -1, 1, EXTRX_DEADBAND_PITCH);
extrxSetpoint.attitudeRate.yaw = EXTRX_SIGN_YAW * EXTRX_SCALE_YAW *cppmConvert2Float(ch[EXTRX_CH_YAW], -1, 1, EXTRX_DEADBAND_YAW);
}
extRxAltHoldPrev = extRxAltHold;
#else
extrxSetpoint.mode.z = modeDisable;
extrxSetpoint.thrust = cppmConvert2uint16(ch[EXTRX_CH_THRUST]);
extrxSetpoint.attitude.roll = EXTRX_SIGN_ROLL * EXTRX_SCALE_ROLL * cppmConvert2Float(ch[EXTRX_CH_ROLL], -1, 1, EXTRX_DEADBAND_ROLL);
extrxSetpoint.attitude.pitch = EXTRX_SIGN_PITCH * EXTRX_SCALE_PITCH * cppmConvert2Float(ch[EXTRX_CH_PITCH], -1, 1, EXTRX_DEADBAND_PITCH);
extrxSetpoint.attitudeRate.yaw = EXTRX_SIGN_YAW * EXTRX_SCALE_YAW *cppmConvert2Float(ch[EXTRX_CH_YAW], -1, 1, EXTRX_DEADBAND_YAW);
#endif
commanderSetSetpoint(&extrxSetpoint, COMMANDER_PRIORITY_EXTRX);
Re: Position Hold with Flowdeck and CPPM input
thank you so much that worked perfectly.
only one change need to be done
needs to be changed to
the whole change to extrx.c (https://github.com/bitcraze/crazyflie-f ... trx.c#L202:
only one change need to be done
Code: Select all
extrxSetpoint.velocity.x = cppmConvert2Float(ch[EXTRX_CH_ROLL], -1, 1, EXTRX_DEADBAND_ZVEL);
extrxSetpoint.velocity.y = cppmConvert2Float(ch[EXTRX_CH_PITCH], -1, 1, EXTRX_DEADBAND_ZVEL);
Code: Select all
extrxSetpoint.velocity.y = cppmConvert2Float(ch[EXTRX_CH_ROLL], -1, 1, EXTRX_DEADBAND_ZVEL);
extrxSetpoint.velocity.x = cppmConvert2Float(ch[EXTRX_CH_PITCH], -1, 1, EXTRX_DEADBAND_ZVEL);
Code: Select all
if (extRxAltHold)
{
extrxSetpoint.thrust = 0;
extrxSetpoint.mode.z = modeVelocity;
extrxSetpoint.velocity.z = cppmConvert2Float(ch[EXTRX_CH_THRUST], -1, 1, EXTRX_DEADBAND_ZVEL);
extrxSetpoint->mode.yaw = modeVelocity;
extrxSetpoint->attitudeRate.yaw = EXTRX_SIGN_YAW * EXTRX_SCALE_YAW *cppmConvert2Float(ch[EXTRX_CH_YAW], -1, 1, EXTRX_DEADBAND_YAW);
extrxSetpoint->mode.x = modeVelocity;
extrxSetpoint->mode.y = modeVelocity;
extrxSetpoint->velocity.y = cppmConvert2Float(ch[EXTRX_CH_ROLL], -1, 1, EXTRX_DEADBAND_ZVEL);
extrxSetpoint->velocity.x = cppmConvert2Float(ch[EXTRX_CH_PITCH], -1, 1, EXTRX_DEADBAND_ZVEL);
extrxSetpoint->velocity_body = true;
}
else
{
extrxSetpoint.mode.z = modeDisable;
extrxSetpoint.thrust = cppmConvert2uint16(ch[EXTRX_CH_THRUST]);
extrxSetpoint.attitude.roll = EXTRX_SIGN_ROLL * EXTRX_SCALE_ROLL * cppmConvert2Float(ch[EXTRX_CH_ROLL], -1, 1, EXTRX_DEADBAND_ROLL);
extrxSetpoint.attitude.pitch = EXTRX_SIGN_PITCH * EXTRX_SCALE_PITCH * cppmConvert2Float(ch[EXTRX_CH_PITCH], -1, 1, EXTRX_DEADBAND_PITCH);
extrxSetpoint.attitudeRate.yaw = EXTRX_SIGN_YAW * EXTRX_SCALE_YAW *cppmConvert2Float(ch[EXTRX_CH_YAW], -1, 1, EXTRX_DEADBAND_YAW);
}
extRxAltHoldPrev = extRxAltHold;
#else
extrxSetpoint.mode.z = modeDisable;
extrxSetpoint.thrust = cppmConvert2uint16(ch[EXTRX_CH_THRUST]);
extrxSetpoint.attitude.roll = EXTRX_SIGN_ROLL * EXTRX_SCALE_ROLL * cppmConvert2Float(ch[EXTRX_CH_ROLL], -1, 1, EXTRX_DEADBAND_ROLL);
extrxSetpoint.attitude.pitch = EXTRX_SIGN_PITCH * EXTRX_SCALE_PITCH * cppmConvert2Float(ch[EXTRX_CH_PITCH], -1, 1, EXTRX_DEADBAND_PITCH);
extrxSetpoint.attitudeRate.yaw = EXTRX_SIGN_YAW * EXTRX_SCALE_YAW *cppmConvert2Float(ch[EXTRX_CH_YAW], -1, 1, EXTRX_DEADBAND_YAW);
#endif
commanderSetSetpoint(&extrxSetpoint, COMMANDER_PRIORITY_EXTRX);