Space Engineers

Space Engineers

SAM's Autopilot Manager v2TC
96 Comments
TechCoder  [author] 4 Jun @ 4:39am 
... and have enough STOP thrust so you won't blame SAM when it crashes! :)

While true that YOU "can fly...." in a lot of 'wild' ways (come in upside down or sideways, etc.), SAM is an AUTOPILOT script, which is designed to "bring the ship in SAFELY, along the most DIRECT route while avoiding collisions using the least fuel possible".

You must engineer the ship for an AUTOPILOT (i.e., plenty of thrust all around, etc.) - just as IRL, 'Top Gun' planes and cargo carriers are not built the same!
r4v1n6 3 Jun @ 9:40pm 
SAM is very good at flying lean, way better than the RC or the AI blocks (for those turning off engines can be sensible). With mixed engine setups it will generally use the strongest, most efficient engine(s) for that part of the flight in order to maintain desired speed. It starts with just one engine and then piles on, adding additional engines as needed to get the desired thrust. By comparison the RC and AI blast with everything (and then realise it was too much so it uses the opposite engines to compensate but use them too much too).

With the exact same drone I was able to circumnavigate Orlunda (diam 60km I think) without refueling when using SAM. With the RC it got about a quarter before it ran out of fuel.

So don't worry. If you think SAM uses the engines too much when deorbiting, increase max speed from 95 (default) to 104 (if using vanilla world settings).
aaron 3 Jun @ 8:57pm 
the thing about saving fuel is my ship has both hydrogen and atmo thrusters and can fly just fine with the hydrogen turned off in atmo.
so when i am heading back from space i just turn off the hydrogen, glide down until the amto thrusters start working.
TechCoder  [author] 3 Jun @ 7:37pm 
aaron - as r4v1n6 said, you need to be 'observant' of routes and clearances. One of the MOST IMPORTANT, yet, sadly overlooked things in setup is in the SAM documentation that Magistrator did - there's a bunch of scrolling pictures and one with a 'circle' around it with CLEARANCES labeled (sorry, this is Steam and I can't link it or post the pic - - - get on my Discord if you can't find it and we can chat this through with pics and videos.... :)

