CrazyFlie comms protocols
Posted: Sat Feb 08, 2014 1:42 am
Hi,
I am having a bit of difficulty with fully underrstanding the comms protocols for sending and receiving setpoints. I want to change the data in the setpoint to include more parameters as part of development of the control system. For example send P I and D values for the PID controller and also an altititude, so say 4 floating point numbers
setpoint(roll,pitch,yaw,thrust,P,I,D,altitude) for instance.
If i understand correctly, input.py uses these commands to send the setpoint using:
Line:101 sendControlSetpointSignal = pyqtSignal(float, float, float, int)
Line:296 self.sendControlSetpointSignal.emit(trimmed_rol, trimmed_pitch, yaw, thrust)[/color]
Assuming I have the variables taken care of correctly and the firmware updated to handle the incoming new setpoint, can I just change this code to:
Line:101 sendControlSetpointSignal = pyqtSignal(float, float, float, int, float, float, float,float)
Line:296 self.sendControlSetpointSignal.emit(trimmed_rol, trimmed_pitch, yaw, thrust, P, I, D, altitude)
or will there be consequences to this alteration that I am missing somewhere?
At the CrazyFlie end I think commander.c is receiving the setpoint data with:
void commanderGetRPY(float* eulerRollDesired, float* eulerPitchDesired, float* eulerYawDesired)
{
int usedSide = side;
*eulerRollDesired = targetVal[usedSide].roll;
*eulerPitchDesired = targetVal[usedSide].pitch;
*eulerYawDesired = targetVal[usedSide].yaw;
}
void commanderGetRPYType(RPYType* rollType, RPYType* pitchType, RPYType* yawType)
{
*rollType = ANGLE;
*pitchType = ANGLE;
*yawType = RATE;
}
void commanderGetThrust(uint16_t* thrust)
{
int usedSide = side;
uint16_t rawThrust = targetVal[usedSide].thrust;
Can I just add something like this after the commanderGetThrust:
void commanderGetPIDandAlt(float P, float I,float D,float Altitude)
{
P=targetVal[usedSide].P;
I=tagetVal[usedSide].I;
D=targetVal[usedSide].D;
Altitude=targetVal[usedSide].Altitide;
}
My brain can not handle programming in C and Python at the same time without overheating. Any help would be much appreciated!
Thanks Freddy
I am having a bit of difficulty with fully underrstanding the comms protocols for sending and receiving setpoints. I want to change the data in the setpoint to include more parameters as part of development of the control system. For example send P I and D values for the PID controller and also an altititude, so say 4 floating point numbers
setpoint(roll,pitch,yaw,thrust,P,I,D,altitude) for instance.
If i understand correctly, input.py uses these commands to send the setpoint using:
Line:101 sendControlSetpointSignal = pyqtSignal(float, float, float, int)
Line:296 self.sendControlSetpointSignal.emit(trimmed_rol, trimmed_pitch, yaw, thrust)[/color]
Assuming I have the variables taken care of correctly and the firmware updated to handle the incoming new setpoint, can I just change this code to:
Line:101 sendControlSetpointSignal = pyqtSignal(float, float, float, int, float, float, float,float)
Line:296 self.sendControlSetpointSignal.emit(trimmed_rol, trimmed_pitch, yaw, thrust, P, I, D, altitude)
or will there be consequences to this alteration that I am missing somewhere?
At the CrazyFlie end I think commander.c is receiving the setpoint data with:
void commanderGetRPY(float* eulerRollDesired, float* eulerPitchDesired, float* eulerYawDesired)
{
int usedSide = side;
*eulerRollDesired = targetVal[usedSide].roll;
*eulerPitchDesired = targetVal[usedSide].pitch;
*eulerYawDesired = targetVal[usedSide].yaw;
}
void commanderGetRPYType(RPYType* rollType, RPYType* pitchType, RPYType* yawType)
{
*rollType = ANGLE;
*pitchType = ANGLE;
*yawType = RATE;
}
void commanderGetThrust(uint16_t* thrust)
{
int usedSide = side;
uint16_t rawThrust = targetVal[usedSide].thrust;
Can I just add something like this after the commanderGetThrust:
void commanderGetPIDandAlt(float P, float I,float D,float Altitude)
{
P=targetVal[usedSide].P;
I=tagetVal[usedSide].I;
D=targetVal[usedSide].D;
Altitude=targetVal[usedSide].Altitide;
}
My brain can not handle programming in C and Python at the same time without overheating. Any help would be much appreciated!
Thanks Freddy