CrazyFlie altitude hold problem

Post here to get support
chad
Expert
Posts: 555
Joined: Sun Sep 28, 2014 12:54 am
Location: New York, USA
Contact:

Re: CrazyFlie altitude hold problem

Post by chad »

lgenzelis wrote:I attached the json file corresponding to the controller configuration, because there's something odd about it. Notice that the id correponding to "althold" is the same as the id corresponding to "pitch". If I change the id (manually, from the file) to something different, the althold button doesn't do anything.
Hi! :)

The button id numbers being the same for both pitch and althold is not an issue. The INPUT.axis and INPUT.button inputs are different and between the two, some will have the same ID. INPUT.axis correspond to your analog controls (right and left thumbs) whereas INPUT.button IDs correspond to specific buttons on your controller. For a Sony branded PS3 controller, the button IDs are as follows. I'm not sure if other brands are the same or if other controllers (ie. Xbox or PS4) are the same because I don't use those controllers. I expect all PS3 "type" controllers are likely the same but I have nothing to back that statement up!

0 = Select
1 = L3
2 = R3
3 = Start
4 = Digital Up
5 = Digital Right
6 = Digital Down
7 = Digitial Left
8 = L2 (digital mode)
9 = R2 (digital mode)
10 = L1
11 = R1
12 = Triangle
13 = Circle
14 = X
15 = Square
16 = PS

In my config, althold is mapped to the L1 button which is "10" as you can see here.

Since you're looking at the JSON file, you've probably deciphered it a bit, so you can edit the file directly. I made a copy of one and edited to my liking then called it something different (Custom_PS3.json for example). Once you've done that, make sure it's selected as the input device input map in the client. This way, you can set-up the button mapping without using the GUI.

Here's what mine looks like for my PS3 controller:

Code: Select all

{
  "inputconfig": {
    "inputdevice": {
      "updateperiod": 10, 
      "name": "PS3_ECS3", 
      "axis": [
        {
          "scale": 1.0, 
          "type": "Input.BUTTON", 
          "ids": [
            7, 
            5
          ], 
          "key": "rollcal", 
          "name": "rollcal"
        }, 
        {
          "scale": 1.0, 
          "type": "Input.AXIS", 
          "id": 0, 
          "key": "yaw", 
          "name": "yaw"
        }, 
        {
          "scale": 1.0, 
          "type": "Input.BUTTON", 
          "id": 9, 
          "key": "alt1", 
          "name": "alt1"
        }, 
        {
          "scale": 1.0, 
          "type": "Input.BUTTON", 
          "id": 8, 
          "key": "alt2", 
          "name": "alt2"
        }, 
        {
          "scale": 1.0, 
          "type": "Input.BUTTON", 
          "id": 12, 
          "key": "exit", 
          "name": "exit"
        }, 
        {
          "scale": 1.0, 
          "type": "Input.BUTTON", 
          "id": 11, 
          "key": "ring_effect", 
          "name": "ring_effect"
        }, 
        {
          "scale": 1.0, 
          "type": "Input.BUTTON", 
          "id": 14, 
          "key": "estop", 
          "name": "estop"
        }, 
        {
          "scale": -1.0, 
          "type": "Input.AXIS", 
          "id": 3, 
          "key": "pitch", 
          "name": "pitch"
        }, 
        {
          "scale": -1.0, 
          "type": "Input.AXIS", 
          "id": 1, 
          "key": "thrust", 
          "name": "thrust"
        }, 
        {
          "scale": 1.0, 
          "type": "Input.BUTTON", 
          "id": 10, 
          "key": "althold", 
          "name": "althold"
        }, 
        {
          "scale": 1.0, 
          "type": "Input.AXIS", 
          "id": 2, 
          "key": "roll", 
          "name": "roll"
        }, 
        {
          "scale": -1.0, 
          "type": "Input.BUTTON", 
          "ids": [
            6, 
            4
          ], 
          "key": "pitchcal", 
          "name": "pitchcal"
        }
      ]
    }
  }
}
Once you are "in flight" you should be able to hold down the althold button and the Crazyflie will maintain (roughly) a similar altitude (as long as you keep the button held) from the height when you hit the button. I think you can adjust this height (while continuing to hold the althold button) by increasing or decreasing thrust. You might want to try throttle down as soon as you hit althold.

Be aware that the althold feature uses the barometer and it is not precise. Furthermore, direct sunlight on the baro can cause major fluctuations so flying by a window on a sunny day can wreak havoc on your alt-holding!

