This object is in archive! 

[Custom Turret Block] AI shaking turrets

UfoL BeerSeeker shared this bug 2 years ago
Won't Fix

Custom Turrets AI apparently struggles with aiming if turret's centre of mass is away from axis of rotation.

Once close to the target it does not stop and lock on target but oscilates fast between min/max velocity of rotor resulting in shaking and being unable to hit anything.

This is not clang, as issue only appears when turret ai is enabled, and manual control is fine.

Reducing speed of turret rotation close to zero reduced amplitude of shaking but it was still there. But it's not a good remedy as turret with very slow rotation can't track anything but very distant targets, but then even minimal shake makes it miss every time.


To remedy this, when turret is close to point straight at target it should gradually reduce RPM the closer it is to prevent infinite loop of overshooting and overcorrecting.


Turrets in example videos use default settings as the blocks were placed. No changes in block settings were able to get rid of the issue, unless grid was built to be perfectly balanced.

Below are links to example videos:

https://streamable.com/yoeou0

https://streamable.com/16rpxt

Replies (3)

photo
1

Hello, UfoL!

Sorry to hear you're experiencing this issue. I appreciate the videos provided. I have tried to reproduce a similar setup to what I can see in your video but I'm not getting the shaking results you have. Could you please provide a save file with this in it so I can experience it for myself and see what settings/setup you have?

Please share reliable reproduction steps too :)

  • You can access your save files by typing %appdata% into your Windows search bar and you will be redirected to the hidden Roaming folder. After that just follow: \Roaming\SpaceEngineers\Saves. There should be a folder with your SteamID and your saves.
  • Please zip the file and attach it here. If you are having difficulty attaching files you can optionally use Google Drive. When sharing a google drive link please make sure it is set to be downloadable by anyone with the link.

Kind Regards

Laura, QA Departement

photo
1

Hi Laura,


I'm getting the same issue. I'm using this turret (attached, zipped). With default settings, the wobble is severe and really messes up the aiming capabilities of the turret.


Steps for reproducing wobble:


Have the turret on a space ship in space (zero G)

Ensure AI aiming is turned on for the turret

Create a GPS coordinate somewhere near the ship in view of the turret

Spawn in a second small ship. Set up a remote control with the GPS coord in the auto-pilot, and a button panel (anyon can use) to turn on the small ship's autopilot.

Transfer all blocks on small ship to SPRT and press the button to send the small ship to the waypoint. Ensure that you've spawned the small ship in an area where the turret can auto-target and fire at it with its AI turret range of 600 meters.

Observe the turret as the small ship flies by (I recommend using spectator mode). It will wobble and never settle on the actual target. The wobble may be so severe that it will affect the turret's elevation as well


I've managed to mess with the settings on the turret just a little and by turning down the default settings on the rotor block, those settings being Torque of 500 kNm and a breaking torque of 1.2 MNm, it mitigates the wobble a little but not completely.


I think this problem could be fixed if the dev could implement a slowing feature for the turret as it nears the estimated correct path of the target.


If using the blueprint does not work to reproduce the issue, let me know and I'll send you the world that I'm using the turret in.

photo
1

Here you go, a savefile plus a short vid with reproduction process.

https://streamable.com/on9pie


Steps to reproduce:

1: Set up a powered grid with turrect control block.

2: Place rotor

3: Place hinge on top of the rotor

4: Place gun on the hinge

5: Place any powered block on separate grid and change ownership to enemy faction

6: Assign rotor as azimuth and hinge as elevation in turret control block

7: Assign gun

8: Turn on the AI targeting


Issue exists both in gravity and in 0G. everything was placed with default values. Reducing rotation speeds only decreases how far the turret wobble, but not removing the wobble itself. Less weight lets turret shake faster, heavier turret wobble with less frequency but to larger extent.

photo
1

Hello, Abyzmi!

Thank you so much for the information and help. Would it please be possible to have a copy of your save file? The blueprint for me isn't shaking/wobbling as mentioned and I want to make sure I have your exact setup :)

Kind Regards

Laura, QA Department

photo
1

Here's the save file for the world I'm using.

It has a large PCU grid (very large......) in it with turrets already attached and the save is under a little bit of time-dilation. That may be contributing to the performance of these turrets.


Also, this save file has the modifications mentioned above for the advanced rotors that I've used as the azimuth rotor for anti-air.


In order to reproduce the issue:


Create a GPS coordinate somewhere near the ship in view of the turret

Spawn in a second small ship (recommend 2km+ distance). Set up a remote control with the GPS coord in the auto-pilot, and a button panel (anyone can use) to turn on the small ship's autopilot.

Transfer all blocks on small ship to SPRT and press the button to send the small ship to the waypoint. Ensure that you've spawned the small ship in an area where the turret can auto-target and fire at it with its AI turret range of 600 meters.

Observe the turret as the small ship flies by (I recommend using spectator mode). It will wobble and never settle on the actual target. The wobble may be so severe that it will affect the turret's elevation as well.