If your ship is crashing, check the "BASICS" - cameras with clear vision are critical (and often overlooked/missed) and make sure you have enough POWER - and that means in ALL directions (often left/right is 'wimpy' and that can cause autopilot issues - #ItAin'tJustUP! )

Turning off engines does NOT save fuel - the actual script and use of fuel is maximized in SAM to make sure it uses the minimum to maintain current flight path using all engines available
aaron 3 Jun @ 6:50pm 
one other thing i noticed is the other script turned off the engines when dropping from orbit, which saves fuel.
is there a way to do that with this one? it seems to turn all engines on even if i manually turn them off?
r4v1n6 3 Jun @ 6:36pm 
There are a number of parameters that can be tweaked through Custom Data (or editing the script). Not sure altitude is one of them for this version of the script though. As I recall the vMod version was generally better at long range atmospheric flight than this version (at least for drones), but lacked several features that this version have.

You need to set up sensible routes for automated ships that avoid hazards as much as possible and maybe lay out paths (LCDs tagged with connector name) to help them approach safely. Or ride along and take over if/when something happens.

When going to the other side of the planet, you may want to first go into orbit visiting orbitals along the way to your final destination. Safer than hugging the ground, though less exiting if you're riding along.
aaron 3 Jun @ 5:50pm 
i just upgraded this script from the original one that is no longer maintained.. so far its working good but i have a few issues..

is there any way to tell it a min flight altitude? my base is in the mountains and its in a valley, every once in awhile if i come in there will be a mountain in the way and it just grazes the ground and sometimes hits a tree.. it would be nice if i can make it so it stays 100m or so off the ground at all times?

also my base has wind turbines. sometimes when i come in at a certain angle, it just goes right through them like they arent there. not sure what i can do about that?
debstar 30 May @ 3:36am 
@Our Bowl and Saviour.
I m using Aerodynamics Mod and DIGI wing blocks;
SAM still needs enough thrusters to handle each direction.
Of course, the ship will use less energy in navigating mode with enough forward thrust thanks to the advantages of aerodynamic's physics.
TechCoder  [author] 13 May @ 6:08am 
I don't use such mods, so I would say TRY IT and if it doesn't work as expected, get on my Discord and we can open a thread about it - not saying anything will change, but you are the 'expert' on what you are looking for, not me!
Our Bowl and Saviour. 13 May @ 5:40am 
does this support atmospheric physics/ wing mods?
TechCoder  [author] 10 May @ 10:09am 
NEW VERSION SAMv2TC1.14 now ONLINE - be sure to upgrade ALL your ships - and be sure to get debstar's SAM HELPER script - https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=3419699144 - it really extends the power of SAM!
debstar 1 May @ 10:29am 
@Empada
I do have a similar feature , i ve implemented in on of my script.
it will run SAM and cycle to all the GPS Or Docks ( i do not know if programable block arguments do support more than 50 GPS XD)
--> AddWaypoints GPS1 GPS2 GPS3 GPS4 DOCK1 DOCK2

You can use Remote Commands too

Please join to SAM TC discord to discuss about your feature maybe we do have something that suits your needs
TechCoder  [author] 29 Apr @ 3:24pm 
50 points.....one command......

Well, there are RC Remote commands that you can do, but, sadly, they are limited by the text field in the LCD and so you only get about 20 at once.

Oh, no, that's 20 SHIPS that you can do at a time (so only a mini-armada....) - you are wanting to enter a bunch of GPS points for one ship.... hmmm - not sure that would be possible directly, though a small script to read an LCD panel's text (where you'd put all the commands) one at a time is not too hard to make (rather a one-off, but could be done...)

We have a decently active group of folks on the Discord and perhaps one has done something like this (a couple guys do all sorts of 'fancy' stuff) - I highly recommend you join there and ask around.
Empada 29 Apr @ 11:23am 
is it possible to add 50 or more GPS waypoints with just one command or I do have to put one by one?
it is for scouting purposes, so I will have to enter lots of points every time
Snowz 20 Jan @ 6:48pm 
Yo, thanks so much for updating/maintaining this. SAM is great and now so are you :)
r4v1n6 2 Jan @ 1:30pm 
I have been poking around in the code and comparing it with other versions of it (vMod and v2.6.7 found on github) and I may have found a solution. In v2TC1.13, on line 247 there are some constant's used in the MaxThrust calculations. The first one (-110.1f) appears to be the speed limit for the world so it should be ok if it hasn't been changed. The second one (203.3f) however seems to be used for MaxThrust.
I experimentally moved the decimal point to the right one step (2033.0f) making it 10x stronger and tested in-game. The ship is now able to move and dock just fine (with or without cargo)! :D

Having only tested with one kind of ship, I don't know if this solution is valid for other ships, but it's a start.
r4v1n6 2 Jan @ 1:29pm 
Hey, thanks for the updated script. I have tested it in space with a zg bulk freighter that I built recently. Without cargo, it's now able to dock with perfect aim and alignment, and doesn't hit the dock too hard.

With cargo things are quite different. When loaded with about 7kt with ore (ship's dry weight is about 500t), the ship is not able to move at all. It can point itself in the right direction but hardly even try to use the thrusters (applied overrides are minimal). When flying manually (or using SAM vMod or Spug's AutoDock) it works fine so there should be enough thrust, although the ship is designed to be more realistic than average so it's highly asymmetrical (and probably part of the issue).
Jack Schitt 30 Dec, 2024 @ 10:29am 
There's 4 remotes in the world, total. One per ship. None were tagged when I put the log screen up so that's probably why it did that.

So we have to _either_ put the tags in the CD or in the block name? It can't be mixed; some in the block name others in the CD?

I'm not on Discord and won't be.
I followed the instruction I wrote in the discussions here on the workshop page. I wrote those the only single time I've ever gotten this script working. Setup for this script is complicated.
TechCoder  [author] 30 Dec, 2024 @ 9:48am 
that message _will_ come up if you have ZERO remotes tagged (it is a bug introduced in V1.13 - fixed in V1.14 which will come out 'soon') - I'd check that tag if you are seeing it in a ship (stations will continue to show that until V1.14....)

You can have only ONE RC on a ship - if you have 4 (or 400 or 40000) in a world, SAM doesn't care, but it can ONLY have ONE in the ship (all autopilot scripts have that requirement, I believe - otherwise, just who is controlling things?)

Your post shows sort of 'mixed' tagging (some with SAM. others without) - make sure the tags are per the instructions (I use the CD as there can be a lot of them - see my PINNED message in Discord for my defaults I put in every ship)

SAM doesn't fly backwards, so no reason to tag a camera in that direction (dunno what might happen there.....) - see instructions
Jack Schitt 30 Dec, 2024 @ 9:31am 
Rechecked and triple checked. Everything I know of that has to be tagged is tagged:
- SAM ADVERTISE the station's pb
- Connectors at station wanted to be used (I'm only using one at 2 different stations)
- The antenna on the station (SAM. in custom data)
On the ship:
- The connector used
- The antenna
- The remote control.
- All cameras, I have 4 (on in each direction. They're all SAM. tagged in custom data)
- The LCD

The strange thing is I put a log screen at the station and before I set my ship up the log screen was filling with "E: Too many remote controls". There's a total of 4 remotes in the world and only one single remote is tagged with SAM. (on the one single ship I set up). Is 4 too many?
Jack Schitt 30 Dec, 2024 @ 8:13am 
I'll recheck everything. Maybe I missed tagging something.
TechCoder  [author] 30 Dec, 2024 @ 4:11am 
Not completing a route always comes back to the same thing - BASICS (as SAM is really just that - setting up the parts of the ship to allow the autopilot to know what it can use to fly.

If it can't "see" (cameras) or it doesn't know where/how to connect (connector{s}), it may start, but can't finish.

99.9% of the time - engineer error in setting things up.....
If it was running, it is 99.9% that after a crash/repair you didn't tag it again.

All just BASICS of tagging.

My YT video (see description) has details - and there's loads of discussion on this topic on the Discord channel.
Jack Schitt 29 Dec, 2024 @ 7:27pm 
What would cause this to stop half way to the dock it's told to go to? I have 2 docks barely 1000m apart and the ship goes 500m and stops.
r4v1n6 29 Nov, 2024 @ 6:14pm 
Ok, changing (line 204) ...PhysicalMass -> TotalMass pretty much fixed the oscillations when orienting. SAM still can't actually move the ship, the thrust calculations may not actually take mass into account?

When testing with Spug's AutoDock, it could dock the ship just fine although it also used PhysicalMass instead of TotalMass in it's calculations. Still it didn't dock too hard this time... it's blind though.
r4v1n6 29 Nov, 2024 @ 3:01pm 
The latest update(s) may have broken setup through Custom Data for some blocks. It seems what I put into there for Connectors and Bridge Helms (and maybe some other blocks) is ignored. I have to use the block name instead.

There also might be an issue with how it calculate the ship's mass. My most recent ship (bulk cargo), when I load it up with full cargo containers (attached with mag plates) it won't move but can orient itself with gyro's (sluggishly and with a lot of oscillations). The applied thrust overrides seems way too small for the ship mass. I have to help with manual throttle through remote or helm.

Also, as I recall from experiments I did a long time ago, thrusters and gyros are much stronger when operated with a ship controller compared to overrides (factor 10 or something like that).

Otherwise this script is still great if you avoid crazy ship designs.
Frogmaster 25 Nov, 2024 @ 5:55am 
I'm sorry but I had to gave up after 8 hrs of fiddling and hunting for, clear, Concise step by step, and UP TO DATE Written directions WITHOUT a pile of superfluous yada yada. If the user can get something running in bare bones minimum the user can expand from their. Remember just K.I.S.S. it. "Keep It Simple and Stupid" :steamhappy:
Delf 13 Nov, 2024 @ 6:25am 
Thank you, I will study this information) At the moment I am experimenting with APck by the author cheerkin
TechCoder  [author] 8 Nov, 2024 @ 9:12am 
Delf - another user on my Discord (yes, that is the BEST way to get all sorts of info!) asked a similar question and when I checked the 'pinned' messages, sure enough, there was an answer that might also help you - https://www.youtube.com/watch?v=3mwD4BpS8UU (another great way to get tons of info that just CAN'T be put on Steam!)
TechCoder  [author] 7 Nov, 2024 @ 3:27am 
If you are just going to/from given points, you might also try PAM (Path Auto Miner) - certainly a 'go to' as much as SAM for the right jobs. It is a simple waypoint recorder and replays them, so if you turn it on and then fly, it will go that same path next time. No obstacle avoidance or anything, but it does great for what it does.

Dream on about SAM 'remembering' anything - that is part of the magic of SAM - that it LISTENS for the location! That way, you CAN even move the base and SAM will find it (some restrictions apply - full discussion on Discord!)
Delf 7 Nov, 2024 @ 1:46am 
Thanks for the quick response. You've given me something to think about!
I will test the combination "Safe flight to the GPS point (Start GPS) -> getting into the antenna area (small radius) - > docking with the base."
(Dreams - if only SAM would just remember the location of the connector and the vector of approach to it in order to carry out autonomous navigation)
TechCoder  [author] 6 Nov, 2024 @ 6:57am 
Delf - wow, what you are asking certainly is NOT typical SAM as it breaks many simple rules of how SAM works!

As for "push a button, go 'HOME'", see my script "Call Shuttle" https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2893374486
though it does require two working sides of the SAM connection.

Otherwise, you _could_ make a SAM command
START (GPS Coordinate)
see Magistrator's docs at https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1947156145
which will send your SAM ship flying (and doing what it can for avoiding stuff)

That won't, of course, do any docking (as you aren't telling it anything about WHERE to dock), but you could pick a GPS that is "close" to the connector.

Be clear - you asked if "it will return itself to the connector" - though unless something tells the ship where that connector is in space (which is what SAM.ADVERTISE does on the main base) there is nothing SAM can do.

But, START (GPS Coordinate) will at least get you close.....
Delf 6 Nov, 2024 @ 6:46am 
Hi TechCoder. Is it possible to execute the scenario "Press the button "Go HomeBase", after which it will return itself to the connector My Homebase from any distance, avoiding crashing into the base and asteroids along the way? Limitations - one program block on the ship. No program blocks on the base. No antennas (pvp server)
I used Spug easyautodocking, but it does stupid things, crashes into asteroids and the base.
Nemezir 4 Nov, 2024 @ 6:17pm 
Hi TechCoder,

Thank you so much for continuing to maintain that script—I really appreciate the time and effort you put into it!

Kind regards
jhughes 1 Nov, 2024 @ 10:16pm 
You can't demand people help you in the way you want.
jhughes 1 Nov, 2024 @ 10:15pm 
We get it Jack .. you don't like discord. OK, then don't get the help. Modders owe you NOTHING. If you choose not to use their perferred method of communitcation, then you are on your own.
Jack Schitt 15 Oct, 2024 @ 11:36am 
I don't agree. Discord is a clutter mess on the screen. Sure, this and that "thousands and thousands" you even said and agree of messages and stuff to look through pins and channels and subchannels and subchannels of subchannels. That's not organized or easier. LOL

CTRL+F, search and find. Without having to login to a place that sells user data like cheap prostitutes....which Steam does not do.
TechCoder  [author] 15 Oct, 2024 @ 9:12am 
not really....... https://somup.com/cZ6oDlHv15
Jack Schitt 15 Oct, 2024 @ 8:58am 
Tip: CTRL+F searches any and every browser including Steam. A person would have to do the same thing on Discord.
TechCoder  [author] 15 Oct, 2024 @ 8:05am 
I really don't like posting anything here and I HIGHLY encourage anybody that wants to learn/use SAM in interesting ways to get on my Discord!

That being said, I will post this ONCE - I'm not in a position to constantly search/copy/paste things I have already posted (I do have a day job and IRL responsibilities, y'know...)

here is the SAM PB CD that I typically use (at least as a start...)

SAM.
SAM.LOOP
SAM.NODAMPENERS
SAM.ApproachDistance=1500
SAM.ApproachingSpeed=30
SAM.DockDistance=5
SAM.MaxSpeed=100
SAM.ConvergingSpeed=30
SAM.TaxiingDistance=20


You need to do with it as you need for your situation/ship/etc.
TechCoder  [author] 15 Oct, 2024 @ 8:05am 
pretty sure I posted this in Steam before - but it is near impossible to search (which is, as I have said many times, why I USE DISCORD FOR POSTING A LOT OF INFO). There's about a dozen 'pinned' (i.e., important to check first) messages in the samv2-tc channel and hundreds of 'interesting' posts/discussions plus about 2 dozen other channels for tons more discussions.

Steam doesn't provide anything like that and is soooooo limited (in fact, so limited I couldn't post this in one message - - - AAAARRGGGHHHH!)...
Jack Schitt 15 Oct, 2024 @ 6:35am 
Would you please post your standard thing here? In the description or the discussions.
TechCoder  [author] 15 Oct, 2024 @ 6:24am 
yeah, it is a bit to set up and get used to, but once set (which is why I have that 'standard' list - I find it works for my gameplay on the vast majority of builds) it is worth the effort.

