Understanding the Firmware

Firmware/software/electronics/mechanics
Korrelator
Beginner
Posts: 9
Joined: Fri Jun 02, 2017 12:49 pm

Understanding the Firmware

Post by Korrelator »

Hello Guys,

I'm new to this community and already need your help :)
I just started using Crazyflie and want to modify the firmware. Is there any documentation of the Source Code? It's hard to handle so much Code without documentation. I also have some other questions:

1) A question about the main-loop-frequency: In stabilizer.c (line 104) it's said that the main-loop-frequency for a kalman-estimator should be 500 Hz, however in stabilizer_types.h (line 203) the rate is defines as 1kHz. Is this a mistake or am I misunderstanding something?

2)A question about a strange behavior while flying the copter: I used an official release firmware with the cfclient and a PS3 controller. I had to set down the maximum thrust to 40% because i was testing it indoor and my flying skills were very poor and i kept overriding the thrust. After reducing I had the problem that the copter wasn't able to fly. The props started rotating but suddenly stopped after 2-3 sec for about 4-5sec regardless what inputs i was giving on the controller. After the 4-5sec i was able to rotate the props again with the same outcome. Does it have to be like, if yes why?

3)The controller is very sensitive. A deflection of 50% of my thrust-stick is already considered as maximum thrust. If i want to modify this behavior, where do i have to look in the code? Is it part of the the cfclient? Do someone also know in which file it is implemented?

Thank You
Korrelator
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Understanding the Firmware

Post by tobias »

Hi and welcome to the forum!

The documentation isn't great :oops: (constancy evolving code) but the wiki is a good resource for more detailed documentation.

1) The sensor accusation is synced to the sensor output together with the body rate control (rate PID) and runs at 1khz. The complementary filter (attitude control) runs at 250Hz and if using the kalman it's predict state runs at 100Hz.

2) A behavior I haven't seen. My guess is that something is not right with the setup of PS3 controller. I think you need at least 60% thrust for it to take off.

3) What OS are you using. Any possibility to check the input from the PS3. I think it is this file you are looking for.
Korrelator
Beginner
Posts: 9
Joined: Fri Jun 02, 2017 12:49 pm

Re: Understanding the Firmware

Post by Korrelator »

Ty Tobias.

I have checked again and saw on my terminal that the connection is lost. The following error appears:

"Got link error callback [Too many packets lost] in state [2]"

some times it says in "in state [1]". Im using a PS3-Controller with crazyflie 2.0 and crazyradio on Linux. If i connect my client with the copter i get the following console output:

SYS: Crazyflie 2.0 is up and running!
SYS: Build 0:df11f2550b81 (2017.05) MODIFIED
SYS: I am 0x3131393135355115400052 and I have 1024KB of flash!
CFGBLK: v1, verification [OK]
MPU9250 I2C connection [OK].
AK8963 I2C connection [OK].
LPS25H I2C connection [OK].
DECK_DRIVERS: Found 9 drivers
DECK_INFO: Found 0 deck memory.
DECK_CORE: 0 deck enumerated
EEPROM: I2C connection [OK].
AK8963: Self test [OK].
SYS: Free heap: 20048 bytes

and it also passes always the selftest. I have just modified the color of the system-led (like in your tutorial) and i had the behavior also before modifying.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Understanding the Firmware

Post by arnaud »

Hi,

For the connection lost, you can try to change the radio channel and datarate. A datarate of 2M is usually much more stable indoor (since it will send shorter packet and be less affected by packet collision with wifi/bluetooth/etc...).

you can change the radio setting using the menu "connect/configure 2.0" in the client.
Mitteau
Expert
Posts: 248
Joined: Fri Jan 29, 2016 6:00 am

Re: Understanding the Firmware

Post by Mitteau »

Hello
I can give some details about PS3 joystick. Mine is very rough and I lost a cf2, gone away at high speed toward a local pond.... Lost....
So I wrote a post named: "Input devices problems" and I gave the input json file for my joystick.Throttle and yaw ont the left, pitch and roll on the right, something like in a real helicopter.
Trim is adjusted using right 4 buttons.
Shoulder left installs highthold.
Left trigger (lower side) is for the sound (siren to mare easily find the beast). Right triggers for lights, in cas of LED-ring.
START button allow connect and disconnect the client.
You must also look at the parameters of the joystick. At the beginning, axis acted as binary commands: 0 throttle or full throttle. That's why I lost my cf.
I have to press 10 seconds HOME button to shift to analog command.
Furthermore, I add an adjustable attenuation to soften PS3 commands.
Finally, I fly in advanced mode, with 8% as maximum PY values, and 62% for power.
Now, my cf2 has a very gentle behavior....
Hope this will be useful to use PS3 joysticks!
Yours truly
Jean-Claude
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Understanding the Firmware

Post by arnaud »

Hi Jean-claude, thanks for the explanations.

Is that an official PS3 or a third party PS3 controller? We have never had to press the PS button for 3 seconds in order to get good analog behavior. The only quirk with PS3/4 controllers is that they require to push the PS button once in order to activate the gamepad (and not have 100% thrust).
Mitteau
Expert
Posts: 248
Joined: Fri Jan 29, 2016 6:00 am

Re: Understanding the Firmware

Post by Mitteau »

It is an Undercontrol joystick..
SAM_3212_r.JPG
..
Mitteau
Expert
Posts: 248
Joined: Fri Jan 29, 2016 6:00 am

Re: Understanding the Firmware

Post by Mitteau »

Surprise, this morning, my wireless xbox, offended by the Undercontrol joystick, works perfectly on my Lifebook/xubuntu/cfclient control system...
Have a nice day
Jean-Claude
Mitteau
Expert
Posts: 248
Joined: Fri Jan 29, 2016 6:00 am

Re: Understanding the Firmware

Post by Mitteau »

New surprise... No connections of the joystick an the receiver, this morning, in any case. What's going on? Don't look to be a lost contact or a broken wire of the receiver...
Jean-Claude
Konstantin
Beginner
Posts: 17
Joined: Fri Aug 05, 2016 7:57 am

Re: Understanding the Firmware

Post by Konstantin »

Hey guys,

I had the same connection-loss-problems like described in the first posts. I tried to change the datarate and channels, but the error occured somewhere else:
If the Oracle VM VirtualBox is used to emulate the linux-system, it appears, that VM sets the USB-input to USB 2.0 as default. But my Laptop has USB 3.0, which leaded to a "mismatch". I changed the settings to USB 3.0 and i got finally rid of this connection-loss.
Maybe this can help trouble-shooting in future cases. One can change the USB-input-settings by right-clicking on the VM.
Post Reply