Detecting a deck using the code from the step by step motion commander tutorial.

Post here to get support
Post Reply
cafeciaojoe
Member
Posts: 83
Joined: Mon Jun 18, 2018 2:37 am

Detecting a deck using the code from the step by step motion commander tutorial.

Post by cafeciaojoe »

hi!

I am following the motion commander tutorial, after copy pasting the code below direct fromt the tutorial, I cannot detect a deck.
The CF is running the latest release firmware with a blank config.mk file.

I get the following from the console, no matter if a deck is attached OR what kind of deck is attached, (flow, lighhouse, led...)

Code: Select all

Connecting to radio://0/80/2M/E7E7E7E7E7
Connected to radio://0/80/2M/E7E7E7E7E7
0
Deck is attached!

Process finished with exit code 0

Code: Select all

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):
    global is_deck_attached
    print(value)
    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)
Thanks in advance.
PhD Student
RMIT University
School of Design
http://www.cafeciaojoe.com
Image
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: Detecting a deck using the code from the step by step motion commander tutorial.

Post by kimberly »

hi joe!

I will try this this afternoon. It should work but maybe somethings off. I will give an update once I do!
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: Detecting a deck using the code from the step by step motion commander tutorial.

Post by kimberly »

you are right. The value is received as a string so then the if statement doesnt work like this.

it should be

Code: Select all

int(value)
in the if statement.

I updated the step by step guide on the web so I hope this works now for you!
Post Reply