Commit 4e761445 authored by Ian McInerney's avatar Ian McInerney

Added computation rate adjustment

parent 9ed78882
......@@ -87,6 +87,7 @@ enum Computation_channels {
enum comp_config_codes {
COMP_CONFIG_ENABLE = 0,
COMP_CONFIG_FUNC,
COMP_CONFIG_RATE,
};
// Numbers specified here must match the quadcopter ID numbers
......@@ -408,6 +409,14 @@ class CCrazyflie {
void disableComputation();
void configureComputation( void *config, uint8_t length);
/**
* Set the computation data rate in Hz.
* Note: Maximum rate of 1000 Hz.
*
* @param rate The computation rate in Hz
*/
void setComputationRate(uint16_t rate);
/**
* Reset the controller on the quadcopter
*/
......
......@@ -73,6 +73,30 @@ void CCrazyflie::disableComputation() {
this->computationStarted = false;
}
/**
* Set the computation data rate in Hz.
* Note: Maximum rate of 1000 Hz.
*
* @param rate The computation rate in Hz
*/
void CCrazyflie::setComputationRate(uint16_t rate) {
// Populate the packet
int nSize = 3;
char cBuffer[3];
cBuffer[0] = COMP_CONFIG_RATE;
memcpy( &(cBuffer[1]), &rate, sizeof(uint16_t) );
// Create the packet to send
CCRTPPacket *crtpPacket = new CCRTPPacket(cBuffer, nSize, CRTP_PORT_COMPUTATION);
crtpPacket->setChannel(COMP_CHAN_CONFIG);
CCRTPPacket *crtpReceived = m_crRadio->sendAndReceive(crtpPacket, m_nRadioChannel, this);
// Clear variables and return
delete crtpPacket;
delete crtpReceived;
}
void CCrazyflie::configureComputation( void *config, uint8_t length) {
// Populate the packet
int nSize = length+1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment