Rotation with limited turn rate in degrees

Started by
45 comments, last by the incredible smoker 5 years, 9 months ago

Yes, it's possible to find a closed-form formula for hitting a constant-velocity target with projectiles that fall due to gravity. I described the general way to approach this type of problem here.

In this particular case, it's easier to use a frame of reference that falls with gravity. Then the projectiles seem to travel at constant velocity and it's the target that is accelerating upwards. Write the parametric equation that tells you where the target is at time t, and find a time t such that the distance from the origin to the target at time t is t * projectile_speed. The resulting equation is a polynomial of degree 4 in t, which can be solved in closed-form. But a numeric solver would work just fine.

 

Advertisement
1 hour ago, Oberon_Command said:

I would say that automation control theory is more of an engineering topic than computer science

Of cource. But just a calculations wiithout relations to real word engineering is usual spheric horse. So locally main idea of any high-grade computer-related education locally - is to train engineers that able by wishes of engineers from other fields, that figured out into field- realted equations, research ways of implementation and implement a calculations related to any engineering field. Really most university branches related to CS here called "Applicative mathematics" and graduate after 5 years "Engineer-Programmers" into letheral translation.  Really first 2 years is high intensive  mathematical and coding traningth, other 3 years is studing of fields where computing is most contributed fields - accounting, networking, CADs , FA and so on, that impossible without knowledge of math studied on first 2 years. Also colledges here is not a high education grade, it is a middle technical education grade, and graduate a "technecian-programmers" that usaully works on something like support teams and generally not involved into software development. 

#define if(a) if((a) && rand()%100)

28 minutes ago, alvaro said:

Yes, it's possible to find a closed-form formula for hitting a constant-velocity target with projectiles that fall due to gravity. I described the general way to approach this type of problem here.

In this particular case, it's easier to use a frame of reference that falls with gravity. Then the projectiles seem to travel at constant velocity and it's the target that is accelerating upwards. Write the parametric equation that tells you where the target is at time t, and find a time t such that the distance from the origin to the target at time t is t * projectile_speed. The resulting equation is a polynomial of degree 4 in t, which can be solved in closed-form. But a numeric solver would work just fine.

Doh - oh yes. I once figured out already it is that simple, but i forgot it. Of course movement on gravity plane is simply linear! It's not the first time i've ignored this to overcomplicate things just to realize later how dump that is. Thanks!

 

48 minutes ago, JoeJ said:

but the code to control a turret towards a direction is useful in any case

For targets that have a constant velocity vector first part of his trajectory missile "searching" a interception point than moves lineary. So to extend it to turrets it require just to use 2 other consequtive points of projectile trajectory before short it to aim. Mst likely it moozle point and point with one step back from moozle point along moozle vector.  It can be easely extended to work under garvity conditions without respect of air drag. Without air drag horizontal projection of speed still constant, so we can just project a task to horizontal plane and it will still a enought accurate in case small difference of target and turret heights and short ranges, but decrease accuracy with height difference and range growth. Also it require to find trowing angle that can be found from solution of quadric equation from distance betwin turret and target, so usually done by precalculated ballistic tables. With respect to air drug precalculation of ballistic  tables so complexive, so Germainy and USA has use a first their computers only to its purposes, and after WWII USA and then Sovit shifted to guided projectiles. 

#define if(a) if((a) && rand()%100)

14 minutes ago, Fulcrum.013 said:

so Germainy and USA has use a first their computers only to its purposes, and after WWII USA and then Sovit shifted to guided projectiles. 

I guess today the standard is to have computer vision and satellite tracking to predict how a vehicle drives on a road. What a bunch of interesting control problems to solve, just to cause death and destruction. :)

But there is one thing about real world machinery that wonders me. It seems turrets rotate at constant angular velocity, is this right? I would assume the motors can produce constant max torque instead, so angular acceleration. For a game this would result in more interesting motion, more like muscle driven motion and less robotic. Personally i use this for most control problems and prefer it against PIDs, although it's harder to do. 

23 minutes ago, JoeJ said:

It seems turrets rotate at constant angular velocity, is this right?

