Controller modding

Discussions and questions about the Crazyflie Nano Quadcopter
OKButton
Beginner
Posts: 2
Joined: Tue May 21, 2013 3:22 pm
Location: UK
Contact:

Controller modding

Post by OKButton » Tue May 21, 2013 4:05 pm

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.



rmirwin2
Member
Posts: 51
Joined: Mon May 13, 2013 6:06 pm

Re: Controller modding

Post by rmirwin2 » Tue May 21, 2013 6:14 pm

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
VGer's v1.7.1 frame, 10DOF Crazyflie, Wireless Xbox360 Controller, Virtual Machine on VMware/Windows 7

TheFrog4u
Expert
Posts: 113
Joined: Fri Feb 08, 2013 6:59 pm
Location: Bremen, Germany

Re: Controller modding

Post by TheFrog4u » Tue May 21, 2013 9:20 pm

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.

rmirwin2
Member
Posts: 51
Joined: Mon May 13, 2013 6:06 pm

Re: Controller modding

Post by rmirwin2 » Wed May 22, 2013 12:39 am

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
VGer's v1.7.1 frame, 10DOF Crazyflie, Wireless Xbox360 Controller, Virtual Machine on VMware/Windows 7

rmirwin2
Member
Posts: 51
Joined: Mon May 13, 2013 6:06 pm

Re: Controller modding

Post by rmirwin2 » Wed May 22, 2013 1:13 am

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
VGer's v1.7.1 frame, 10DOF Crazyflie, Wireless Xbox360 Controller, Virtual Machine on VMware/Windows 7

allynbauer
Beginner
Posts: 12
Joined: Mon May 06, 2013 6:59 pm

Re: Controller modding

Post by allynbauer » Thu May 23, 2013 5:42 am

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

rmirwin2
Member
Posts: 51
Joined: Mon May 13, 2013 6:06 pm

Re: Controller modding

Post by rmirwin2 » Thu May 23, 2013 1:36 pm

Aw wow, that looks awesome! I'll be watching for it!

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

Rich
VGer's v1.7.1 frame, 10DOF Crazyflie, Wireless Xbox360 Controller, Virtual Machine on VMware/Windows 7

DesTinY
Member
Posts: 97
Joined: Sat Feb 09, 2013 5:18 pm
Location: Bünde, Germany

Re: Controller modding

Post by DesTinY » Thu May 23, 2013 1:58 pm

Great! A non linear controlling possibility is really needed!

tobias
Bitcraze
Posts: 1904
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Controller modding

Post by tobias » Thu May 23, 2013 2:38 pm

Awesome! We have been planning to do this for a long time and now you come to the rescue. Great!

allynbauer
Beginner
Posts: 12
Joined: Mon May 06, 2013 6:59 pm

Re: Controller modding

Post by allynbauer » Thu May 23, 2013 3:21 pm

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.

Post Reply