seems a bit counterintuitive that 'autopilot' needs so much, but just consider how much IRL 'autopilot' (self driving vehicles, etc.) needs setting up and you'll be happy to set these 5-10 things....
Jack Schitt 15 Oct, 2024 @ 6:20am 
Thanks! There's so many options to this thing...lol
TechCoder  [author] 15 Oct, 2024 @ 5:58am 
configs for SAM are done either in the names or in the Custom Data (my personal favorite way - again, on my Discord are the settings I use when I start a ship, then I tweak them to a particular use if/as needed) - all come from the original docs https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1947156145 under the Programmable Block header (and also use from instructions in the Tagging section)

If you have an approach set to 500 and you start less, just when can the 'magic' of collision detection kick in (and raycast is typically reliable at 2km or more thing - talk to Keen.... - it can/does work pretty well on shorter distances, but mostly SAM navigates within the approach/docking parameters by 'expecting' there to be nothing in the way {that part is sort of like PAM as it is somewhat 'path' guided})
Jack Schitt 14 Oct, 2024 @ 10:23am 
Do you mean the config screen or is there a config file somewhere? I don't think I've gone back to the config screen after selecting a dock to see if it changes, I will do that. I looked in the script and saw approach was 500...meters? It's a float value. I was testing the drone going from station dock to ship's dock so they were way under 500 meters from each other and the station was pretty much directly under the ship.
TechCoder  [author] 14 Oct, 2024 @ 9:43am 
yeah, PAM vs SAM = not possible to compare.... Path recorded is great for what it does, but move that mother ship and it is all over.. That's where SAM comes in, but it is far from do-all end all perfect (though it does a darn good job for most non-PAM things!)

