Lighthouse yaw at takeoff

Firmware/software/electronics/mechanics
Post Reply
aseggebaeing
Beginner
Posts: 5
Joined: Sat Feb 29, 2020 3:10 pm

Lighthouse yaw at takeoff

Post 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));
    }
}
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: Lighthouse yaw at takeoff

Post 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.
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: Lighthouse yaw at takeoff

Post by kimberly »

By the way. This issue might be interesting for you as well: https://github.com/bitcraze/crazyflie-f ... issues/523
aseggebaeing
Beginner
Posts: 5
Joined: Sat Feb 29, 2020 3:10 pm

Re: Lighthouse yaw at takeoff

Post 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));
    }
}
aseggebaeing
Beginner
Posts: 5
Joined: Sat Feb 29, 2020 3:10 pm

Re: Lighthouse yaw at takeoff

Post 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));
    }
}
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: Lighthouse yaw at takeoff

Post by kimberly »

And how about setting the mode of yaw to relative? Just out of curiousity :)
aseggebaeing
Beginner
Posts: 5
Joined: Sat Feb 29, 2020 3:10 pm

Re: Lighthouse yaw at takeoff

Post by aseggebaeing »

I tried that but it also didn't help.
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: Lighthouse yaw at takeoff

Post 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.
Post Reply