Page 1 of 1

Autonomous flight using wall following

Posted: Wed Apr 07, 2021 3:01 pm
by darkshadows111
Hi, I am currently working on Wall following using crazyflie 2.0. I have even tried the commander.py and hl-commander.py programs in repositories in Github. I got some ideas related to it, but still I have few doubts with it. So can you guide me through the wall following of crazyflie drone, for picture how to run it in infinite loop to hover continuously. I am looking forward to you guys!

Re: Autonomous flight using wall following

Posted: Fri Apr 09, 2021 8:49 am
by arnaud
One good example you could get started with is the multiranger push example: https://github.com/bitcraze/crazyflie-l ... er_push.py. This example runs in an infinite loop and so it will allow you to hover until the battery is empty. It also uses the multiranger deck which is a good deck to use to implement wall following.

Re: Autonomous flight using wall following

Posted: Sun Apr 18, 2021 3:41 am
by darkshadows111
@arnaud
First of all I would like to thank you for the previous response. It was kindof useful!.
Yes I have even tried it and after seeing that I got ideas for wall following and implemented a code, but the thing is functioning. For now i tried to detect the left side wall and move forward ,if there is no left wall, then it should turn left and move forward. Whenever I run the code, the first if part only works, the other following if parts ain't working I don't know why is it happening that way.

Code: Select all

#part of code facing problem

def is_close(range):
    MIN_DISTANCE = 0.2  # m

    if range is None:
        return False
    else:
        return range < MIN_DISTANCE

#main

    with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:
        # We take off when the commander is created
        with MotionCommander(scf) as mc:
            with Multiranger(scf) as mr:
                keep_flying = True

                while keep_flying:
                    if is_close(mr.left):
                        mc.start_forward(velocity=0.5)
                    else:
                        mc.start_turn_left(90)
                    if is_close(mr.up):
                        keep_flying = False
If possible help me with it, I would be thankful to you.

Re: Autonomous flight using wall following

Posted: Mon Apr 19, 2021 12:15 pm
by arnaud
Hi,

Can you explain a bit more what work and what does not?

Intuitively, your algorithm will make the Crazyflie collide with the wall since the Crazyflie is never able to get away from the wall, only closer.

ps: Can you please use "code display" in the menu when writing your message for block of code, copy-pasting python code directly removes all indentation which makes it very hard to read since python relies on indentation. I did edit your message to add the code blocks. As a bonus the code block has a scrolling bar so it allows you to copy-paste the full code which might be helpful to help you.