Mothership use is fine (I have at least one video on that - actually using a rover that moves around, not a ship, but same thing...)

SAM will make its own path according to the 'rules' you set up in the config - docking, approaching, etc.

If you are trying to fly in a direction you don't have any cameras (or cameras marked SAM) or enough room to let SAM 'see', you WILL crash (again, basics of thinking "if I were flying this according to the rules I set up for this ship, what would happen") - gotta have enough clearance for SAM to 'see' and gotta have a camera in that direction.... - that's what I'd check.
Jack Schitt 14 Oct, 2024 @ 9:19am 
The docks it's having trouble with are on a 'mother ship'. I haven't seen anything that says it does work that way. Could that be the problem? Other things that follow a recorded path don't have any issues. This seems to make it's own direct path. When the ship the SAM drone is to land on is above the drone that's when there's an accident with injuries.
TechCoder  [author] 14 Oct, 2024 @ 6:55am 
See, it ain't really that hard to get it working..... :)
Colliding is caused by poor engineering design, well, rather AIRSPACE design and while SAM does its best for collision avoidance, there are still some rules - far too complex to put in a Steam post, but some basics:
1. Don't even think about using the same connector for multiple ships..... (probably your issue??)
2. Make sure there is sufficient clearance between connectors (see the last picture on the original SAM page- it shows a 'circle' - - - - that's important!
3. Check each ship's settings and make sure there is clearance for it to take off/land (in my Discord there is a pinned post of the settings I start off with)

Basically, just BASICS of making sure the autopilot can kick in and do its thing (it isn't 'magic' and {due to the tech allowed by Keen in raycast} works best when given distance to 'focus'.
Jack Schitt 14 Oct, 2024 @ 6:48am 
I FINALLY got this working!
But...my ships are colliding and destroying each other. Is there a way to prevent that?
NAUGHTY SANTA 20 Aug, 2024 @ 12:43pm 
@techcoder its only a hydro ship. it fills up at planet. ok.
but in space- it unloads both TANK[sam cargo] and the HY fuel Tank.
what i want is it to have 33% to return to planet for more hydrogen..

but it just idle away like an unbehaved kid, :-) in sam nav it just says "waiting". So when i release the fuel on the station, (stock pile off) it fills the tanks...also tank[sam cargo].