Page 1 of 1

Raspberry Pi X-Mode

Posted: Mon Jun 10, 2013 2:39 pm
by BagOfArms
I've tried searching for this using Google and the forum search, but i haven't found any results. Please let me know if there are any existing resources about this.

I used this tutorial to turn my Raspberry Pi into a base station:
http://wiki.bitcraze.se/projects:crazyf ... rasberrypi

Everything works perfectly, but i'm used to flying in "x" mode, and I have been unable to enable this mode. I have tried changing “client_side_xmode” to “true” in “crazyflie-pc-client/lib/cfclient/configs/config.json”, but that doesn't seem to change it. Here's the contents of that config file:

Code: Select all

{
  "writable" : {
    "input_device": "", 
    "link_uri": "", 
    "flightmode": "Advanced", 
    "open_tabs": "Flight Control", 
    "trim_pitch": 0.0, 
    "slew_limit": 45, 
    "slew_rate": 30, 
    "trim_roll": 0.0, 
    "max_thrust": 80, 
    "min_thrust": 25, 
    "max_yaw": 200, 
    "max_rp": 30,
    "client_side_xmode": true,
    "device_config_mapping": {}
  },
  "read-only" : {
    "normal_slew_limit": 45, 
    "normal_slew_rate": 30, 
    "normal_max_thrust": 80, 
    "normal_min_thrust": 25, 
    "normal_max_yaw": 200, 
    "normal_max_rp": 30,
    "default_cf_channel": 10,
    "default_cf_speed": 0,
    "default_cf_trim": 0
  }
}
Does the headless Linux version even support client side xmode? I found this on line 283 of "crazyflie-pc-client/lib/cfclient/ui/tabs/FlightTab.py":

Code: Select all

self.helper.cf.commander.set_client_xmode(checked)
But no corresponding line for the headless (non-UI) version.

Which corresponds to this in "crazyflie-pc-client/lib/cflib/crazyflie/commander.py":

Code: Select all

    def set_client_xmode(self, enabled):
        """
        Enable/disable the client side X-mode. When enabled this recalculates
        the setpoints before sending them to the Crazyflie.
        """
        self._x_mode = enabled
It's looking like the headless version doesn't ever set the xmode, The quick solution is to change commander.py to initialize with xmode set to true (this works), but i would rather not start hacking things if there's an existing solution i'm overlooking. Am i crazy, or barking up the wrong tree?

Re: Raspberry Pi X-Mode

Posted: Mon Jun 10, 2013 2:44 pm
by BagOfArms
I just found this issue in the repo:
"The config values for the input device (like max_rp, max_yaw, etc..) is not passed to the input layer until the FlightControlTab is showed. The config values should be loaded when Input is created."
https://bitbucket.org/bitcraze/crazyfli ... fig-values

The resolution of this will probably fix this problem, since both cfclient and cfheadless create Input, but only cfclient loads the FlightControlTab.

Re: Raspberry Pi X-Mode

Posted: Sat Jul 20, 2013 1:28 pm
by absoloodle37
Did you ever get this issue resolved? I'm trying to change the max thrust parameter in the headless client from 80 to 99. Is there a corresponding parameter in commander.py I can change?

Thanks

Re: Raspberry Pi X-Mode

Posted: Tue Aug 06, 2013 1:06 pm
by marcus
No, there's no solution for this yet. If you just want it working quickly then do what BagOfArms suggested and initialize the xmode variable to true in the commander.

Re: Raspberry Pi X-Mode

Posted: Tue Aug 13, 2013 11:53 pm
by absoloodle37
What about changing the thrust limit on the headless client? When I use my RPI to fly my CF, I'm always limited to 80% thrust and the default roll/bank limits. Can I change these parameters in the code?

Thanks

Re: Raspberry Pi X-Mode

Posted: Wed Aug 14, 2013 11:30 am
by hsanjuan
Hello,

for Raspberri Pi perhaps you want to have a look to my alternative Ruby client https://github.com/hsanjuan/crubyflie

I activate xmode by pressing a joystick button (which is configured to :switch_xmode) and the thrust limits are also directly configured in the joystick configuration file (the :output_range option). It also uses less CPU which is a plus on small system like the RP.

Re: Raspberry Pi X-Mode

Posted: Thu Oct 03, 2013 3:13 am
by absoloodle37
hsanjuan, thanks for suggesting your Ruby client. I'm no programmer, but I was able to install your Crubyflie client on my R-Pi using your instructions and some additional tweaking of the file: /root/bin/cfheadless so that it points to crubyflie instead of the python cfheadless client. Now the Crubyflie program launches when I plug in my usb antenna and I can SSH into the R-Pi using my mac to change parameters while I'm flying.

I'll post what I learned on your Crubyflie thread, but I just wanted to let you know the Ruby client is a great solution for flying with the R-Pi because I can modify the control sensitivities/parameters to customize how I like to fly. Thanks! What a great contribution!

Re: Raspberry Pi X-Mode

Posted: Thu Oct 03, 2013 11:39 am
by hsanjuan
Thanks @absoloodle37, feel free to suggest improvements in the github project. Right now my CF is broken and i have been too busy to repair it but hopefully it will be back in the air soon :D