diff --git a/crazyCART.sh b/crazyCART.sh index e6547e49183cf914864829165fffcbffbc930d85..2c7a64b8506b8f6c8a315af7812c818b99b16ea1 100755 --- a/crazyCART.sh +++ b/crazyCART.sh @@ -9,7 +9,14 @@ function handler() cd ./crazyflie_groundstation #xterm -hold -e './crazyflieGroundStation' & -./crazyflieGroundStation & +if [ $# -gt 0 ] +then + echo "custom radio" + ./crazyflieGroundStation $1 & +else + echo "default radio" + ./crazyflieGroundStation & +fi CFPID=$! echo "Waiting for crazyflie groundstation to be created..." cf_gs=crazyflie_groundstation.socket diff --git a/crazyflie_groundstation/src/crazyflieGroundStation.cpp b/crazyflie_groundstation/src/crazyflieGroundStation.cpp index c3f2a930fb523a7a47683886dcb80e8fa7036336..80d05ce3510ae598fed2b0d648f3068d353f4c79 100644 --- a/crazyflie_groundstation/src/crazyflieGroundStation.cpp +++ b/crazyflie_groundstation/src/crazyflieGroundStation.cpp @@ -92,8 +92,8 @@ pthread_t threads[3+NUM_RADIOS]; #define PI 3.14159265 -int main(int argc, char **argv) { - sleep(1); //***FOR TESTING PURPOSES*** (REMOVE) +int main(int argc, char** argv) { + //sleep(1); //***FOR TESTING PURPOSES*** (REMOVE) signal(SIGINT, &ctrlc_handler); @@ -145,17 +145,34 @@ int main(int argc, char **argv) { cout << "Initializing Crazyflie " << i+1 << endl; // Init the radio - radios[crazyflie_info[i].radioNumber].radio->setChannel( crazyflie_info[i].channelNumber ); + if(argc == 2 && i == 0) { + uint8_t channelNum = (uint8_t) std::strtol(argv[1], (char**) NULL, 10); + radios[crazyflie_info[i].radioNumber].radio->setChannel( channelNum ); + } + else { + radios[crazyflie_info[i].radioNumber].radio->setChannel( crazyflie_info[i].channelNumber ); + } + // Clear the packets on the network destined for this quadcopter network->clearNetworkQueue(i); // Create the crazyflie object - crazyflie_info[i].cflieCopter = new CCrazyflie(radios[crazyflie_info[i].radioNumber].radio, + if(argc == 2 && i == 0) { + uint8_t channelNo = (uint8_t) std::strtol(argv[1], (char**) NULL, 10); + crazyflie_info[i].cflieCopter = new CCrazyflie(radios[crazyflie_info[i].radioNumber].radio, + channelNo, + crazyflie_info[i].dataRate, + i, + startTime); + } + else { + crazyflie_info[i].cflieCopter = new CCrazyflie(radios[crazyflie_info[i].radioNumber].radio, crazyflie_info[i].channelNumber, crazyflie_info[i].dataRate, i, startTime); + } crazyflie_info[i].cflieCopter->setNetworkForwarding(network); crazyflie_info[i].initTime = crazyflie_info[i].cflieCopter->currentTime(); diff --git a/crazyflie_groundstation/src/quadcopterData.cpp b/crazyflie_groundstation/src/quadcopterData.cpp index 658adbd303676cbf63785d4f988f96825b1417e9..50929e3db7248919990df72f9dfe86dd4e8da0f8 100644 --- a/crazyflie_groundstation/src/quadcopterData.cpp +++ b/crazyflie_groundstation/src/quadcopterData.cpp @@ -231,7 +231,7 @@ QUADCOPTERS_t crazyflie_info[] = { {"Crazyflie22", // Trackable name NULL, // VRPN tracker object (initialized in VRPNinit) NULL, // CrazyFlie copter object (initialized in main) - 65, // The channel number of the crazyflie + 85, // The channel number of the crazyflie 0, // The radio to use XFER_2M, // The datarate of the Crazyflie 0, // The init time