Angular velocity is proportional to deviation. It what P regulation do. "P" mean proportionaly to deviation of  current and target signal. Of cource real motor have limits of max and min torques, so on high deviations angular velocity is max  constant and it have a accuracy limit that can be reached due to motor minimal torque limit.

 

32 minutes ago, JoeJ said:

Personally i use this for most control problems and prefer it against PIDs, although it's harder to do. 

Really PID comes from muscle simulation. Just most of robotics toys have a stepper motors that drive a constant torque. Hevy industrial machines usualy use a servo-motors that have a adjustuble torque so looks very similar to muscle movements.

 

#define if(a) if((a) && rand()%100)

54 minutes ago, Fulcrum.013 said:

Really PID comes from muscle simulation.

Maybe, but they always require manual tuning to work 'most of the time', while still being inefficient, or causing oscillations in other cases.

I think it's better to accurately predict the future and to calculate the right moment in time to switching between max / min forces. Although there are minor issues as well, like being unable to do the switch in an instant, or oszillating around the target due to discrete timesteps, etc. But in theory it's always possible to hit a target position and velocity with a minimum of time and energy. PIDs have no guarantees on that.

I came up with this myself when working on the walking ragdoll (PIDs did absolutely not work good enough). But of course others have invented this wheel long before me, unfortunately i do not know what term is usually used for it. But i assume we could save lots of power if we would not use PIDs for almost everything in the real world. 

It's worth pointing out that this is a video game. In the real world, we don't have the option of "cheating" to directly work with world state, we have to sense it somehow. But in a video game, the gameplay code has direct access to exactly where everything is and where it's going. It's all a pretty illusion drawn up to entertain the player. Most of the time, gameplay logic doesn't need complicated math or elaborate approximation methods to look good. A few vectors and a scale and some simple trigonometry will often go a long way.

11 minutes ago, JoeJ said:

But i assume we could save lots of power if we would not use PIDs for almost everything in the real world. 

Really motors can not get tired while muscles get tired on maximal torque very shortly. So usually human uses a maximum possible torques into critical situations only, while robots preconfigured to move as fast as possible to  have a maximum perfomance, so works like human with couple gallons of adrenaline injected. So to simulate a whide range of human movements modes it just require to adjust factors of PID regulators by other PID regulators that depends from importence. It really what adrenaline do. Brain have no other tools than PID

PIDs intended to move a system to target signal value and  for nothing else. PID regulator perfom a gradient-search into single-dimension space. So it deliver a shortest posible trajectory. Set of PID regulators perform a gradient-search on multi-dimension space. Of cource it may not work where shortest trajectory is not optimal or not give a solution. Targets have to be determined by other algos etc, that have break a trajectory to set of  consequtive targets that is optimal in case shortest possible trajectory is not optimal. For example into real missile guidance target signal comes from missile sensors. Into industrial robotics target positions calculated from lows of field. From example on rolling mills position of press calculated from matherial resistance theory. PIDs just drive press motor to reach required position.

19 minutes ago, Oberon_Command said:

But in a video game, the gameplay code has direct access to exactly where everything is and where it's going

It why into video games FA related algos works better and simplier than into real word - it have no complexities with mesuarment and limitations of motors in case its limitations not required to be simulated. For example Lock-On  has model a limitations of missile coordinator  (elements that turn to targed used sensor to measure angle) turn speed and missile stears turn speeds limits.

#define if(a) if((a) && rand()%100)

3 hours ago, Oberon_Command said:

A few vectors and a scale and some simple trigonometry will often go a long way.

And it say piple that so crazzy about perfomance so even prefer to sacrafice any flexibility for perfomance. Removing only single unnessesary trigonometic function calculation from most internal loop you can save more CPU time than any hardware optimization can.

 

3 hours ago, Oberon_Command said:

Most of the time, gameplay logic doesn't need complicated math or elaborate approximation methods to look good.

Really CAD and FA - related algos is very simple for implementation and high flexible becouse data driven by its nature. Much simplier then i seen into gamedev papers. It just involve a crazzy complexive math to find and prove  this simple solution.

#define if(a) if((a) && rand()%100)

This topic is closed to new replies.

Advertisement