Page 1 of 2

Controller modding

Posted: Tue May 21, 2013 4:05 pm
by OKButton
The only issue with the ps3 and xbox controllers is the fact that the analog sticks auto center. This is a problem for the throttle/yaw stick which you would prefer to only auto center horizontally (yaw) and allow full vertical motion (throttle) without auto centring.
I have found http://www.sainsburysentertainment.co.u ... =E11170992 sell a cheep (£9.99) ps3 copy controller and I have started to take it to bits in order to only allow centring of the right stick in the horizontal plane. This seems like it will be successful and I will post pics here soon.
I am not sure if anyone has tried this with other controllers but I would be interested to here if this is simpler on other models. Also when complete It would be good to be able to configure the throttle to the full scale of the vertical access allowing for no throttle in the down position to full throttle in the up position. I havent tried yet but is this possible to achieve by manual edit of the profile file for the controller. It would be nice to have this as an option in the application if not and for simpler activation in the future.

Re: Controller modding

Posted: Tue May 21, 2013 6:14 pm
by rmirwin2
Hello OK and all!

I've been meaning to comment on this issue for a couple days. I'm also running an Wireless XBox360 controller, something I just happened to have on hand and was considering upgrading.

What I've noticed is the Crazyflie is pretty much un-flyable, as the right stick's values are only about +/- 9 units of zero when you let go of that stick. That's pretty annoying and quite enough to keep the Flie from doing anything useful. At first I thought it was balance and trim issues, but no, it's the lack of a reliable zero in the pitch and roll axis. On my 360, the left stick isn't so bad, probably only +/-0.2 units. That's no problem for Thrust, but does give a yaw problem which is easily confused for accidental change in yaw when the thrust axis is moved.

Researching this I find it's a known issue with XBox360 controllers. A response inside of many games has been to implement a DEADZONE around zero within the software.

My suggestion is to add a DEADZONE value for each of these axis for the Crazyflie. I suspect it could really help other controllers besides the XBox360 controller as well.

To test this possibility, a added some lines of code inside the VM at /projects/crazyflie-pc-client/lib/cfclient/utils/pygamereader.py. This allows for a scan of values returned for each Input.AXIS value in real time. Any value in the range between -deadzone and +deadzone should simply be set to be zero.

Code: Select all

          if e.type == pygame.locals.JOYAXISMOTION:
            index = "Input.AXIS-%d" % e.axis 
            try:
                if (self.inputMap[index]["type"] == "Input.AXIS"):
                    key = self.inputMap[index]["key"]
                    axisvalue = self.j.get_axis(e.axis)
                    # All axis are in the range [-a,+a]
                    axisvalue = axisvalue * self.inputMap[index]["scale"]
		    # Add deadzone but this breaks hover
		    deadzone=0.15
		    self.data[key] = 0.0
		    if (axisvalue >= deadzone) : 
			self.data[key] = axisvalue
		    elif (axisvalue <= -deadzone) : 
			self.data[key] = axisvalue
                    # The value is now in the correct direction and in the range [-1,1]
                    #self.data[key] = axisvalue
            except Exception:
                # Axis not mapped, ignore..
                pass              
To my delight and surprise, even this terrible code totally fixed that centering problem and I could easily hover the crazyflie and have all the fun I knew was there! Even using just one deadzone threshold for each of the four axis works beautifully, effectively ignoring minute stick movements.

NOTE: No one should use this code as-is within pygamereader.py because it does break the "hover" branch, which I am keen to use. Clicking the Hover button zeroes all the values. I expect the P&ID doesn't like seeing zeros but haven't had a look further as this needs serious consideration.

This is only an experiment, a crude attempt to see if DEADZONE is something to recommend.

At this point I really think DEADZONE is essential for anyone with an XBOX360 controller, and recommend it for further development! Ultimately, it could be a better solution than hacking your controller. It's a concept already included in many gaming applications. We need it here too!

Just my two cents!
Rich

Re: Controller modding

Posted: Tue May 21, 2013 9:20 pm
by TheFrog4u
When using the Motioninjoy driver you can set a deadzone value there. Personaly I use a ps3 controller and put +- 30% deadzone on the yaw axis (left stick for me) and additionaly set max yawrate to 100 in the cfclient. Works beautifully.

Re: Controller modding

Posted: Wed May 22, 2013 12:39 am
by rmirwin2
Greets and thanks for the tip TheFrog4u!

From reading the board it seemed that MotionJoy was only for used to interface DS3 controllers. Is that not the case?

I completely missed that MotionJoy would have benefit for the XBox360, but if that's the case I'm all for it. Is there a linux version of the MotionJoy driver for use in the Ubuntu VM environment?

For the latter case, it turns out there is also a DEADZONE setting for XBOXDRV, which I've used inside of the VM so far. I'll be giving that a shot tonight.

Back to the OKButton's question, it seems software is a viable way to overcome some of the XBox360's shortcomings!

Thanks!
Rich

Re: Controller modding

Posted: Wed May 22, 2013 1:13 am
by rmirwin2
From within the VM, I used this instead tonight:

xboxdrv --deadzone 15% --silent

Works just fine to add the DEADZONE around all the axes. Much cleaner way to go.

Rich

Re: Controller modding

Posted: Thu May 23, 2013 5:42 am
by allynbauer
I have been working on a variety of enhancements mostly in the form of more advanced config settings for axises. This allows enabling a deadband for each. I will make a pull request on the bitbucket repo when it is ready.
Image

Re: Controller modding

Posted: Thu May 23, 2013 1:36 pm
by rmirwin2
Aw wow, that looks awesome! I'll be watching for it!

What types of scaling are you thinking about for the drop-down?!!

Rich

Re: Controller modding

Posted: Thu May 23, 2013 1:58 pm
by DesTinY
Great! A non linear controlling possibility is really needed!

Re: Controller modding

Posted: Thu May 23, 2013 2:38 pm
by tobias
Awesome! We have been planning to do this for a long time and now you come to the rescue. Great!

Re: Controller modding

Posted: Thu May 23, 2013 3:21 pm
by allynbauer
rmirwin2 wrote:What types of scaling are you thinking about for the drop-down?!!
Currently there are three. The linear one and two others. They are implemented in terms of a function which curves an input value from the controller to an output, which is processed further and finally send to the UI and the radio.