So I’m confused about one thing as I’m coding my turn PID -
Is turn PID only for stationary turns (move one side of chassis forward, other side backward and apply PID loop to slow it down till you reach the desired angle) or can you do a curved turn as well where your angle is changing and the position of your robot?
It will be paired with Odometry.
They have some sort of a curved turn as they are moving and fulfilling tasks, how do you code that to do it accurately? Is that turn PID? Or is that an odometry motion algorithm? Or is that something completely different lol
Also, can I PM someone my Odometry code + Motion algorithms that was done in PROS and can you check it and give feedback on how we can make it more accurate and worlds level ? Let me know and I’ll message it to you. We don’t have access to be able to physically test it out right now and we coded it for the first time, so if an experienced coder who has lots of experience with Odometry and it’s motion algorithms in tank drive check it, it would be appreciated
They used pure pursuit to make those paths. In my opinion you can construct an equally good programming skills from simple drives and turns as you can by using pure pursuit or arc motion. The resource above would help with pure pursuit.
PID can literally work with any sensor (as long as it can return a range of values, not just 0 or 1).
So think about it this way: with an arc turn, do both sides of the drivetrain travel the same distance? Is there anyway I could calculate these distances and use another sensor in a PID loop? Just some food for thought.
You can see if this flowchart helps. You can PID to use drive motors to turn to face a direction around your pivot point. I guess you could turn one side off if you want to translate while you rotate (Turning right while your right motors are off will move your bot forward and to the right, vs just turning around your center point).
In general if you want your robot to follow a path, you will need to create a virtual “carrot on a stick” and give your robot the ability to chase the carrot. The bot will chase the carrot along a path using pathfinding algos like pure pursuit, waypoints, spline, and bezier curves,
You will need to use Odometry for this. Your robot needs to know where it is, and where the target point is. Then you can calculate how far in front or behind, how far right or left (for x drives) and how great of an angle you need to turn. Then those numbers go into your PIDS.
Now how do you make your motors follow the “carrot”. Turn and drive pids. Left Motors = DrivePIDout + TurnPIDout. Right Motors = DrivePIDout - TurnPIDout.
Just knowing your current (x, y, theta) and your desired (x’, y’, possibly theta’), you can use lots of subtraction and tans/arctans to caluclate your target and desired turn values and drive values. Once you can do steps 1-6 as described in my previous post, you are ready to make the stick move along a curve.
For that you can use waypoints, where you change the desired value to the next waypoint once your robot reaches a threshold distance (unless you actually want to stop at the waypoint). This is disjointed and logic based, which is never the best way to do things. Just like with PIDS over bangbang/takebackhalfs, the best versions are the ones that are continuous and tuned.
So you make a function that outputs (x target, y target) by calculating the coordinates of a point along a parametric curve at time “t” where “t” is simply how close the robot is to the final point from where it started. Then you just chase the carrot that travels along this path. Having a strong integral term will help reduce difference between the carrot’s path, and your robot’s path.
All that being said, if you follow my flowchart, step 7 is the natural next step for you once you have good PIDs. This year especially, if you have a well tuned step 7, then that is as far as you really need to go for most autonomous tasks.