From 98c42cf953b37989462d8ffe0d6e8b5adfde1ba0 Mon Sep 17 00:00:00 2001 From: zeisele <zeisele@iastate.edu> Date: Mon, 21 Mar 2022 00:51:16 +0100 Subject: [PATCH] can now specify radio channel without building --- crazyCART.sh | 9 ++++++- .../src/crazyflieGroundStation.cpp | 25 ++++++++++++++++--- .../src/quadcopterData.cpp | 2 +- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/crazyCART.sh b/crazyCART.sh index e6547e491..2c7a64b85 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 c3f2a930f..80d05ce35 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 658adbd30..50929e3db 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 -- GitLab