First off, bear with me, this is my first contraption in wiremod of any decent size. I use four expression chips that I wrote, 14 wire thrusters, one gyroscope, a button, and an advanced pod controller. I call it Version 2 btw as I had a Version 1 but it wasn't nearly as good, it bounced around a lot.
Now first off let me explain the controls. W, A, S, and D move you left right and forward backward. Left and Right mouse button rotate. Shift and Alt move you up and down. Spacebar turns on and off rotation breaking, R turns on and off Movement breaking. The Reset button resets the learned values back to 0.
What I mean by learning is that it will sense if it is off from being at perfectly flat or perfectly at the specified altitude and will continue to fudge it until it comes into place. This gets to the specified altitude or angle within 10 seconds or so out to within 3 decimal places. So if you stand on it it will even out to be flat even with you standing on one side of it. This works well enough that I have 4 white blocks on the platform such that you can change the weight from 1 to 1000 on one corner and it will rapidly go back to flat. It does the same thing for altitude.
What I mean by breaking is that when it is on if no input is being put in of that kind then it will rapidly break all motion of that kind. The spin, forward-back, and left-right are each each separate. So if you are holding down both W and S and moving diagonally like that and you let go of Left then it will break all horizontal movement while you continue to move forward.
Also one warning, it doesn't like being frozen. I put in some code to mitigate it but if you freeze it very near (or at) completely flat and almost exactly at the altitude it is trying to get to the learning code keeps trying to adjust itself and it cant so it keeps increasing and increasing. So if you do freeze it at flat, before you use it, it is suggested you hit the reset button otherwise it will be temporarily crazy as it quickly readjusts itself.
Here is the code for my expression chips. I am sorry that it is uncommented but if anyone has questions just ask. Anyone is welcome to use the chips or modify them. You don't have to tell me, but I would appreciate it if you told me when you do so. All this code is mine but I took inspiration from random bits of code I used to learn from.
I welcome any suggestions for improvement or critiques anyone has.
Roll Control v2
Inputs: Roll - Roll from an input gyroscope. ExOn - Reset button.
Outputs: ThrustR - Thrust to right side thruster. ThrustL - Thrust to left side thruster.
N@Roll Control v2
I@Roll ExOn
O@ThrustR ThrustL
interval(20)
first() -> RBalance = 0;
(!ExOn & ~ExOn) -> RBalance = 0;
clk() ->
Roll > 0 -> RollNew = Roll - 180;
Roll < 0 -> RollNew = Roll + 180;
Roll == 0 -> RollNew = 180;
ThrustL = 0, ThrustR = 0, Smoother = 10
abs($RollNew) < 0.1 & !($RollNew == 0 & abs(RollNew) > 1) -> RBalance += 0.01 * RollNew;
ThrustR = RollNew + RBalance + $RollNew * Smoother
ThrustL = -ThrustR;
Pitch Control v2
Inputs: Same as above (but with pitch)
Outputs: Same as above (but front and back)
N@Pitch Control v2
I@Pitch ExOn
O@ThrustF ThrustB
interval(20)
first() -> PBalance = 0;
(!ExOn & ~ExOn) -> PBalance = 0;
clk() ->
ThrustF = 0, ThrustB = 0, Smoother = 10
abs($Pitch) < 0.1 & !($Pitch == 0 & abs(Pitch) > 1) -> PBalance += 0.01 * Pitch;
ThrustF = Pitch + PBalance + $Pitch * Smoother
ThrustB = -ThrustF;
Altitude Control v2
Inputs: Up - Up key from pod controller. Down - Down key from pod controller. Fast - Unused on my platform, but increases up down speed by 10 when held down and also going up or down. ExOn - Same ExOn as above.
Outputs: Thrust - Thrust to the four downward thrust thrusters.
N@Altitude Control v2
I@Up Down Fast ExOn
O@Thrust
interval(20)
Smoother = 10, Speed_smth = 500, Speed = 200
first() -> ZBalance = 0, Target = round(extposz() / (Speed * 0.02)) * (Speed * 0.02);
!ExOn & ~ExOn -> ZBalance = 0;
clk() ->
Fast -> Speed *= 10;
Target += Speed * 0.020 * (Up - Down)
Zloc = extposz(), Dist = Target - Zloc
Thrust = Dist + ZBalance + -$Zloc * Smoother
abs($Zloc) > 5 -> Thrust += -$Zloc * Speed_smth;
abs($Zloc) < 0.1 & !Up & !Down & !($Zloc == 0 & abs(Dist) > 1) -> ZBalance += 0.01 * Dist;;
Yaw and Movement Control v2
Inputs: Inputs labeled with their output names from adv pod controller are obvious. Yaw - Input Yaw from Gyroscope. Yaw_In - The key for turning on and off Yaw Breaking. Thrust_In - The key for turning on thrust breaking.
Outputs: YawR - Output to Yaw Thrusters. Forward - Thrust to the thruster that makes you move forward (the one in the back). Back - Thrust to the thruster that makes you move back (the one in the front). Same for Right and Left (reversed like that).
N@Yaw and Movement Control v2
I@W A S D Mouse1 Mouse2 Yaw Yaw_In Thrust_In
O@YawR Forward Back Right Left
interval(20)
first() -> Yaw_Break = 0, Thrust_Break = 0, Yaw_last = Yaw, Test = 0;
~Yaw_In & Yaw_In -> (Yaw_Break ? Yaw_Break = 0 : Yaw_Break = 1);
~Thrust_In & Thrust_In -> (Thrust_Break ? Thrust_Break = 0 : Thrust_Break = 1);
clk() ->
X = extposx(), Y = extposy(), Forward = 0, Back = 0, Left = 0, Right = 0
(Mouse1 | Mouse2 | !Yaw_Break ? YawR = Mouse2 - Mouse1 : YawR = $Yaw)
New_Y_chg = cos(Yaw) * $X + sin(Yaw) * $Y
New_X_chg = sin(Yaw) * $X + cos(Yaw) * -$Y
(W | S | !Thrust_Break ? Forward = W - S : Forward = -New_Y_chg)
Back = -Forward
(D | A | !Thrust_Break ? Right = D - A : Right = -New_X_chg)
Left = -Right;
Advanced Duplicator Save is included. Highly suggest that you use it instead of trying to reuse the chips.
Edit: Updated my hover platform slightly. The chips are exactly the same except a very few slight modifications (added some outputs of values that were already there). Outputed those values to 5 Wire HUD Indicators so when you get in you can see your current Pitch, Roll, Yaw, Target Altitude, and current Z Altitude. Also made an online version that is slightly modified with a few less thrusters (14 down to 10) so that it can be uploaded on to servers and used without the server removing thrusters. Also removed thruster effects for online version. (I might add it doesn't work quite as well, little more sluggish, but other than that it is fine.)


LinkBack URL
About LinkBacks




Reply With Quote

Bookmarks