Commit b8edac07 authored by Ian McInerney's avatar Ian McInerney

Redid controller query framework

parent cbd82873
......@@ -64,6 +64,8 @@ CCrazyflie::CCrazyflie(CCrazyRadio *crRadio, int nRadioChannel, int quadNum, dou
m_bufferEnd = 0;
this->queryControllerType();
// Open the file
try {
char fileName[255];
......@@ -130,6 +132,21 @@ int CCrazyflie::getControllerType() {
return controllerType;
}
std::string CCrazyflie::getControllerTypeString() {
switch (this->getControllerType() ) {
case 0:
return( "Controller:Bypassed" );
break;
case 1:
return( "Controller:PID" );
break;
case 2:
return( "Controller:LQR" );
break;
}
return( "Controller:Unknown" );
}
/**
* Enable the thrust controller.
*/
......
......@@ -115,6 +115,11 @@ int main(int argc, char **argv) {
// Initialize the CrazyFlie quadcopters
for (int i = 0; i < NUM_QUADS; i++) {
cout << "Initializing Crazyflie " << i << endl;
// Init the radio
radios[crazyflie_info[i].radioNumber].radio->setChannel( crazyflie_info[i].channelNumber );
// Create the crazyflie object
crazyflie_info[i].cflieCopter = new CCrazyflie(radios[crazyflie_info[i].radioNumber].radio,
crazyflie_info[i].channelNumber,
i,
......@@ -122,24 +127,8 @@ int main(int argc, char **argv) {
crazyflie_info[i].cflieCopter->m_enumFlightMode = GROUNDED_MODE;
crazyflie_info[i].initTime = crazyflie_info[i].cflieCopter->currentTime();
// Go through the init sequence
radios[crazyflie_info[i].radioNumber].radio->setChannel( crazyflie_info[i].channelNumber );
// Check the controller type
int controllerType = crazyflie_info[i].cflieCopter->queryControllerType();
switch( controllerType ) {
case 0:
cout << "Controllers Bypassed" << endl;
break;
case 1:
cout << "PID Controller" << endl;
break;
case 2:
cout << "LQR Controller" << endl;
break;
default:
cout << "Unknown Controller Type: " << controllerType << endl;
}
cout << crazyflie_info[i].cflieCopter->getControllerTypeString() << endl;
// Change the PID controller values
cout << "Sending PID Constants" << endl;
......@@ -259,8 +248,8 @@ int main(int argc, char **argv) {
#if USE_HAND
vrpn_init("192.168.0.120:3883", handle_hand);
#else
// vrpn_init("192.168.0.120:3883", NULL);
vrpn_init("localhost:3883", NULL);
vrpn_init("192.168.0.120:3883", NULL);
// vrpn_init("localhost:3883", NULL);
#endif // END USE_HAND
usleep(10000);
......@@ -315,7 +304,7 @@ int main(int argc, char **argv) {
pthread_create(&threads[1], NULL, vrpn_go, (void*)2);
printf("Spawning User Output Thread\n");
// pthread_create(&threads[2], NULL, displayData, (void*)3);
pthread_create(&threads[2], NULL, displayData, (void*)3);
pthread_join(threads[1], &status);
// Run the VRPN main loop
......
......@@ -217,6 +217,7 @@ class CCrazyflie {
*/
int queryControllerType();
int getControllerType();
std::string getControllerTypeString();
/**
* Enable the thrust controller.
......
......@@ -61,15 +61,13 @@ void logging_OpenLog( uint8_t quadNum) {
exit(-1);
}
// Place the header information into the log file
logfiles[quadNum] << "#Crazyflie" << endl;
//logfiles[quadNum] << quadNum << endl;
//logfiles[quadNum] << "#Time\t\t" << timeString << endl;
// Add the controller type to the logfile
logfiles[quadNum] << "#" << crazyflie_info[quadNum].cflieCopter->getControllerTypeString() << endl;
logfiles[quadNum] << variables << endl;
logfiles[quadNum] << units << endl;
//fprintf(crazyflie_info[quadNum].logfile, "%s\n", variables);
//fprintf(crazyflie_info[quadNum].logfile, "%s\n", units);
cout << " Complete" << endl;
}
......
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