# Combining turn and linear movement PIDs

Hello, I was wondering if in someway you could combine the two actions of turning and linear movement into a single action, without the use of Pure Pursuit or Odometry. Currently I have a PID for moving forward and backwards and one for turning.
Thanks for the help.

2 Likes

are you talking about moving in an arc or moving in a strsight line while turning? for the former, you should use motion profiling, and for the latter you need a holonomic drive base.

3 Likes

That is not strictly necessary, as you can drift. But I definitely agree that holonomic drive base is easier to control for that purpose and it gives you a realistic chance at having repeatable results in the autonomous.

@Micah_7157X, you can use two PID loops for driving straight and turned combined into one.

Take a look at these:

5 Likes

i will be very impressed if I ever see a team do precise controlled drift.

3 Likes

Read the odometry / autonomous part, it talked about how they combined move and turning pid to create point to point movement.

Note that by doing so, you can’t control the global end angle of the chassis, it will only drive to the point. If you want to drive to a target point with a specified angle, motion profiling or other trajectory following algorithms will be better.

5 Likes

I’m assuming the poster is asking about combining PIDs to get an arc with a tank drive.
If they are asking about turning while driving w/ holonomic drive, I can make a new post.

@DrewWHOOP Motion profiling is unnecessary, you don’t need motion profiling to arc.

@Micah_7157X

Yes, there are a few ways to do what you want (which I’m assuming is doing some sort of arc):

• simply add the outputs of a distance and angle PID
• you can control the arc length and final heading, but can’t really control final position (other than by tweaking)
• you have to be careful about managing motor saturation (one PID overpowering the other) to have a smooth arc
• simple but not ideal
• you can instead have a different approach where you basically do a turn PID, but instead of `tank(power, -power)` you can do something like `tank(power, power/3)`. This will cause the robot arc in a 3:1 ratio, and you can calculate that ratio from arc radius if you want

However, for anything more sophisticated, you do need one of the two:

• odometry: like I did in the post linked above, use angle PID to hone in on a point while using distance PID to drive to the point. Also you can do pure pursuit.
• motion profiling: can follow complex paths without needing sensors (odom).
10 Likes

moving in an arc path

no, you do not, but you might find yourself having issues with it being less than perfect at always ending up in the same spot.

2 Likes

Sorry for reviving, but could you explain this in more detail? Thanks

This thread is old lol, anyways you should be able to run an angle PID ( one that moves to a certain angle ) and a drive PID at the same time using tasks, then halfing the inputs from both might work I’m not completely sure.

You can think about it like arcade drive; you would typically combine forward and sideways power to be able to turn. Using the same idea, you could find power values for left and right side (I’m assuming you would considering you’re using a turn PID as well) and combine forward drive power to create an arc drive motion)

Something like this:

``````int drivePID(){
// something something math
LateralPIDPower = //calculation
}

int turnPID(){
// more something something math
TurnPIDPower = //another calculation
}

LeftDrivePower = LateralPIDPower - TurnPIDPower;
RightDrivePower = LateralPIDPower + TurnPIDPower;
``````

The signage might be off but that’s the basic idea of it.

1 Like

something that works for us is using a drive pid and telling it to drive at an angle.

Basically, if the robot is at heading 0, and we tell the robot to drive forwards keeping it at 90 degrees. the pid will turn the robot while driving forwards, until the robot is driving at 90 degrees.
The end result is a parabola in which the robot drives forward and turns while it does that.

Let me know if im not clear

1 Like