[SOLVED] Quad Formation + and x

Discussions and questions about the Crazyflie Nano Quadcopter
brunogabrich
Beginner
Posts: 2
Joined: Fri Aug 25, 2017 8:19 pm

[SOLVED] Quad Formation + and x

Post by brunogabrich » Fri Aug 25, 2017 8:45 pm

Is it possible to fly the crazyflie in the + configuration without doing major changes in the firmware? If someone ever tried that and was successful making it work I would love to talk about it.

Thank you!



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

Re: Quad Formation + and x

Post by arnaud » Mon Aug 28, 2017 12:43 pm

Hi,
There used to be a settings for that in the client but we removed it at some point.

The easiest is to rotate the setpoint 45 degree. That can either be done in the client (for example in the input subsystem: https://github.com/bitcraze/crazyflie-c ... __.py#L497) or in the firmware when receiving the setpoint (https://github.com/bitcraze/crazyflie-f ... #L179-L197).

Another path would be to rotate sensors reading and power distribution in the stabilizer loop, this would however be a much bigger change, it is also more prone to error.

brunogabrich
Beginner
Posts: 2
Joined: Fri Aug 25, 2017 8:19 pm

Re: Quad Formation + and x

Post by brunogabrich » Wed Sep 13, 2017 10:33 pm

Thank you very much! Rotating the setpoint worked well!

jacobgk2
Beginner
Posts: 5
Joined: Fri Jul 17, 2020 2:46 pm

Re: Quad Formation + and x

Post by jacobgk2 » Fri Jul 17, 2020 2:54 pm

arnaud wrote:
Mon Aug 28, 2017 12:43 pm
The easiest is to rotate the setpoint 45 degree. That can either be done in the client (for example in the input subsystem: https://github.com/bitcraze/crazyflie-c ... __.py#L497) or in the firmware when receiving the setpoint (https://github.com/bitcraze/crazyflie-f ... #L179-L197).
Do these methods still work for the Crazyflie 2.1? I am trying to switch my Crazyflie to the + formation as well but have not gotten it working yet so I thought I should ask before continuing in this direction.

Also if this is still the way to change between X formation and + formation, can you be a bit more specific as to what one needs to do to make this change? My initial thought was to do a basis rotation 45 degrees about the z axis as this would move the x and y axes to be aligned with the motor arms but I didn't notice any major changes in flight behavior when I implemented this into the roll and pitch setpoints.

jacobgk2
Beginner
Posts: 5
Joined: Fri Jul 17, 2020 2:46 pm

Re: Quad Formation + and x

Post by jacobgk2 » Fri Jul 17, 2020 6:36 pm

UPDATE: I have discovered the parameter yawMode within the firmware and the Crazyflie PC Client that allows for easy changing between the CAREFREE, PLUSMODE, and XMODE. However, it seems that this change is only implemented when the Crazyflie is being flown manually (not using any of the assist modes provided by the Crazyflie PC Client). That being said, now my question revolves more around getting the Crazyflie to fly in the + formation at all times, including when assist modes are being used for flight. Is this possible?

kimberly
Bitcraze
Posts: 456
Joined: Fri Jul 06, 2018 11:13 am

Re: Quad Formation + and x

Post by kimberly » Mon Jul 20, 2020 8:25 am

Arnaud is on parental leave so I will try to answer it for you

So actually the plus configuration is still a remnant from the crazyflie 1 so we are intending to remove it completely. However if you look into the code of, probably the plus config is I guess still there? Can't be super sure but if you disable the QUAD_FORMATION_X while making the firmware, then it will fly in plus formation always (if QUAD_FORMATION_NORMAL is indeed the plus configuration).


Or else you can change the setpoint 45 degrees as arnaud mentioned before.

jacobgk2
Beginner
Posts: 5
Joined: Fri Jul 17, 2020 2:46 pm

Re: Quad Formation + and x

Post by jacobgk2 » Mon Jul 20, 2020 3:18 pm

Hi Kimberly!

Thank you for your response.

In my firmware the QUAD_FORMATION_X bit is actually skipped so my Crazyflie uses the QUAD_FORMATION_NORMAL for determining motor power values. Also when I change it to QUAD_FORMATION_X (I just changed the #ifdef to #if (1)), I don't notice any major changes to the flight behavior of the Crazyflie which I am a bit confused on as they are different equations. I guess it could be that the thrust limit is always exceeded so the thrust in QUAD_FORMATION_X matches that of QUAD_FORMATION_NORMAL but I'd have to do some more analysis or print the motor power values to figure that out.

Going back to the rotation of the setpoint as explained by Arnaud, I am still stuck on how exactly to implement this in the firmware. I have been trying to make changes to the crtp_commander_rpyt.c code in the lines that he highlighted in his previous posts on this thread. One thing I noticed is that the loops in lines 179-197 are not even reached while flying during an assisted flight mode in the Crazyflie PC Client. I added some debug print statements within those loops and they would print up until the moment I started an assisted hover with the Crazyflie. The loops were still reached during manual flying of the Crazyflie but none of the attempts I made at rotating the setpoint 45 degrees within that section changed the flight behavior the way I wanted.

All of this being said, I still have two questions to figure out:

1) Is there another place within the firmware that would allow the Crazyflie to fly in the + formation when in an assisted flight mode (either hover or height hold)?

2) How do I rotate the setpoint 45 degrees exactly? I initially had tried a basis rotation of 45 degrees about the z axis but as mentioned before that didn't work.

As always, thank you for your help!

kimberly
Bitcraze
Posts: 456
Joined: Fri Jul 06, 2018 11:13 am

Re: Quad Formation + and x

Post by kimberly » Tue Jul 21, 2020 11:55 am

This all happened 'before my time' so I did a bit of investigation by looking in the firmware from 2017.06 when cf1 is still used, and it seems that you would need to look into the yaw mode: https://github.com/bitcraze/crazyflie-f ... .c#L63-L68. Here you see PLUSMODE which was made default when the CF1 was selected as platform (this is not implemented anymore). The rotateYaw function might be interesting for you too.

However, the crtp_commander_rpyt is only used in manual flight indeed (or if you send the attitude setpoints from a script), so that makes sense why this does not work with the assist modes since those are handled by crtp_commander_generic.c. That is probably where you would need to change it to your convenience (answering your question 1). The _rpyt handles attitude setpoints which can sent by both the cfclient or a python script.

So about the questions:
1. Look into crtp_commander_generic: since those handle velocity position setpoints
2. This really depends though... if you want to do this from the cfclient you would need to look at where the setpoints are sent, which are from these positions I believe:
https://github.com/bitcraze/crazyflie-c ... #L249-L262

With changing the setpoint, Arnaud means that you would need to change the 'args' so that they will contain the yaw of +45 deg. The send_hover_setpoint and set_velocity_workld_setpoint functions (part of the cflib which the cfclient uses) only accept yaw rate and not absolute, so you would need to actually to use send_position_setpoint which is not relative but absolute. This will also change the behavior of the assist-mode (and will fly away in class) so this is not something you can use in the client like that though.

It might be better to try these setpoints functions from a python script first instead of the cfclient. It would be easier for you to understand what is going on. There is an example folder in the cflib.

jacobgk2
Beginner
Posts: 5
Joined: Fri Jul 17, 2020 2:46 pm

Re: Quad Formation + and x

Post by jacobgk2 » Wed Jul 22, 2020 4:10 pm

Thank you for the detailed response! I will try some of those solutions out.

jacobgk2
Beginner
Posts: 5
Joined: Fri Jul 17, 2020 2:46 pm

Re: Quad Formation + and x

Post by jacobgk2 » Wed Jul 22, 2020 5:58 pm

UPDATE: Changing the x and y velocity setpoints within the hoverDecoder of crtp_commander_generic.c did the trick!

Thank you again for the help!

Post Reply