To see if the barometer is detecting changes in height, you can open a "Log blocks" tab in your client GUI and check the box next to "Baro" to log the values and check the box to log to a file as well (for later plotting if you wish). The file ends up in crazyflie-clients-python/conf/logdata. Also, open up a "Plotter" tab and select Baro to see the values graphed in real time. Do you baro values reflect the rising and falling of your Crazyflie?

Hope this helps!
Crazyflier - my CF journal...
4x Crazyflie Nano (1.0) 10-DOF + NeoPixel Ring mod.
3x Crazyflie 2.0 + Qi Charger and LED Decks.
Raspberry Pi Ground Control.
Mac OS X Dev Environment.
Walkera Devo7e, ESky ET6I, PS3 and iOS Controllers.
lgenzelis
Beginner
Posts: 8
Joined: Mon Jan 25, 2016 8:16 pm

Re: CrazyFlie altitude hold problem

Post by lgenzelis »

Thanks for your reply chad! I seem to run into you everywhere on the forums! haha. Ok, so there's nothing wrong with the ids. My baro works fine, the values I get make sense (though they're noiser than I would have wanted them to be! But nothing odd about that.).

I'm a bit new to flying quadrotors so I cannot manually hover to try if this works as you say. However, I don't think that what I experience is proper behaviour. Could you please try this?: hold your crazyflie 2.0 with your hand (so that it doesn't fly away), without touching any button (so, no thrust), and press your althold button. What does the crazyflie do? What do you see in the gui, in the flight control tab, on the target ASL textfield? In my case, the mottors go automatically to full speed (so, if released the quad, it would crush to the ceiling), and I see nothing on the target ASL textfield.
chad
Expert
Posts: 555
Joined: Sun Sep 28, 2014 12:54 am
Location: New York, USA
Contact:

Re: CrazyFlie altitude hold problem

Post by chad »

lgenzelis wrote:Thanks for your reply chad! I seem to run into you everywhere on the forums!
Haha! :D Yeah, I'm a prolific poster. Don't know how much of my drivel is valuable though. :oops:
lgenzelis wrote:Could you please try this?: hold your crazyflie 2.0 with your hand (so that it doesn't fly away), without touching any button (so, no thrust), and press your althold button. What does the crazyflie do? What do you see in the gui, in the flight control tab, on the target ASL textfield? In my case, the mottors go automatically to full speed (so, if released the quad, it would crush to the ceiling), and I see nothing on the target ASL textfield.
Good idea! I just tried it. The Thrust goes to 49%. Target ASL goes from "Not set" to 388.26. Motors are all about 99%. If I take off manually, then hit the althold button, it rises pretty quickly then drops back down to around the height it was when I hit the button. It fluctuates from there. I tried it on two Crazyflie 2.0s and both had the same behavior.

I using the latest Client available on the "develop" branch (032c826783251ce31fdd677108b6088343fd4000) and the latest firmware available on "master" (2cad61d5f1a4f836db2398e441e542a905dd0fe5).

As part of the diagnosis, perhaps check the "Console" tab in the Client and make sure it looks something like this after power-on self test (POST):

Code: Select all

CFGBLK: v1, verification [OK]
IMU: MPU9250 I2C connection [OK].
IMU: AK8963 I2C connection [OK].
IMU: LPS25H I2C connection [OK].
DECK_DRIVERS: Found 5 drivers
DECK_INFO: Found 0 deck memory.
DECK_CORE: 0 deck enumerated
EEPROM: I2C connection [OK].
AK8963: Self test [OK].
LPS25H: Self test [OK].
SYS: Free heap: 5376 bytes
Also, I found the wiki page where I got most of my info about the Altitude Hold feature. I couldn't remember where I'd read all that info I posted in my last post.
Crazyflier - my CF journal...
4x Crazyflie Nano (1.0) 10-DOF + NeoPixel Ring mod.
3x Crazyflie 2.0 + Qi Charger and LED Decks.
Raspberry Pi Ground Control.
Mac OS X Dev Environment.
Walkera Devo7e, ESky ET6I, PS3 and iOS Controllers.
lgenzelis
Beginner
Posts: 8
Joined: Mon Jan 25, 2016 8:16 pm

Re: CrazyFlie altitude hold problem

Post by lgenzelis »

I'm a prolific poster
So I see!

Well, then it seems that my quad isn't doing anything strange and that I was worried about nothing. I'm using the same version from client and firmware that you are, and my console output is similar to that one.

Thank you for the wiki link. I had already read that in the thread from the developer of the hold mode (a post from 2013 I think).
Post Reply