Since I've mitigated the wobble by adjusting the settings on the turrets, you may be able to increase the "wobbliness factor" by increasing the torque on the advanced rotors used for the anti-air. To do so, access the K terminal through a nearby gatling turret, and search "Rotor Anti-Air" which will bring up all of the rotors used for each of the anti-air turrets. Note that they may be hidden from the terminal. Adjust the torque for all of them at once.


I have a bevy of gatling turrets to work in concert with these custom anti-air turrets. I think the best course of action for testing this wobble bug is to turn off the gatling turrets to ensure that the target grid lasts long enough to observe the wobble on the turrets. The gats tend to melt targets.


NOTE also that I'm having a separate KLANG issue caused by attaching separate small grids to the main ship via connectors (I think). This issue causes the main ship to randomly accelerate sometimes. This issue is outside of the scope of this bug report, but if it happens, use the administrator mode to stop the grid while it's moving. The ship's natural deceleration takes a very long time if the speed applied to the grid is rather high. The main grid is quite heavy. The main grid is called Sovereign. Should be easy to find in the list of elements in the administrator menu.


Lastly, I'm using Whiplash's new TCES Custom Turret Control script in a programmable block, but I've confirmed that this does not affect the issue at all by simply turning off the programmable block and not allowing it to run while I was testing the wobble. You can leave it on or turn off the programmable. It will simply reset turrets to their default position after they're finished attacking. To turn it off, search "TCES" in the ship's K menu and you'll find the programmable (may be hidden).

photo
3

The problem is how the controls are coded for the turrets, it either moves Left/Right at a set speed. This shaking/oscillating behavior is a fairly common problem in control theory, it can usually be solved by using a PID controller that's tuned well. PID controllers are very easy to implement in code too, you just need to know that they exist and how they work :) If you ask the developers to look into PID controllers for the turrets they should be able to solve this issue in just a couple of hours of work :)

Though they also need to calculate the target angle, if the current targeting system isn't already calculating a target angle but rather just increases the angle in an attempt to get towards the target this will be more difficult to implement. Luckily that's also quite simple with some linear algebra :)

photo
1

Tuning appears to be the issue. Default settings appear to be weirdly off the mark.

Lowering of the gain (velocity multiplier) of the 2 axes (azimuth and elevation) seems to help. I'm using 0.2 for both axes at the moment. Additionally, using the "share inertia tensor" on the elevation device also seems to help (this assumes the elevation device is 2nd in the subgrid chain (i.e. the azimuth device is on the main grid and the elevation device is attached to the azimuth device). In this configuration, sharing the tensor on the azimuth device drastically affects ship steering in the same axis.

Angle deviation is (note tool tip description) also important. The default is overly large. I'm using 0.5 at the moment. As the turret aim oscillates (control of this type oscillates .. even though the oscillations are small looking at the gun) the ballistic flight endpoint (e.g. where projectile will end up) wavers back and forth across the target. When the angle of the gun is within this angle with the aim point the gun fires. Choosing this angle has a lot to do with projectile velocity. In particular any velocity lateral to the projectile's flight axis.


I'm still testing so I don't have all the answers, but it works OK and I can hit a target (using AI control) at 2000 meters when both target and gun are sitting still and when their relative velocities are the same (both target and gun moving in the same direct ~50m/s). I have not gotten the controller to work well enough yet to try at a greater velocity mismatch. It is still unclear to me if the gun/projectile simulation properly imparts the gun's velocity as a lateral velocity to the projectile.

Back to work ...

photo
1

So, built new target drone and put it on autopilot. At around 100 m/sec a 5 artillery gun turret under full AI control was able to hit target consistently. Tested angular mismatch by rotating gunship and tested velocity mismatch up to reaching angular stop and 5 to 10 m/sec velocity difference. The AI obviously has problems as the velocity mismatch increases. Part of the problem is the slow artillery projectile (300 to 400 m/sec).

A 5" naval gun projectile in a gravity field with sea level air density caused friction travels at 760 m/sec. With no air friction and no gravity a projectile should be faster than that.

The other problem may be the turret controller is trying to aim the gun at the target rather than calculating a ballistic intercept path. When the flight speed is 2 magnitudes faster than the gun/target velocity difference the gun can be aimed. When the velocity difference becomes larger, aiming will no longer work.

photo
1

Hello, Engineers!

It´s already quite long time from when this issue was originally posted as well as from the last comment.

Are you still experiencing it? Or was it fixed in the meantime.

Thanks in advance for confirming me current situation.

Kind Regards

Keen Software House: QA Department

photo
1

Hello, Engineers!

Because there is no new comment from you, and we are unable to reproduce the issue on our own, I will close this thread now as outdated.

If you or any other player will experience this issue again, please make a new thread and provide all needed info there.

Thank you for understanding.

Kind Regards

Keen Software House: QA Department

Replies have been locked on this page!