Issues in demo unit for KMSO in NY

  • This is Jeongkyu Lee at University of Bridgeport and testing a demo unit for KMSO in NY. Here is issues of demo unit:

    • Pairing, calibrate(), takeoff(), hover() and land() are working well
    • However, other libraries are not working, such go(), and set_pitch()
    • Please, see the code below:
      I am using MacOS (Catalina), Python 3.6 and run the script using python interpreter, i.e., python3
      ========= ================
      import CoDrone
      from CoDrone import Direction
      drone = CoDrone.CoDrone()
      drone.go(FORWARD) # Go forward for 1 second at 50% power
      #drone.go(Direction.UP, 5) # Go up for 5 seconds at 50% power
      drone.go(BACKWARD) # Go backwards for 3 seconds at 70% power

    ========= ==========
    import CoDrone
    from CoDrone import Direction

    drone = CoDrone.CoDrone() # easier to type drone
    drone.pair(drone.Nearest) # pairs to nearest drone

    drone.takeoff() # takeoff for 2 seconds
    drone.hover(3) # hover for 3 seconds

    drone.go(Direction.FORWARD, 1, 30) # moves the drone forward for 2 seconds at 30% power
    #drone.go(LEFT, 1, -30) # moves the drone left for 2 seconds at 30% power
    drone.go(Direction.BACKWARD, 1, -30) # moves the drone backward for 2 seconds at 30% power
    #drone.go(RIGHT, 1, 30) # moves the drone right for 2 seconds at 30% power # lands the CoDrone
    drone.close() # disconnects CoDrone

    ====== ==========
    import CoDrone
    drone = CoDrone.CoDrone()
    drone.pair() # pairs to previous drone

    drone.takeoff() # takeoff for 2 seconds
    drone.hover(3) # hover for 3 seconds

    drone.set_pitch(30) # set positive pitch at 30% power
    drone.move(2) # forward for 2 seconds

    #drone.set_roll(-30) # set negative roll at 30% power
    #drone.move(1) # left for 2 seconds

    #drone.set_pitch(-30) # set negative pitch at 30% power
    #drone.move(1) # backward for 2 seconds

    #drone.set_roll(30) # set positive roll at 30% power
    #drone.move(2) # right for 2 seconds # lands the CoDrone
    drone.close() # disconnects CoDrone

    Thanks in advance

  • here are some correcitons I see:

    when using go():

    drone.go(Direction.RIGHT, 1, 30)

    where your import section must also include: from CoDrone import Direction
    (here is a the basic page for the go() command:

    with regards to the set_pitch()/move() based on reading the code, it should work (though I've found that 30 and below sometimes has minimal effect, but not consistent)

  • @ixmclean Thank you so much for your quick reply. I just figure out the problem.
    I have run the program using terminal python script as below:
    i) MacOS -> Start terminal
    ii) at command line:


    Sometimes, command line interpreter looks like lose some data (not sure, there might be byte data...), which caused the problem.
    However, using Jupyter is fine.
    So, my question is :
    "What are suggested IDE for CoDrone programming rather than Jupyter?"
    During the competition, some of students are not familiar with Jupyter, so I'd better know what are the suggested IDE.

    Also, any work around of the problem using command line script programming?

    Thank you in advance.

  • ATM I'm using PyCharm. Works well so far. odd that command line isn't working for you though. I run a test on my own system to see if I'm encountering problems.

  • ok run some tests, and I'm having no issues with my code running at command line
    Using Ububtu (I have a mac at home, but doubt they'd let me take my project out of the building)

    any IDE should work. even nano/vi/emacs

    as far as your code, I copy/pasted into nano, (added the Direction and ended with a drone.close() ) and it worked the 2nd (and 3rd time) time I ran it (I've noticed that it is common [1 in 4] for the execution to get interrupted (like when I have a battery check for anything under 10% and it would close on a fresh battery, or close itself before my check)
    as for the runtime, it barely did a forward/backward nudge

    I added a "1" time component: drone.go(Direction.FORWARD, 1)
    (and to the backward) and it ran smoothly for 1 sec forward and backward

  • @ixmclean Hello,
    Thank you so much for your suggestion.

    1. Did you test the code with Mac using terminal and vi?
    2. Based on your suggestion, I tested the following code with PyCharm and here are the results:
      ====== Code ======
      import CoDrone
      from CoDrone import Direction
      import time
      drone = CoDrone.CoDrone()
      drone.go(Direction.LEFT, 1)
      drone.go(Direction.BACKWARD, 1)
      drone.go(Direction.FORWARD, 1)
      drone.go(Direction.RIGHT, 1)
      ======= End of code (I added sleep in case of latency, but not helpful ====
      (i) first case of results: sometimes right-front motor is not working see a video below.
      --> I plugged the motor into other position. Then, work. So, a motor is not a problem. After adjusting a position of motor to a arm, it works. But, not clearly understand what is a problem
      (ii) second case of results: sometimes couldn't pair, but no error message. The rest of code are executed, but no movement. I checked this with print(). See a video below:
      (iii) third case of results: sometimes can be paired and takeoff(), but rest of commands didn't work. A drone is just landed (looks like forcely because the program is not ended yet). See video below:
      (iv) forth case of results: just one time. a dron moved to LEFT, but rest of commands didn't work. Then same as case (iii).

    Also, from time to time, I need to reconnect a battery to be paired.

    1. Any advices and comments are welcome.
      I'd like to know if this is caused by a drone (specific) or programming problem.
      Thank you in advance for your help.

  • sadly, I can't take the drone home to test on my Apple.

    With regards to your code and videos, Yes, sometimes, the communication drops to the drone (1 in 6 times is a rough guess) I've made it a habit to unplug the BLE cable, and re-seat the CoDrone Battery to ensure a fresh connection most of the time. I would say that I don't think I've had mine not execute the rest of the code post takeoff though (if it falters it errors out before take off, or if it does falter [this is rare] it would not take off but continue with the program [and no solid green pairing light])

  • @ixmclean Hello,

    1. Yes, sometimes, the communication drops to the drone (1 in 6 times is a rough guess) I've made it a habit to unplug the BLE cable, and re-seat the CoDrone Battery to ensure a fresh connection most of the time.
      --> Mine is almost every time of the communication drop. Anyway, your suggested workaround (i.e., reconnect BLE and battery every try) is working so far (I tested successfully 4 times in a row)

    2. However, the first case of my failures (in my previous note) still happened to me. Even after successful landing, the right front motor is now running. So, my another question is:
      Do you have any library to test a specific motor without takingoff nor calibration?
      Now, whenever the motor is not working, I run calibrate( ) with holding a drone by left hand, and adjusting motor position in a arm until running. Then, re calibrate() -> run the code.
      This is not convenient also not safe (a couple of times hit my fingers). Any suggestions?

    Thank you in advance.

  • @ixmclean One more question:
    As you can see from a video, when a drone lands on a floor using land( ), it hit a ground hardly. I guess this may cause a problem of a motor (position).
    So, is there way for very soft landing using library?
    (see the last part of video for landing)
    Thank you

  • administrators

    @jaykay0408 That landing looks about right. It varies from drone to drone. You can probably write your own function if you would like that decreases the throttle in increments. For the skipped commands you were mentioning, I have found it useful to insert a time.sleep(1) in between commands. If you use the time library make sure to import time. Let me know if these answer your questions.

  • @robolink_leila Hello,

    1. I have used time.sleep() before, but doesn't help a lot before. But, I will test this again after refreshing the connection.

    2. However, currently it is solid green (tail LED) when a battery is plugged in

    3. Even reset doesn't work

    4. I setup the 30 min tech support this afternoon, but no show.
      Thank you.

    1. Glad the unhook/rehook option helped you.
    2. there isn't a way in the codrone library to test different arm motors. without seeing the arms, it is hard to determine if there is a contact issue, wiring, or ESC
    3. ya, the landing is a tad tough sometimes. I'll do some runs of dropping the throttle in stages then land and see how that goes. though I've seen when flying and using throttling, the min distance is roughly 20cm (200mm) and the CoDrone likes that gap. forcing it lower will be interesting to see (I've tested going higher because the landscape I'm flying over had buildings [HO gauge table top] and the drone's flight goes up and down which alters the straight line path).
    4. calibrate(): I've found this only works the first time called (doesn't takeoff/land like the instruction says though) successive calls to calibrate() (I was gauging power levels @1 sec to get a feel of distance it travels and how straight of a line it goes) and I had a loop set int he program with successive calibrate()s but the first call changed the lights/paused, but each other successive calls did not.

Log in to reply

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