Need a Solution to Autonomous Inconsistencies

    I am a novice programmer and I've spent the last few minutes looking for fixes to my autonomous. I use basic commands like motor.startRotateFor and motor.rotateFor. However, there is just too much variability because of getting starting position down to a degree, robot not driving completely straight (probably one side of the chassis weighs more than the other), and goals not being in the exact the same spot each time. 
   I've looked into stuff like PID controllers and intertial sensors, but it all seems way out of my league. I'd like a system where my robot can automatically correct to be square with a mobile goal, but I have no idea where to even start coding that. I guess I am just asking for ideas from anyone. Thanks

Might be a little easier to read:

“I am a novice programmer and I’ve spent the last few minutes looking for fixes to my autonomous. I use basic commands like motor.startRotateFor and motor.rotateFor. However, there is just too much variability because of getting starting position down to a degree, robot not driving completely straight (probably one side of the chassis weighs more than the other), and goals not being in the exact the same spot each time.
I’ve looked into stuff like PID controllers and intertial sensors, but it all seems way out of my league. I’d like a system where my robot can automatically correct to be square with a mobile goal, but I have no idea where to even start coding that. I guess I am just asking for ideas from anyone. Thanks”

15 Likes

This is the more likely case. This is no quick fix perfect auton. Things like PID do help, but they require a basic understanding of c++ programming. In the short term, I recommend driving slowly and making sure that your wheels don’t slip or get air time. In the long term, try and learn the basics of c++ coding and how to use variables, while loops, and if/else statements.

Also, please use normal formatting.

14 Likes

I concur. I remember my freshman year as a programmer for FRC being extremely confused (albeit FRC is a little more complicated than VRC) about PID, odometry, kinematics, code organization (subsystems, parallelization etc.), state tracking and so much more. Building a high quality custom control system can be overwhelming. Over time seeing demonstrations of various things, getting explanations from good mentors, and learning physics and engineering fundamentals helped a lot.

However, if you use PROS and are reasonably familiar with C++, OkapiLib or Ez-Template are libraries that can get you 80% of the way in 20% of the time.

2 Likes

Yeah, I figured I’d get a response like this. I’ll try slowing down my motors and hopefully that will help at least a little. It’s hard to try and learn programming on my own in high school. Would it help to see my code? Also, sorry for screwing up the formatting so much. I’m not sure how I did that.

For your purposes, I’d use the inertial sensor vex sells and program a quick PI controller for your drivebase. You can use the gyro to correct for any drift inherent to your drivebase and the PI controller will get you to your desired position much more quickly and reliably than startRotateFor.

3 Likes

Question: In the video he talks about Integral not being efficient in drivetrains. Would I just make a PD controller instead or ignore his advice? I’m also not sure how to use the gyro to account for issues with my drivetrain’s imbalance.

PI is kind of better so I would ignore his advice. Notice how he doesn’t power a drivetrain here, just code.

To use the gyro, gather a drive output and a turn output and do

Right Side = drive+turn
Left Side = drive-turn

to make it correct for error.

2 Likes

I’ve found integral to be very important for driving, but one thing I do is that I don’t make integral increase unless the robot is relatively close enough to the target, which does a good job getting the robot all the way where it needs to go, while stopping integral from growing huge and causing the robot to overshoot.

4 Likes

Could you show me some sample code?

https://wiki.purduesigbots.com/software/control-algorithms/pid-controller

2 Likes