Combining Axes for Trim

Official forum for open source FreePIE discussion and development.
Post Reply
Billhelm
One Eyed Hopeful
Posts: 14
Joined: Fri Oct 11, 2013 7:01 pm

Combining Axes for Trim

Post by Billhelm »

Hello all,

I'm working on a project using FreePIE to fly RC aircraft. It's going pretty well, but I've run into a snag regarding trim. In the code below, Joystick 1 is aileron/elevator, joystick 2 is throttle, joystick 3 is rudder, and joystick 4 trims aileron, elevator, and rudder.
from System import Int16

if starting:
joystick[1].setRange(0, 2048)
joystick[2].setRange(0, 2048)
joystick[3].setRange(0, 2048)
joystick[4].setRange(0, 2048)

x = Cyclic.getY(joystick[4].x /2 -512 + joystick[1].x)
y = Cyclic.getY(joystick[4].y /2 -512 + joystick[1].y)
z = Rudder.getY(joystick[4].z /2 -512 + joystick[3].zRotation)

vJoy[0].x = filters.mapRange(x, 0, 2048, -Int16.MaxValue, Int16.MaxValue)
vJoy[0].y = filters.mapRange(y, 0, 2048, -Int16.MaxValue, Int16.MaxValue)
vJoy[0].z = filters.mapRange(z, 0, 2048, -Int16.MaxValue, Int16.MaxValue)
vJoy[0].rx = joystick[2].z
vJoy[0].ry = joystick[2].zRotation
It more or less works, but with two not so desirable side effects.

1) With this method, if I trim in one direction, I can never fully go in the other direction.
2) Because I'm using curves, once I have trimmed, I'm no longer in the center of the curve, and one direction will be more 'aggressive' than the other.

Is it possible to have trim without running into one or both problems? If so, would anyone know how to go about doing so?
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Combining Axes for Trim

Post by CyberVillain »

Can you please post a pic of your curve?

edit: Latest version have more control over the Curve, you can now use negative values etc, thats why I wonder
Billhelm
One Eyed Hopeful
Posts: 14
Joined: Fri Oct 11, 2013 7:01 pm

Re: Combining Axes for Trim

Post by Billhelm »

Here are my curves. They run from 0,0 to 2048,2048, and are symmetric at 1024,1024.

Image
Billhelm
One Eyed Hopeful
Posts: 14
Joined: Fri Oct 11, 2013 7:01 pm

Re: Combining Axes for Trim

Post by Billhelm »

So a coworker and I puzzled this out:

Code: Select all

if starting:
   joystick[1].setRange(0, 2048) 
   joystick[2].setRange(0, 2048) 
   joystick[3].setRange(0, 2048)
   joystick[4].setRange(0, 8192)

x = Cyclic.getY(joystick[1].x)
y = Cyclic.getY(joystick[1].y)
z = Rudder.getY(joystick[3].zRotation)

Tx = joystick[4].x
Ty = joystick[4].y
Tz = joystick[4].z

vJoy[0].x = Tx -4096 + filters.mapRange(x, 0, 2048, -Int16.MaxValue, Int16.MaxValue)
vJoy[0].y = Ty -4096 + filters.mapRange(y, 0, 2048, -Int16.MaxValue, Int16.MaxValue)
vJoy[0].z = Tz -4096 + filters.mapRange(z, 0, 2048, -Int16.MaxValue, Int16.MaxValue)
vJoy[0].rx = joystick[2].z
vJoy[0].ry = joystick[2].zRotation
I'm not sure why we need such a large range for joystick[4].setRange, but the thing flies like a champ, so I won't complain.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Combining Axes for Trim

Post by CyberVillain »

Glad you got it , a tip, you are not using latest version of FreePIE, the new version has much more control over the curves
Post Reply

Return to “FreePIE”