NanobyteTrainee Engineer
- Messages:
- 25
Does anybody have any clue on how to approach this?
Nanobyte,Nov 15, 2015
#1
plaYer2kMaster Engineer
- Messages:
- 3,160
sure, here is a suggestion for how to approach it
- get the natural gravity through a remote
- get all gyros you want to use in order to turn
- get the current orientation so you can compute the angular offset from current to ideal orientation
- transform the orientation offset to all gyros to turn them in that direction
- optionally apply some smooth magic like PID or other dynamic meassure system to guess the moment of inertia tensor in order to build a simple physics model
plaYer2k,Nov 16, 2015
#2
NanobyteTrainee Engineer
- Messages:
- 25
Thanks player, i like a coding challenge so ill start with the above, and if that causes me too much headaches ill continue with the last option
Nanobyte,Nov 16, 2015
#3
plaYer2kMaster Engineer
- Messages:
- 3,160
Sure that. Also if you got issues at one of the steps, dont hestitate to ask for help.
For months now i was too busy/lazy to do the "orient gyro towards point" now but i will need it too soon. I will also need to code that myself because i dont like most of the implementations i have seen.
So i dont know all the answers myself but "the community" as a whole does. Not that the tast is particularly hard but i simply didnt bother doing it yetGood luck and enjoy the tinkering.
plaYer2k,Nov 16, 2015
#4
NanobyteTrainee Engineer
- Messages:
- 25
Ok i will keep you updated on anything that works out the way it should, im currently trying to align my vehicles down vector with the data from GetNaturalGravity()
But im not sure if that vector even is a normal direction vector. Its been a long since i've done vector math so im a little rusty on that endNanobyte,Nov 16, 2015
#5
HarrekinMaster Engineer
- Messages:
- 3,077
Vector from ship to centre of planet.
Vector of ships direction of travel.Get dot product and adjust gyros to keep it as close to zero as possible.
Harrekin,Nov 16, 2015
#6
plaYer2kMaster Engineer
- Messages:
- 3,160
But what is a one-dimensional value worth when you got three dimensions to rotate in
So no it aint that simple, but it aint much worse than that too.plaYer2k,Nov 16, 2015
#7
NanobyteTrainee Engineer
- Messages:
- 25
I'm stumped at the moment, i think im getting confused by the gyro itself. Not sure if i'll be able to break this one
Nanobyte,Nov 16, 2015
#8
HarrekinMaster Engineer
- Messages:
- 3,077
Youre only looking to maintain a right angle from the ship to the centre of the planet tho so only two options, no?
Harrekin,Nov 16, 2015
#9
plaYer2kMaster Engineer
- Messages:
- 3,160
Yeah but in which direction is important aswell. What is a value of 0.3 worth when you dont know around which of the three axis the gyros have to turn around? Would you want to define that in a fixed manner for every program and physical setup you got?
Instead the car needs to have a defined orientation. Transforming the gravity vector through the inverted orientation matrix gives a local gravity vector. With that local vector you can then form the parameters for rotations around that anchor block. Things like PID come to mind there.
Now that you got your rotational parameters you can transform these to the local orientation of each gyro to kill their three rotational parameters aswell as power as optional parameter.plaYer2k,Nov 16, 2015
#10
NaosythTrainee Engineer
- Messages:
- 9
I actually programmed something really similar yesterday. I can share my code when I get home from work in a few hours. I determine my roll and pitch using my forward and right vectors in relation to the gravity vector. I then use a PID controller to adjust my pitch and roll to bring my ship to a stop, using a helicopter-like flight model.
Naosyth,Nov 16, 2015
#11
AutoMcDSenior Engineer
- Messages:
- 2,369
I have a somewhat related idea that maybe you can include:
To automatically enable/disable UP thrusters so that the ship thrust/weight Going upwards matches the side thruster performance, after factoring in weight and gravity.This would make something with a LOT of cargo lifting capacity much more predictable to fly.
AutoMcD,Nov 16, 2015
#12
NanobyteTrainee Engineer
- Messages:
- 25
Sounds cool Naosyth, if you wouldn't mind sharing, i am still bumping into things to try and figure out how to get it working correctly
Nanobyte,Nov 16, 2015
#13
JoeTheDestroyerJunior Engineer
- Messages:
- 573
Threw this together, seems to work reasonably well:
Just have a timer running the PB and "trigger now"-ing itself. It's setup to align based on the remote control block. (If you have more than one, it will take the first one it finds.) If you want to use a different reference, just changing how "down" is assigned should be enough (down is in grid-local coordinates).By default it will use all the gyros it can find (well, 999). This works best if you don't need any steering. If you need steering try setting the limit lower, then the script will allow you to pitch/roll but will slowly correct it (yaw should be unaffected.)
Last edited: Nov 17, 2015
JoeTheDestroyer,Nov 17, 2015
#14
- Like x 3
NanobyteTrainee Engineer
- Messages:
- 25
I will not need the steering, i just want to make a drone that is able to achieve the above, but i keep having the feeling that im either getting the wrong values, or that i keep doing something wrong in the math
Nanobyte,Nov 17, 2015
#15
NanobyteTrainee Engineer
- Messages:
- 25
Derp, i didnt notice you input code at first, thanks! ill play around with this tomorrow see if i can achieve what i like, im sure it will teach me multiple things
Nanobyte,Nov 17, 2015
#16
NanobyteTrainee Engineer
- Messages:
- 25
Joe thank you very much for sharing ! This does exactly what i was trying to achieve, and i learned that the way i approached it especially the gyro part is what held me back. You saved me a lot of headaches
Nanobyte,Nov 17, 2015
#17
AutoMcDSenior Engineer
- Messages:
- 2,369
Anyone have it shared on workshop?
AutoMcD,Nov 17, 2015
#18
JoeTheDestroyerJunior Engineer
- Messages:
- 573
No problem, I'm glad all that digging I did in the gyroscope code on github finally proved useful Not me, I don't bother much w/ the workshop.
If somebody else wants to clean it up and post it, that's fine by me.
JoeTheDestroyer,Nov 17, 2015
#19
AutoMcDSenior Engineer
- Messages:
- 2,369
Ok. Makes it easier to use in-game when you can paste it in straight off steam.
AutoMcD,Nov 17, 2015
#20
JoeTheDestroyerJunior Engineer
- Messages:
- 573
I keep all my scripts in the local scripts folder, they can be used the same way as from steam that way. (And I can edit them with Notepad++, rather than the awful in game editor.)
You can use the "Browse Workshop" -> "Create from editor" option to do this (after you paste the script into the editor the first time).
JoeTheDestroyer,Nov 17, 2015
#21
NaosythTrainee Engineer
- Messages:
- 9
I reworked my helicopter braking script a bit. It no longer uses a PID loop, just some math to determine angles and rotation rates. You can take a look at it here if you're curious how it works. It's my first Space Engineers program, so any feedback would be great. It takes a slightly different approach to aligning the ship with the planet's gravity, so maybe it will still be useful to you.
Naosyth,Nov 17, 2015
#22
JoeTheDestroyerJunior Engineer
- Messages:
- 573
This will give unexpected results when your simspeed drops (i.e. game time is slower than real time). If it weren't broken atm, you should use ElapsedTime. As it is, the only real choice is to run your script every tick (timer TriggerNow) so that dt=1000/60.Code:
long now = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond;double dt = now - oldTime;
This isn't necessary anymore. Use the WorldMatrix property of blocks/grids to get a translation/orientation matrix, then the matrix Forward, Right, Up properties to get the directions you want.Code:
// Get orientation vectorsVector3 normalVec = Vector3.Normalize(remotePos - computerPos);Vector3 forwardVec = Vector3.Normalize(gyroPos - computerPos);Vector3 rightVec = Vector3.Normalize(timerPos - computerPos);
Code:
Vector3 gravityVec = Vector3.Multiply(Vector3.Normalize(Remote.GetNaturalGravity()), -1);
I'm not sure about your math, it looks like it just boils down to proportional control to me. But I maybe missing something.Code:
Vector3 gravityVec = -Vector3.Normalize(Remote.GetNaturalGravity());
The thing about gyros is that even though Keen says everywhere (UI, value names) that the 3 values are yaw, pitch, and roll, they really aren't. They are the X (pitch), Y (yaw) and Z (roll) axis of a rotation vector (well, a rotational velocity vector, really). When only one value is non-zero, then the two are equivalent. When the values are small, they are reasonable approximations of each other. But when the values are large, you will get odd behavior if you treat them as if they were truly yaw/pitch/roll.
JoeTheDestroyer,Nov 18, 2015
#23
- Informative x 1
NaosythTrainee Engineer
- Messages:
- 9
Yeah, I initially had a PID controller, but it wasn't working well, and proportional control just worked way better.I didn't consider the sim speed issue, definitely a good point.Ah, I was trying to figure that out, but didn't have much success. I'll take another look. Thanks!
Also, for the gyros, right now it only uses one gyro, which I knew the orientation of. I'm planning on making it work with all of the ship's gyros at some point, so I'll make it use the appropriate axis when I do so.
Edit: Got it working with all gyros now, and changing dt to just be 1000/60 made it much less jittery at low speeds. Overall it's working great, thanks for the feedback and advice
Last edited: Nov 18, 2015
Naosyth,Nov 18, 2015
#24
PsicoPatoSenior Engineer
- Messages:
- 1,097
You think this works with spawnships? I am planing to put this on my mod so my spawnships just orientate by themselfs right after spawning.
Another question. Do i need to set a loop on the Timer block to run the scrip time to time, or running it one time is enough?
PsicoPato,Nov 18, 2015
#25
JoeTheDestroyerJunior Engineer
- Messages:
- 573
So, yes. To expand, you need:
- 1 or more gyroscopes
- A remote control oriented so it's "down" face is pointed towards where you want the planet to be
- A programmable block w/ the script in it
- A timer set to:
- Run the programmable block (the argument doesn't matter, leave it blank)
- Do "TriggerNow" on the timer itself (setting up a loop)
Also, in this case I would recommend using the "LIMIT_GYROS" option (see the comment in the source) so that the player can still steer their ship, to some extent.
JoeTheDestroyer,Nov 18, 2015
#26
- Informative x 1
sepen_Trainee Engineer
- Messages:
- 52
Thanks a lot for this hint! I praise your source code digging dedication! Hah! PID is its very own can of worms, it really is.
sepen_,Nov 19, 2015
#27
- Like x 2
LynnuxJunior Engineer
- Messages:
- 881
Sorry, seeing this late.
Made a script some time ago (before planets): Avionics - Catlanding
In my Zecke vehicle I've added the usage of the gravity vector. Then the ship can be steered left/rigth and forward/backward while keeping the attitude. I'll update the script soon but first I want to know if I also have to add a speed limiter toggling the inertia dampeners and keeping the ship falling at a certain speed.Lynnux,Nov 20, 2015
#28
SibzApprentice Engineer
- Messages:
- 361
Could you explain what this is doing?
I think it changes the normalised vector into one that's relative to the current block. I.e. getting the green vector:
Did I understand this right?Sibz,Nov 22, 2015
#29
- Like x 1
- Informative x 1
JoeTheDestroyerJunior Engineer
- Messages:
- 573
Yep, that's it precisely. (Although your drawing says local grid, current block is actually the correct one.)
JoeTheDestroyer,Nov 22, 2015
#30
- Like x 2
Aligning ship to planet gravity (2024)
Table of Contents
NanobyteTrainee Engineer
plaYer2kMaster Engineer
NanobyteTrainee Engineer
plaYer2kMaster Engineer
NanobyteTrainee Engineer
HarrekinMaster Engineer
plaYer2kMaster Engineer
NanobyteTrainee Engineer
HarrekinMaster Engineer
plaYer2kMaster Engineer
NaosythTrainee Engineer
AutoMcDSenior Engineer
NanobyteTrainee Engineer
JoeTheDestroyerJunior Engineer
NanobyteTrainee Engineer
NanobyteTrainee Engineer
NanobyteTrainee Engineer
AutoMcDSenior Engineer
JoeTheDestroyerJunior Engineer
AutoMcDSenior Engineer
JoeTheDestroyerJunior Engineer
NaosythTrainee Engineer
JoeTheDestroyerJunior Engineer
NaosythTrainee Engineer
PsicoPatoSenior Engineer
JoeTheDestroyerJunior Engineer
sepen_Trainee Engineer
LynnuxJunior Engineer
SibzApprentice Engineer
JoeTheDestroyerJunior Engineer
Top Articles
Suppliers of golden paper daisy subundulatum | Exporters of golden paper daisy subundulatum | Sellers of golden paper daisy subundulatum
Model Military International - Issue 099 (July 2014) - PDF Free Download
Fernald Gun And Knife Show
St Thomas Usvi Craigslist
Golden Abyss - Chapter 5 - Lunar_Angel
My E Chart Elliot
Tryst Utah
Wordscapes Level 6030
Windcrest Little League Baseball
Ixl Elmoreco.com
Mychart Mercy Lutherville
Jonathon Kinchen Net Worth
Routing Number 041203824
Evita Role Wsj Crossword Clue
A.e.a.o.n.m.s
Chicken Coop Havelock Nc
OpenXR support for IL-2 and DCS for Windows Mixed Reality VR headsets
Cvs Appointment For Booster Shot
Foodland Weekly Ad Waxahachie Tx
Houses and Apartments For Rent in Maastricht
R Personalfinance
Best Nail Salons Open Near Me
Free Personals Like Craigslist Nh
Evil Dead Rise Showtimes Near Pelican Cinemas
Walmart Pharmacy Near Me Open
Lbrands Login Aces
Town South Swim Club
Ezstub Cross Country
Trust/Family Bank Contingency Plan
Armor Crushing Weapon Crossword Clue
Wisconsin Volleyball Team Leaked Uncovered
Springfield.craigslist
Morlan Chevrolet Sikeston
The Pretty Kitty Tanglewood
Chattanooga Booking Report
Tas Restaurant Fall River Ma
Colorado Parks And Wildlife Reissue List
WorldAccount | Data Protection
888-822-3743
Rush Copley Swim Lessons
Coffee County Tag Office Douglas Ga
Craigslist/Nashville
BCLJ July 19 2019 HTML Shawn Day Andrea Day Butler Pa Divorce
Skyward Cahokia
Gabrielle Abbate Obituary
Meet Robert Oppenheimer, the destroyer of worlds
Plumfund Reviews
CPM Homework Help
Superecchll
Amourdelavie
Epower Raley's
Used Curio Cabinets For Sale Near Me
Latest Posts
Article information
Author: Nicola Considine CPA
Last Updated:
Views: 6177
Rating: 4.9 / 5 (69 voted)
Reviews: 92% of readers found this page helpful
Author information
Name: Nicola Considine CPA
Birthday: 1993-02-26
Address: 3809 Clinton Inlet, East Aleisha, UT 46318-2392
Phone: +2681424145499
Job: Government Technician
Hobby: Calligraphy, Lego building, Worldbuilding, Shooting, Bird watching, Shopping, Cooking
Introduction: My name is Nicola Considine CPA, I am a determined, witty, powerful, brainy, open, smiling, proud person who loves writing and wants to share my knowledge and understanding with you.