Page 1 of 1

Lighthouse yaw at takeoff

Posted: Sat Feb 29, 2020 3:40 pm
by aseggebaeing
Hello,

I have custom code running on a crazyflie that is equiped with both the loco and the flow v2 decks. However I'm running into issues during takeoff where the crazyflie rotates to a seemingly random yaw angle (Before takeoff its facing towards positive x). When the crazyflie is then navigating to an absolute coordiante position it initially flies into the wrong direction before gradually correcting the yaw angle by itself. After that everything works as expected, but in the process of correcting itself it's often crashing into the wall. I'm now wondering how to enable lighthouse yaw to automatically rotate to yaw=0 during takeoff. Thanks!

This is the code I'm running for takeoff:

Code: Select all

static void setHoverSetpoint(setpoint_t *setpoint, float vx, float vy, float z)
{
	setpoint->mode.x = modeVelocity;
	setpoint->mode.y = modeVelocity;
	setpoint->mode.z = modeAbs;
	setpoint->velocity.x = vx;
	setpoint->velocity.y = vy;
	setpoint->position.z = z;
	setpoint->velocity_body = true;
}

static void takeoff()
{
	for (int i=0; i<30; i++)
    {
		setHoverSetpoint(&setpoint, 0.0f,  0.0f, 0.4f);
		commanderSetSetpoint(&setpoint, 3);
		vTaskDelay(M2T(100));
    }
}

Re: Lighthouse yaw at takeoff

Posted: Mon Mar 02, 2020 3:29 pm
by kimberly
Are you sure that the yaw angle estimate by the kalman filter is in the right direction once you take off? It has a tendency to drift a lot on the floor to random directions, as I tried to explain in this forum-post: viewtopic.php?f=6&t=4081&p=18558#p18558.

What I also guess, is that the setpoint->yaw is set to relative (mode velocity) by default, so you might want to consider setting that in the setpoint as well.

Since it custom code it is a bit difficult to estimate what is going on. Are you using the applayer as described in this blogpost: https://www.bitcraze.io/2019/11/making- ... app-layer/. Then we might be able to recreate your situation.

Re: Lighthouse yaw at takeoff

Posted: Mon Mar 02, 2020 3:44 pm
by kimberly
By the way. This issue might be interesting for you as well: https://github.com/bitcraze/crazyflie-f ... issues/523

Re: Lighthouse yaw at takeoff

Posted: Tue Mar 03, 2020 12:11 pm
by aseggebaeing
Thank you for your answer. I tried setting the yaw in the setpoint as well but sadly that didn't help. I'm not sure how to reset the kalman estimator. I tried calling estimatorKalmanInit() right before takeoff to reset it but then the crazyflie doesn't start flying at all. I'm not using the applayer currently, I'll have to look into that.

Code: Select all

static void takeoff()
{
    estimatorKalmanInit();
    for (int i=0; i<30; i++)	
   {
	safety_check();
	setHoverSetpoint(&setpoint, 0.0f,  0.0f, 0.4f);
	setpoint.mode.yaw = modeAbs;
        setpoint.attitude.yaw = 0.0f;
	commanderSetSetpoint(&setpoint, 3);
	vTaskDelay(M2T(100));
    }
}

Re: Lighthouse yaw at takeoff

Posted: Tue Mar 03, 2020 12:11 pm
by aseggebaeing
Thank you for your answer. I tried setting the yaw in the setpoint as well but sadly that didn't help. I'm not sure how to reset the kalman estimator. I tried calling estimatorKalmanInit() right before takeoff to reset it but then the crazyflie doesn't start flying at all. I'm not using the applayer currently, I'll have to look into that.

Code: Select all

static void takeoff()
{
    estimatorKalmanInit();
    for (int i=0; i<30; i++)	
   {
	safety_check();
	setHoverSetpoint(&setpoint, 0.0f,  0.0f, 0.4f);
	setpoint.mode.yaw = modeAbs;
        setpoint.attitude.yaw = 0.0f;
	commanderSetSetpoint(&setpoint, 3);
	vTaskDelay(M2T(100));
    }
}

Re: Lighthouse yaw at takeoff

Posted: Wed Mar 04, 2020 9:18 am
by kimberly
And how about setting the mode of yaw to relative? Just out of curiousity :)

Re: Lighthouse yaw at takeoff

Posted: Wed Mar 04, 2020 11:22 am
by aseggebaeing
I tried that but it also didn't help.

Re: Lighthouse yaw at takeoff

Posted: Thu Mar 05, 2020 9:35 am
by kimberly
Hmm alright... there is something going one there. You might be hitting a corner case since maybe the kalmanfilter is not liking the input of both the LPS system and the flowdeck. You could also try different ranging methods of the LPS, but I'm not sure that is possible.

The lighthouse yaw will be difficult to enable since the lighthouse is able to estimate the yaw, and the flowdeck/lps are not.

It will be difficult to help you with this since there are modifications to the firmware and currently we can only 'guess' the problem. If you could make a minimal example case where this happens, preferably in the applayer functionality, and send it to use, we can try to replicate your problem here at our office. Let us know how you want to proceed.