Calculate the amount of torque impulse needed to get to a certain orientation.

Started by
10 comments, last by alvaro 5 years, 6 months ago

I’m programming some steering behaviors in 3D and am a little lost on figuring out how to figure out the necessarily torque impulse necessary to match a target orientation.

Ive been looking at some boids steering code and it seems like often the orientation is dependent on velocity. I’m trying to implement a space simulation so I want to do steering based on rotational thrust.

I’ve tried finding the difference between the two orientations (q2 * q1.inverse()) and then converting that to ruler angles. However I’m not sure that’s completely the same thing. Doing this also leads to some spinning out of control so I haven’t figured out how to try to go to the nearest target and then be able to stop.

Advertisement

Do you want to apply just 1 impulse in 1 frame and then let it rotate until it converges at the desired orientation based on the angular momentum? Over how long time? Infinite? Finite? Is there angular drag? (in space? :D)

Wouldn't it be slightly better to rotate every frame by applying a smaller impulse of a constant size (maximum rotation thrusters thrust) until you're close enough and if you overshoot a little, it'll automatically rotate back?

Sounds like a job for a PID controller, but I haven't done this so I'm awaiting for someone to link something useful :)

Yes, ideally, I would both use angular forces to accelerate and then decelerate. However I feel like figuring out the total angular impulse would be the first step, then I could try and use that to figure out how to accelerate and decelerate angularly to stop at the target orientation.

 

Thanks for the keywords. I've since found these, which look promising. I'll try to read up on them in the morning.

https://engineering.stackexchange.com/questions/13960/using-a-pid-to-control-rotation

https://www.researchgate.net/publication/322015472_FPGA_based_angular_stabilization_of_a_quadcopter

Figuring out the angular impulse to reach some target orientation is the angular equivalent of figuring out the linear impulse to reach some target position. It basically makes no sense. You have to decide how quickly you want to get there, as pcmaster pointed out.

 

I didn't expect to, but I managed to do this, albeit only in 2D (box2D in libGDX; shouldn't be a problem to translate into 3D), without a PID controller, just with some boid tutorial. There's some wiggling at the end, but I haven't been able to program a PID controller without it either, quite frankly.

Anyway, in the boid tutorial it's just a variation on linear arrival, and I found it pretty straightforward and effective.

21 hours ago, Axiverse said:

Ive been looking at some boids steering code and it seems like often the orientation is dependent on velocity.

Really angular velocity is integration of applied torque impulses. So to get a required orientation it required to apply at least 2 consequtive impulses - one to start rotation and other to stop it. On most use-cases it require a proportinal navigation , so PID regulation is  better (intendent for its kind of tasks)and simpliest way to implement it.

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

22 hours ago, Axiverse said:

Doing this also leads to some spinning out of control so I haven’t figured out how to try to go to the nearest target and then be able to stop

Find a normalized vector from your object to target. Find projection of its vector to coordinate planes of object's local coordinate system. Now calculate angles betwin of its projections and forward axe .  Use a PIDs to turn on orientation trust proportionally to its angles (or ever proportionally to just a projections of target dir vector to other local axes for simplified but much faster approach). It will follow a target point ever in case target point is moving. Say more if you will use a differences of angles calculated on 2 consequtive steps as input of PIDs it will follow a interseption point for moving targets.

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

I've been looking more into PIDs, however I'm not sure where to start learning how PIDs are combined in automation. For example, we have both the turning mechanism as well as the acceleration - both affecting how we arrive at our goal but independent on each other. I can implement some logic which attenuates the acceleration by the difference between the heading and the target angle, but I wouldn't know how to extrapolate this if more actuators were involved.

I'm sure this is an existing problem, however I don't know what the field is called or what to look for.

6 hours ago, Axiverse said:

For example, we have both the turning mechanism as well as the acceleration - both affecting how we arrive at our goal but independent on each other.

Real-world autopilots use separate channel for each axe.    Each PID converts input  volume (that usually is a input from sensors) to output volume (that is a power delivered by drives)  only. If we drive a some feedback (that usually sensors do) to PID input it able to keep/follow target value of sensed signal with some dT kown as regulation delay. Linked to chains it able to keep a orientation using angular speed as intermediate (PID regulated by chained regulator) value for example.  But it works separately for each deegry of freedom and able to drive system from current state to target state only. So if you need sequence of moves you have to set a sequence of targets to channels that can be followed sequentaly or simulateousely. For example you can setup required to acceleration impulse orientation to orientation channels, await until it reach required orientation, then setup a target velocity vector to main thrust channel, avait while it reach it velocity, and then setup other orientation (for example that match velocity direction). It what you logic have to do - to setup targets for regulators, wich drive system from current state to target state by shortest possible way. Really PIDs level of system  work like a cerebellum, while higher level logic works as brain that set sequential goals to cerebellum

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

4 hours ago, Axiverse said:

however I don't know what the field is called or what to look for

Dont sure how it exactly called by English, but litherally translated from Russian it sounds like "theory of automative control".

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

This topic is closed to new replies.

Advertisement