Any coding tips?

Hey, I just started coding a more complicated program that involves actually dumping dispensers into the robot instead of using simple code to knock them down. This is much more hard than I thought, and the only strategy I have is trial and (lots of) error. Is there any faster way to code, or any tips that will make it faster? I’ve been working for like 2 hours and I still can’t align my robot with purple.

You’ll probably want to use some extra sensors or extra structure. Could you maybe add a piece to your robot that aligns with the dispenser? Maybe an ultrasonic sensor would give you a better idea of where your robot is? Maybe a bumper switch?

You could consider changing your drive functions to take inches as input for movement, rather than degrees for example. This takes some of the error out of your trial and error process.

1 Like

One thing that can help get you closer, faster, is understanding how your robot corresponds to movement, in particular how many degrees of motor translates to how many inches (or mm I suppose) of movement. You could also use a protractor to figure out what angles you need to make turns for.

Using that information you should be able to map out a pretty close set of movement for an initial program.

Keep in mind that simple movement with the Drivetrain is going to have some inherent inaccuracy. Getting more precision means stepping up to something like using Caution Tape Robotics’ Drive Straight and Precise Turn code (and understanding how it works so that you can troubleshoot it).