Position Hold Mode

Discussions and questions about the Crazyflie Nano Quadcopter
Post Reply
Korrelator
Beginner
Posts: 9
Joined: Fri Jun 02, 2017 12:49 pm

Position Hold Mode

Post by Korrelator » Thu Aug 03, 2017 10:08 am

Hello Guys i need your help again.

I'm using a cf2 and want to run a position control. I have seen this post:

https://www.bitcraze.io/2017/04/updated ... an-filter/

and im using the Client with the external tab. I have build a Stereo-System(2 PS-Eye) to track the copter and the kalman filter is giving me good estimations. (I send the external position-data with 5Hz) . Furthermore i changed the Kalman-Estimator. Now my Questions:

1) On the Flight-Tab we have the opstion for Position-Hold. How exactly can i use it and how do i set the Target-Position?
I have seen in the commander-cf-firmware that pitch and roll commands are used as position commands but it doesn't work for me. Where can I check my TargetPosition? I'm using a PS3-Controller with the PS3_Mode_3 Inputmap. Do i have to change something?

2) I have created a new tab where i send CF my Target Positions. For this i have added a new generic Command. This is how the setpoint implementation on the cf-firmware looks like:

Code: Select all

    
    setpoint->mode.x = modeAbs;
    setpoint->mode.y = modeAbs;
    setpoint->mode.z = modeAbs;
    setpoint->mode.roll = modeDisable;
    setpoint->mode.pitch = modeDisable;
    setpoint->mode.yaw = modeAbs;

    setpoint->position.x = -values->x;
    setpoint->position.y = values->y;
    setpoint->position.z = values->z;

    setpoint->attitude.roll  = 0;
    setpoint->attitude.pitch = 0;
    setpoint->attitude.yaw = 0;
   setpoint->thrust = 0;
I only send cf a command if a Target-position is changend on the Client-Input. But if i Update my Input the rotor just rotates for a second and then they stand still again. Do you know how i can make this work? Am I missing something?

Thanks

Korrelator
Beginner
Posts: 9
Joined: Fri Jun 02, 2017 12:49 pm

Re: Position Hold Mode

Post by Korrelator » Mon Aug 07, 2017 10:58 am

Hey i found the porblem. I was sending my position-command and the client was also sending a rpyt-command to the cf2. Because of this my command has been overwritten all the time. To solve this i just cut out the send call in commander.py. Is there also a better solution to stop the client from send rypt-commans?

But i have a new quetion. How good is the performance of the Position-PID-Controller? Because i couldnt stabilize the copter with the controller. Im sending my external position with 7Hz and have an accuracy about 2-3cm

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

Re: Position Hold Mode

Post by arnaud » Mon Aug 07, 2017 1:11 pm

Hi,
If the position estimate is good, the on-board PID controller should be pretty good. For instance, this video was made with the internal controller: https://www.youtube.com/watch?v=3lDvWlbDSOA. I also got very good result with AR tag with update at about 20-30Hz.

How does your position estimate look as taken from the kalman filter and are you starting the Crazyflie facing X positive?

As a first approach you could try the position-hold mode integrated in the Crazyflie client, it allows to more easily test if things are working properly (since you keep control on the Crazyflie).

Stereo-vision with 2 PSEye sounds very interesting, Are you planning on pushing the code publicly, I would be very interested to try-out.

Korrelator
Beginner
Posts: 9
Joined: Fri Jun 02, 2017 12:49 pm

Re: Position Hold Mode

Post by Korrelator » Mon Aug 07, 2017 6:08 pm

Hey, yes i will make a blog soon and post all my code and know-how about my setup. But basically I have lighted up a Table Tennis Ball with a LED. Then I tracked the ball (color-based) with both cameras and triangulated the position. The power for the LED is supplied by one of the GPIOs of the CF2.

Yes, I'm starting facing X-positiv and also took out the YAW-correction in the controller, because i can't measure the YAW-Angle with the camera right now. So im trying to fly with a constant YAW-angle.

I have moved my cameras now and will calibrate them again tomorrow and post a estimation plot.

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

Re: Position Hold Mode

Post by arnaud » Tue Aug 08, 2017 7:23 am

The kalman filter will estimate the yaw out of the dynamic, but for that to work well it needs to have a good initial yaw estimate, hence the requirement of starting the Crazyflie facing X. So having the yaw absolute at 0 like you are doing or relative at 0 degree per second should work fine.

It will be interesting to see the estimate from the EKF.

Korrelator
Beginner
Posts: 9
Joined: Fri Jun 02, 2017 12:49 pm

Re: Position Hold Mode

Post by Korrelator » Tue Aug 08, 2017 1:25 pm

Here we go. At first i made circles in the y-z-plane. Then i moved the copter left to right, followed by up to down and at last i moved it fore- and backward. I have noticed that my x-values are sensitive when i move from left to right. Maybe i should do a better calibration.
Screenshot from 2017-08-08 15-10-30.png
And again i dont understand the position-hold mode. I have set the the 'Flight Mode' as 'Normal' and the 'Assist Mode' as 'Position Hold'. How can i make the copter hold his position? Because if i stop giving Trust-input the copter falls down. Am I missing something?

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

Re: Position Hold Mode

Post by arnaud » Wed Aug 09, 2017 8:19 am

Hi,
Yes, you should press the assist button on the gamepad in order to enable assist mode, once you pressed the button you should be able to release all control. It is normally mapped to the shoulder button on PS/xbox controller, you can map it to your controller using the input device configuration.

Your estimates do not look bad. I guess X is in the depth direction which can explain its sensitivity?

Korrelator
Beginner
Posts: 9
Joined: Fri Jun 02, 2017 12:49 pm

Re: Position Hold Mode

Post by Korrelator » Wed Aug 09, 2017 10:42 am

Oh ok thx, yes X is in the depth direction
i have one last question.
How is the coordinate system defined?
1)The x-direction should be positive in the front direction like here: https://wiki.bitcraze.io/_detail/projec ... 3Aassembly
2)The y-direction is positive leftward
3)The z-direction is positive upward

is this correct?

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

Re: Position Hold Mode

Post by arnaud » Wed Aug 09, 2017 11:11 am

Yes, this is correct, the coordinate system looks like that: https://www.bitcraze.io/getting-started ... m/#intro19

Post Reply