Trajectory Following only follows path partway (Romi)

What I know isn’t going wrong:
I ran frc-characterization to get the right constants, and I generated several simple paths (like a smooth curve) using PathWeaver. I’ve quadruple checked units (everything, including characterization and all encoder counts, is done in meters). The gyroscope readings are correct. There are no MalformedSplineExceptions.

But when the Romi starts following the generated trajectory, it will only go part of the way before it shuts off, assuming it is done following the path. Ex. for a path about 7 meters in distance, it stops after traveling about 3 meters.

The code I’m using is very similar to

but is modified to use meters as encoder units. I linked an image of the PathWeaver trajectory I’m using for testing.

Thanks in advance!

Last bit of info:
PathWeaver calculates how long each path should take to traverse. The robot runs for exactly as much time as the calculated trajectory traversal time. Unfortunately, the Romi appears to not be able to move as quickly as PathWeaver calculates that it should. Is the Trajectory class shutting down the Romi at the end of the allotted time?

Can we see your code?

When you create or edit the project in PathWeaver there are settings for Velocity and Acceleration what are you setting those to?

Does it seem to stop:
After a certain period of time?
At a waypoint on the trajectory?
Amount of distance?

1 Like

Does the odometry match reality?

1 Like

Yes, you can try outputting the current pose data from your odometry object to the dashboard (or console). When you travel a metre forward, does it report you travelled a metre?
7ft is just over 2 metres, could it be a unit conversion issue?

Yep. Odometry checks out. The Pose2d matches the distance traveled by the robot and the Rotation2d matches the robot’s heading.

Definitely seems to stop after a certain period of time. It seems to stop as soon as the “calculated time to follow trajectory as defined by Pathweaver” has elapsed. It doesn’t stop at any specific waypoints on the trajectory and it doesn’t seem to stop after a certain set of distance.

Romi code is uploaded here. GitHub - BHSSFRC/3494_2021_Romi

I looked at your PathWeaver project and it looks like you have Velocity and Acceleration set to 3 Meters/second. For a normal FRC robot that is pretty common but that is WAY too fast for the Romi!

What constants would you suggest for the Romi?

I haven’t done a lot of testing with it. I would plot the velocity (in m/s) and then run the Romi at max speed. That will give you an upper bound. I would adjust down from there based on the type of trajectory you are running.

In the example you linked above it looks like ZQ uses:
public static final class AutoConstants {
public static final double kMaxSpeedMetersPerSecond = 0.8;
public static final double kMaxAccelerationMetersPerSecondSquared = 0.8;

which seems much more reasonable

Adjusting those 2 constants down lower seems to fix it! Thanks all!

To add to this, for now, we have cut that speed in half based on the recommendation from @veg We are using 0.4. We may be experiencing some similar behavior, but I am not sure it is consistent yet. I tried to run an iscoelese triangle, and though it goes perfectly through the apex point (I cannot put into words how impressive that is to watch), it continues past the second turn almost every time. I just need to do more testing to see if I am doing something wrong or if it is a similar issue.

I am not using pathweaver.

1 Like

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