I am trying to connect to the CrazyFlie via the Python API and make the motors work by giving a thrust value. The connection happens. Even the green led comes on and flickers a bit continuosly remains on showing thats its connected with the crazyRadio. However, the motors don't move.
This is the response I get from the command line code: The last line "sending data" is a print set by me once the infinite loop kicks in to keep pinging the copter after every 0.1 seconds.
Code: Select all
C:\Users\raghav\Documents\QuadCopter\cfclient-2013.4.2\lib>C:\Pytho
n27-32bit\python.exe sample.py
DEBUG:cflib.crazyflie:Adding callback on port [5] to [<bound method Log._new_pac
ket_cb of <cflib.crazyflie.log.Log instance at 0x0260F648>>]
DEBUG:cflib.crazyflie:Adding callback on port [0] to [<bound method Console.inco
ming of <cflib.crazyflie.console.Console instance at 0x0260F6E8>>]
DEBUG:cflib.crazyflie:Adding callback on port [2] to [<bound method _ParamUpdate
r._new_packet_cb of <_ParamUpdater(Thread-2, initial daemon)>>]
before open link
INFO:cflib.crazyflie:Callback->Connection initialized[radio://0/10/250K]
INFO:cflib.crazyflie:We are connected[radio://0/10/250K], request connection set
up
DEBUG:cflib.crazyflie.toc:[5]: Start fetching...
DEBUG:cflib.crazyflie:Adding callback on port [5] to [<bound method TocFetcher._
new_packet_cb of <cflib.crazyflie.toc.TocFetcher instance at 0x0266C300>>]
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5]
after link is opened
DEBUG:cflib.crazyflie:ExpectAnswer: No answer on [5], do retry
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5]
WARNING:cflib.crazyflie:ExpectAnswer: ERROR! Older timer whas running while sche
duling new one on [5]
DEBUG:cflib.crazyflie:ExpectAnswer: No answer on [5], do retry
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5]
WARNING:cflib.crazyflie:ExpectAnswer: ERROR! Older timer whas running while sche
duling new one on [5]
DEBUG:cflib.crazyflie:ExpectAnswer: No answer on [5], do retry
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5]
WARNING:cflib.crazyflie:ExpectAnswer: ERROR! Older timer whas running while sche
duling new one on [5]
DEBUG:cflib.crazyflie:ExpectAnswer: No answer on [5], do retry
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5]
WARNING:cflib.crazyflie:ExpectAnswer: ERROR! Older timer whas running while sche
duling new one on [5]
INFO:cflib.crazyflie:Callback->Connected to [radio://0/10/250K]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [5], cancelling time
r
ERROR:cflib.crazyflie.toc:Got packet that was not on TOC channel, TOC fetch will
probably not succeed
DEBUG:cflib.crazyflie.toc:[5]: Got TOC CRC, 9 items and crc=0x6F098296
DEBUG:cflib.crazyflie.toc:Requesting index 0 on port 5
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [5], cancelling time
r
WARNING:root:[5]: Was expecting 0 but got 9
WARNING:root:[5]: Was expecting 0 but got 9
WARNING:root:[5]: Was expecting 0 but got 9
WARNING:root:[5]: Was expecting 0 but got 9
DEBUG:cflib.crazyflie.toc:Added element [0]
DEBUG:cflib.crazyflie.toc:[5]: More variables, requesting index 1
DEBUG:cflib.crazyflie.toc:Requesting index 1 on port 5
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5]
DEBUG:cflib.crazyflie:ExpectAnswer: No answer on [5], do retry
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5]
WARNING:cflib.crazyflie:ExpectAnswer: ERROR! Older timer whas running while sche
duling new one on [5]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [5], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [1]
DEBUG:cflib.crazyflie.toc:[5]: More variables, requesting index 2
DEBUG:cflib.crazyflie.toc:Requesting index 2 on port 5
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [5], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [2]
DEBUG:cflib.crazyflie.toc:[5]: More variables, requesting index 3
DEBUG:cflib.crazyflie.toc:Requesting index 3 on port 5
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [5], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [3]
DEBUG:cflib.crazyflie.toc:[5]: More variables, requesting index 4
DEBUG:cflib.crazyflie.toc:Requesting index 4 on port 5
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [5], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [4]
DEBUG:cflib.crazyflie.toc:[5]: More variables, requesting index 5
DEBUG:cflib.crazyflie.toc:Requesting index 5 on port 5
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [5], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [5]
DEBUG:cflib.crazyflie.toc:[5]: More variables, requesting index 6
DEBUG:cflib.crazyflie.toc:Requesting index 6 on port 5
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [5], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [6]
DEBUG:cflib.crazyflie.toc:[5]: More variables, requesting index 7
DEBUG:cflib.crazyflie.toc:Requesting index 7 on port 5
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [5], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [7]
DEBUG:cflib.crazyflie.toc:[5]: More variables, requesting index 8
DEBUG:cflib.crazyflie.toc:Requesting index 8 on port 5
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [5], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [8]
WARNING:cflib.crazyflie.toccache:Could not save cache, no writable directory
DEBUG:cflib.crazyflie:Removing callback on port [5] to [<bound method TocFetcher
._new_packet_cb of <cflib.crazyflie.toc.TocFetcher instance at 0x0266C300>>]
DEBUG:cflib.crazyflie.toc:[5]: Done!
INFO:cflib.crazyflie:Log TOC finished updating
DEBUG:cflib.crazyflie.toc:[2]: Start fetching...
DEBUG:cflib.crazyflie:Adding callback on port [2] to [<bound method TocFetcher._
new_packet_cb of <cflib.crazyflie.toc.TocFetcher instance at 0x0266CCB0>>]
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:[2]: Got TOC CRC, 23 items and crc=0xCE379F23
DEBUG:cflib.crazyflie.toc:Requesting index 0 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [0]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 1
DEBUG:cflib.crazyflie.toc:Requesting index 1 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [1]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 2
DEBUG:cflib.crazyflie.toc:Requesting index 2 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [2]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 3
DEBUG:cflib.crazyflie.toc:Requesting index 3 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [3]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 4
DEBUG:cflib.crazyflie.toc:Requesting index 4 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [4]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 5
DEBUG:cflib.crazyflie.toc:Requesting index 5 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [5]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 6
DEBUG:cflib.crazyflie.toc:Requesting index 6 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [6]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 7
DEBUG:cflib.crazyflie.toc:Requesting index 7 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [7]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 8
DEBUG:cflib.crazyflie.toc:Requesting index 8 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [8]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 9
DEBUG:cflib.crazyflie.toc:Requesting index 9 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [9]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 10
DEBUG:cflib.crazyflie.toc:Requesting index 10 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [10]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 11
DEBUG:cflib.crazyflie.toc:Requesting index 11 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [11]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 12
DEBUG:cflib.crazyflie.toc:Requesting index 12 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [12]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 13
DEBUG:cflib.crazyflie.toc:Requesting index 13 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [13]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 14
DEBUG:cflib.crazyflie.toc:Requesting index 14 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [14]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 15
DEBUG:cflib.crazyflie.toc:Requesting index 15 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [15]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 16
DEBUG:cflib.crazyflie.toc:Requesting index 16 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [16]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 17
DEBUG:cflib.crazyflie.toc:Requesting index 17 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [17]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 18
DEBUG:cflib.crazyflie.toc:Requesting index 18 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [18]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 19
DEBUG:cflib.crazyflie.toc:Requesting index 19 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [19]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 20
DEBUG:cflib.crazyflie.toc:Requesting index 20 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [20]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 21
DEBUG:cflib.crazyflie.toc:Requesting index 21 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [21]
DEBUG:cflib.crazyflie.toc:[2]: More variables, requesting index 22
DEBUG:cflib.crazyflie.toc:Requesting index 22 on port 2
DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2]
DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling time
r
DEBUG:cflib.crazyflie.toc:Added element [22]
WARNING:cflib.crazyflie.toccache:Could not save cache, no writable directory
DEBUG:cflib.crazyflie:Removing callback on port [2] to [<bound method TocFetcher
._new_packet_cb of <cflib.crazyflie.toc.TocFetcher instance at 0x0266CCB0>>]
DEBUG:cflib.crazyflie.toc:[2]: Done!
INFO:cflib.crazyflie:Param TOC finished updating
INFO:cflib.crazyflie:Callback->Connection setup finished [radio://0/10/250K]
sending data
Below is my file sample.py. I have used several different variations of the below code but can't resolve the issue as to why the motors don't start up. When I switch on the crazyflie, the motors do their test spin properly signifying that the soldering and connections to the motors are proper. Just can't get the program to work! Any help is appreciated.
Code: Select all
import logging
import time
import cflib.crtp
from cfclient.utils.logconfigreader import LogConfig
from cfclient.utils.logconfigreader import LogVariable
from cflib.crazyflie import Crazyflie
logging.basicConfig(level=logging.DEBUG)
class Main:
def __init__(self):
self.crazyflie = Crazyflie()
cflib.crtp.init_drivers()
self.crazyflie.connectSetupFinished.add_callback(self.connectSetupFinished)
print("before open link")
self.crazyflie.open_link("radio://0/10/250K")
print("after link is opened")
def connectSetupFinished(self, linkURI):
roll = 0.0
pitch = 0.0
yawrate = 0
thrust = 20000
print("sending data")
result = self.crazyflie.commander.send_setpoint(roll, pitch, yawrate, thrust)
while(True):
result = self.crazyflie.commander.send_setpoint(roll, pitch, yawrate, thrust)
time.sleep(0.1)
def log_accel_data(self, data):
logging.info("Accelerometer: x=%.2f, y=%.2f, z=%.2f" %
(data["acc.x"], data["acc.y"], data["acc.z"]))
Main()