I want to go to the target position with Drive, what should I do?

I want to go to the target position with Drive, what should I do?
I want to go straight for a certain distance.
The robot uses to two Talon SRX,two Victor, four motors and eight tires.
Talon also sends instructions from Roborio to one Talon and has one Victor follow Talon.

Okay so what I understand from this question is that you want your robot to drive in a straight line for a certain distance. Do you have encoders on your wheels? If so you should use the PID on the Talons, if not you need to time how long it takes to drive that distance.

As @64bitGPU said, encoders are the best option.
An Inertial Measurement Unit (IMU) is also a good option. In theory, you could double integrate the accelerometer in your RIO to measure distance, but that doesn’t seem to work very well.
If you do “time” the run, I suggest running the Talons in voltage compensation mode for autonomous; it’ll help even out any variation among your batteries.

Neither of these options are worth even one tenth of the time it takes to code them, unfortunately. Except possibly in entertainment value as you watch the hilarious random walk of your resulting pose estimation.

1 Like

What programming language? If it’s Java, do you use Iterative or Command-based programming?

Supposing you use Java, take a look at the Phoenix examples from CTRE, on Github. There are also other languages available as well, just poke around:

You’ll want some combination of “DifferentialDrive”, “DriveStraight_Pigeon”, and “PositionClosedLoop”.

On the topic of IMU usage for absolute field X/Y/Pose estimation:

In the price range available for FRC, IMU’s are good for estimating changes of linear displacement on the scale of < 5 seconds. Any longer than that, and the error will become unacceptable.

Many teams have shown that a very good (and definitely good enough) FRC solution involves encoders (wheel odometery) fused with gyroscope readings.

There’s a chance you may discover something better through experimentation, and for that reason it’s definitely valid to play around with different ideas. However, be realistic about what can be achieved in a build season. It’s unlikely, no matter how insightful you are, that you’ll be able to outsmart 10,000 other people thinking about the same problem.

Edit: More hedge words.

CTRE’s documentation on MotionMagic for the traezoidal profile is quite good, and fairly simple to implement.

If your purpose is to get to the appropriate distance to the goals, another alternative is to use the retroreflective tape on the goal. You can do this with a webcam and your own coding, but using a pixycam or limelight would almost certainly get you to success faster. If you do this, it could also be useful during teleop - just get close, hit a button, and let the robot find the sweet spot.

Thank you all. Each motor has an encoder on the left and right. Do I need to connect the encoder directly to Talon?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.