Accelerated stop

Firmware/software/electronics/mechanics
Post Reply
r0b0tn1k
Beginner
Posts: 16
Joined: Fri Aug 30, 2019 9:53 pm

Accelerated stop

Post by r0b0tn1k » Wed Nov 27, 2019 10:05 am

Been looking at the multiranger push demo.

Have been trying to get my CF to center between two objects.

However, if I give it a virtual push forward, it would accelerate, fly a couple of meters until it meets the door, and crash.

In the demo that was provided recently (although I think it was using a camera), the CF was able to break for a similar acceleration to a dead stop.

Considering I have a multiranger, and it's able to detect the door way before hand, how the heck do I tell it to stop?

If I multiply the velocity_x * -1 to invert the thrust backwards, that would just send it flying backwards.

There needs to be some sort of "whoa, this wall is coming at me fast, better hit the breaks" code, initiate backwards thrust, detect that it's momentum is 0, and then just stay that way.

I've also played around with setting velocity_x at 0, but that doesnt work either. Although it does slow it down, it still keeps floating in that direction.

Having never coded stuff with vectors and accelerations before, a code example would be nice.



arnaud
Bitcraze
Posts: 2212
Joined: Tue Feb 06, 2007 12:36 pm

Re: Accelerated stop

Post by arnaud » Thu Nov 28, 2019 7:50 am

Hi,

Are you using a flow deck on your Crazyflie?

The push demo (here: https://github.com/bitcraze/crazyflie-l ... ush.py#L72), is setting a velocity that will bring the Crazyflie away from an obstacle and stopping it when the obstacle is not in the detection distance anymore.

This kind of velocity control can only work if the Crazyflie has some kind of position or velocity sensor, like the flow deck. Without flow deck the problem is much harder since the Crazyflie has no way of knowing its velocity (it will integrate the accelerometer if the kalman filter is enabled, but this will eventually drift).

r0b0tn1k
Beginner
Posts: 16
Joined: Fri Aug 30, 2019 9:53 pm

Re: Accelerated stop

Post by r0b0tn1k » Thu Nov 28, 2019 11:08 am

Yes, I do have the flow deck.
Is there a way to give it a hard stop using the flow deck?

arnaud
Bitcraze
Posts: 2212
Joined: Tue Feb 06, 2007 12:36 pm

Re: Accelerated stop

Post by arnaud » Fri Nov 29, 2019 7:48 am

If things work as they should, giving a velocity setpoint of 0 should stop the Crazyflie. his is the whole point of the flow sensor and velocity control: the flow sensor measures horizontal velocity which allows the Crazyflie to control it and stop if you ask it to have a velocity of 0.

Are you using the unmodified push demo?

If so, you most likely have a hardware problem that prevents the Crazyflie to work properly. This is a couple of troubleshouting you can do:
  • Check that you are using the latest released version or the latest master from git for both the Crazyflie firmware and the Crazyflie lib.
  • Check that the flow deck is installed in the right orientation, there is a marking on it to indicate the forward direction.
  • Connect the Crazyflie in the client and look at the console tab, with flow and multiranger there should be two decks detected and initialized
  • Still in the Crazyflie client, enable hover-assisted-mode in the flight tab and try to fly the drone manually using the gamepad assisted mode button. In this mode the Crazyflie should be able to hover.
  • Check that you do not have a tracking problem: the flow requires some pattern on the floor and good lightning but you must not have any hard Crazyflie shadow, if you have a hard Crazyflie shadow seen by the flow it will cause tracking problems.

r0b0tn1k
Beginner
Posts: 16
Joined: Fri Aug 30, 2019 9:53 pm

Re: Accelerated stop

Post by r0b0tn1k » Sun Dec 01, 2019 6:30 pm

Thanks for the reply!

I've been watching some videos about vectors, and made some modifications to the push code, and now the CrazyFlie is successfully hovering in the middle of two objects.
The only issue is I have to implement a PID tuning algorithm, since it will always "miss" the middle by a little, then go back left, then go back right, and so it keeps "wiggling" a bit in the middle, always missing the mark.

Oh, I wanted to ask if there is a way for the CrazyFlie to tell me the distance traveled in any direction, or should I post that as a separate question?

arnaud
Bitcraze
Posts: 2212
Joined: Tue Feb 06, 2007 12:36 pm

Re: Accelerated stop

Post by arnaud » Mon Dec 02, 2019 12:52 pm

Great to hear that you are making progress and that everything is working fine!

For the distance, you can look at the log variables "stateEstimate.x/y/z": https://github.com/bitcraze/crazyflie-f ... #L637-L639. This will contains the position estimate of the Crazyflie. Since the flow gives relative readings (ie. velocity), you cannot have an absolute position and it tends to drift quite a lot at take-off an landing, but when flying it can be a very good indication of how the Crazyflie has been moving.

And yes, if you have other unrelated questions it is always best to create a new thread to make the forum easier to browse :-).

Post Reply