Analog Flight Control - Lesson and Video Parity?



  • I was trying the analog control lesson and followed the example given in the lesson but my CoDrone would not respond to the movement of the analog joysticks. Since you have sent me video links to help fill in gaps of information and understanding for my previous questions I searched and found a video about flight control on the Robolink YouTube channel. This leaves me feeling as an educator that the analog flight control lesson does not provide enough information on its own.

    The code sample in the lesson does not match the Controller Flight code example. Should the code sample from the lesson work? It did not work for me but the example code did.

    Am I missing something?

    I hesitate asking my students to follow a lesson that will leave them unnecessarily frustrated.



  • Hello, the final code located on this lesson Lesson 2K works in my experience. I tested it out via copy & paste with the only addition I made being a kill switch. Although I'm not sure if this is the lesson you were referring to.

    The code on the lesson is as follows:

    #include <CoDrone.h>
    
    void setup() {
        CoDrone.begin(115200);
        CoDrone.AutoConnect(NearbyDrone);
    }
    
    void loop() {if (PAIRING == true){  
        YAW = -1 * CoDrone.AnalogScaleChange(analogRead(22));   
        THROTTLE = CoDrone.AnalogScaleChange(analogRead(23));   
        ROLL = -1 * CoDrone.AnalogScaleChange(analogRead(24));   
        PITCH = CoDrone.AnalogScaleChange(analogRead(25));   
        CoDrone.Control();   
        }
    }
    

    I highly suggest adding a kill switch or a landing event to the code before flying or else you may not be able to stop the drone from flying.
    Note: The kill switch makes the drone completely stop in the air. I suggest using it when the drone is near the floor or in the case that you need to make an emergency stop (like if it's about to hit someone).

    Here is the exact code I used to test (kill switch added):

    #include <CoDrone.h>
    
    void setup() {
        CoDrone.begin(115200);
        CoDrone.AutoConnect(NearbyDrone);
    }
    
    void loop() {if (PAIRING == true){  
        YAW = -1 * CoDrone.AnalogScaleChange(analogRead(22));   
        THROTTLE = CoDrone.AnalogScaleChange(analogRead(23));   
        ROLL = -1 * CoDrone.AnalogScaleChange(analogRead(24));   
        PITCH = CoDrone.AnalogScaleChange(analogRead(25));   
        CoDrone.Control();   
        }
    
        if(digitalRead(11) && !digitalRead(14) && !digitalRead(18)) //bottom left sensor
        {
          CoDrone.FlightEvent(Stop); // Kill switch
          //CoDrone.FlightEvent(Landing); // Landing event
          CoDrone.Buzz(4000, 7);
          delay(100);
        }
    }
    

    Hope it helps!



  • Thanks so much for your detailed response, @Loui2! @robolink_arnold mentioned your responses are all excellent.


Log in to reply
 

Looks like your connection to Robolink community was lost, please wait while we try to reconnect.