Can not detect deck when using the step-by-step: motion commander guide

Discussions about all things Bitcraze
Post Reply
juliaundsophia
Beginner
Posts: 1
Joined: Fri Feb 12, 2021 2:04 pm

Can not detect deck when using the step-by-step: motion commander guide

Post by juliaundsophia »

Hello,
I am currently trying to use the script provided in the Step-by-Step Guide. I copy-pasted the script and even if a deck is attached to the crazyflie, it still give back the "Deck is NOT attached" message. There is an existing topic about that issue, which suggested to change the int(value) but this did unfortunately not work for me.
Is there another solution?

Thanks in advance. :)

This is my current script:


import logging
import time

import cflib.crtp
from cflib.crazyflie import Crazyflie
from cflib.crazyflie.syncCrazyflie import SyncCrazyflie
from cflib.positioning.motion_commander import MotionCommander

URI = 'radio://0/80/2M/E7E7E7E7E7'
is_deck_attached = False

logging.basicConfig(level=logging.ERROR)


def param_deck_flow(name, value_str):
value = int(value_str)
print(value)
global is_deck_attached
if value:
is_deck_attached = True
print('Deck is attached!')
else:
is_deck_attached = False
print('Deck is NOT attached!')


if __name__ == '__main__':

cflib.crtp.init_drivers(enable_debug_driver=False)
with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:

scf.cf.param.add_update_callback(group="deck", name="bcFlow2",
cb=param_deck_flow)
time.sleep(1)
kristoffer
Bitcraze
Posts: 630
Joined: Tue Jun 30, 2015 7:47 am

Re: Can not detect deck when using the step-by-step: motion commander guide

Post by kristoffer »

The best way to check if a deck is detected by the Crazyflie is to use the python client.

Open the console tab and check if you can see a line saying something like "DECK_CORE: 1 deck(s) found"

You can also use the Parameters tab to check which deck that is detected. Find the "deck" group and expand it, you should see a list of all possible decks, for most of them the value should be 0, but hopefully the one for your deck should be 1.
Check the name of the parameter that is 1 and compare it to what you have in your script. The "name" on this line

Code: Select all

scf.cf.param.add_update_callback(group="deck", name="bcFlow2", cb=param_deck_flow)
should match the name of your deck. It is for instance possible that you have a Flow V1 deck (bcFlow) instead of a Flow V2 deck (bcFlow2)
Post Reply