Deck connection Python_script

Discussions about all things Bitcraze
Post Reply
RubICS
Beginner
Posts: 8
Joined: Thu Feb 03, 2022 1:16 pm

Deck connection Python_script

Post by RubICS »

Hello Everyone,

I must admit that I am still quite a beginner. I was doing the Step_By_Step-Guide, given here: https://www.bitcraze.io/documentation/r ... commander/, and a problem has occurred. I don't understand why my deck, which I use, is not found. Can somebody help me out?

According to the client: I'm using the Deck: bcDWM1000.
Deck.png
Deck.png (11.47 KiB) Viewed 13755 times
What i did now is. I just changed the name of my Deck in the given script from the Step_By_Step-Guide:
Skript.PNG
And unfortunately my deck still can not be found. And i really need some advice, please.
jonasdn
Expert
Posts: 132
Joined: Mon Mar 01, 2021 3:13 pm

Re: Deck connection Python_script

Post by jonasdn »

Hi RubICS!

Let's see if we can figure this out! It seems like the code change you did should work, it should at least find the deck one thinks.

What is the output when you run that script? And what is the output if you run the basicparam.py example script?

Thanks
Jonas
RubICS
Beginner
Posts: 8
Joined: Thu Feb 03, 2022 1:16 pm

Re: Deck connection Python_script

Post by RubICS »

First of all thank you very much jonasdn for replying.

The output when i run the script is: "no deck is detected" as it is written in the function.

And the Output of the basicparam.py example is this:


Part1.PNG
Part2.PNG
part3.PNG
Bild4.PNG
pART4.PNG
pART4.PNG (13.47 KiB) Viewed 13715 times
As I can see, my deck (bcDWM1000) is also found in that.

Thanks,

RubICS
jonasdn
Expert
Posts: 132
Joined: Mon Mar 01, 2021 3:13 pm

Re: Deck connection Python_script

Post by jonasdn »

Thank you!

Could you give me the complete code of the script that is not working?

Jonas
RubICS
Beginner
Posts: 8
Joined: Thu Feb 03, 2022 1:16 pm

Re: Deck connection Python_script

Post by RubICS »

Yeah for sure! Thanks for you patience.

Code.PNG
The output is "Deck is NOT attached!"

Thank you very much.

RubICS
jonasdn
Expert
Posts: 132
Joined: Mon Mar 01, 2021 3:13 pm

Re: Deck connection Python_script

Post by jonasdn »

Hi!

Could you post the entire script? Perhaps on pastebin.com ?
RubICS
Beginner
Posts: 8
Joined: Thu Feb 03, 2022 1:16 pm

Re: Deck connection Python_script

Post by RubICS »

Hello Jonasdn,

i hope i did everything right. If so my code can be found here here: https://pastebin.com/SegtpYjL.

Thank you very much.
jonasdn
Expert
Posts: 132
Joined: Mon Mar 01, 2021 3:13 pm

Re: Deck connection Python_script

Post by jonasdn »

Thank you!

Am I right in understanding you do not get either of the:
print('Deck is attached!')
print('Deck is NOT attached!')

Outputs?

Could you try the following script? I modified it to ask for a parameter update.

Code: Select all

import logging
import sys
import time
from threading import Event

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

URI = uri_helper.uri_from_env(default='radio://0/80/2M/E7E7E7E7E7')

DEFAULT_HEIGHT = 0.5

deck_attached_event = Event()

logging.basicConfig(level=logging.ERROR)

def take_off_simple(scf):
    with MotionCommander(scf, default_height=DEFAULT_HEIGHT) as mc:
        time.sleep(3)
        mc.stop()


def param_deck_flow(_, value_str):
    value = int(value_str)
    print(value)
    if value:
        deck_attached_event.set()
        print('Deck is attached!')
    else:
        print('Deck is NOT attached!')
        
 
if __name__ == '__main__':
    cflib.crtp.init_drivers()

    with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:

        scf.cf.param.add_update_callback(group='deck', name='bcDWM1000',cb=param_deck_flow)
        scf.cf.param.request_param_update('deck.bcDWM1000')


        if not deck_attached_event.wait(timeout=5):
           print('No flow deck detected!')
           sys.exit(1)

        #take_off_simple(scf)


RubICS
Beginner
Posts: 8
Joined: Thu Feb 03, 2022 1:16 pm

Re: Deck connection Python_script

Post by RubICS »

Hello jonasdn,

i dont know what you did :D :D , but now my deck is going to be detected. Thank you soooooo much :D
The Output is:
1
Deck is attached!
:D :D

yours,

RubIcs
Post Reply