Trajectory following with the Romi

ZQ’s long winded ramble about trials and tribulations. Feel free to skip ahead
My team has always had problems trying to do trajectory following with our robots, and we’ve often been jealous of robots making smooth, complex paths on the field, while ours uh… do the jerky “i-think-this-is-where-i-need-to-be” driving. Apart from the usual problems of not having a robot ready until 10 minutes before our first match, it’s been extra hard last year (and this year), since we are fully remote, and have no access to our robot, nor a build space. With the Romi however, we can get a lot more students learning how to path-plan and get familiar with the WPILib Trajectory system.

romi-trajectory (1)

Now you too can slalom at home with your Romi! I built a modified version of the RamseteCommand WPILib example and added in a bunch of extra waypoints.

The drivetrain constants were found using the frc-characterization tool, and a Romi characterization template project. The README on that link has a little more information on how to use frc-characterization to get useful numbers about your Romi. The constants defined in the Romi trajectory project were based off a stock Romi kit with no additional components. You may need to tweak values a little to compensate for physical differences between the Romis, or better yet, characterize your own!

Hopefully this helps more teams learn about the joys of trajectory following, on a smaller scale :slight_smile:

30 Likes

that’s really cool! Thanks for including that information in the read-me!

3 Likes

This is awesome! I was literally just chatting with my team about how to do this.

Smooth video, too!

2 Likes

As the trajectory stuff is very new for me, would you be able to provide a screenshot of what the data analyzer screen looked like for you? It took me awhile to figure out that I needed to change the units to meters in that screen for the trajectory project. Then it took me awhile longer to figure out that I needed to put in 0.219 for the units per rotation. Now I’m wondering if I need to adjust the max controller output and max acceptable control effort for the romi project, and if I should use the WPILib gain settings preset or something else.

Thanks!

2 Likes

I updated the docs (romi-examples/romi-characterization at main · bb-frc-workshops/romi-examples · GitHub) with a screenshot and some additional details

8 Likes

This is incredible. Thank you for sharing this with us and as others have said, the docs help us understand how to get it going for ourselves, I was close to figuring it out, but there are so many pieces and we have had a few other projects come through that take precedence. This is such an exciting project and the trajectory feels like the culmination of it. And yet, there is so much more we can do with these bases.

4 Likes

Very cool! Our team experimented with trajectory profiling last year and are trying to improve it. I’m using the Romi, but when I put some coordinates in and run it, the Romi spins around instead of doing what I plugged into it. Do you have any suggestions on how to fix it? Thanks!

I had a similar experience with an earlier release of WPILib. They recently fixed a few things, including the gyro calibration.

Make sure you are fully updated to the latest release of WPILib 2021.2.1 which is just a few days old. You need to update your WPILibPi image and then also the firmware on your Romi, and recalibrate the gyro.

1 Like

Thanks veg for the response so quickly! Everything was up to date, but I realized that I had inverted the right motor when running usual code, and when I used this code the tankDriveVolts() method inverted it again, so it created the spinning. Now it works. Thanks though for the advice!

1 Like

I’m probably messing something up here but:
Am I doing this right? I have cloned https://github.com/bb-frc-workshops/romi-examples/blob/main/romi-characterization to my PC, I have clicked shift F5 to deploy the project to the romi, it goes fine (nothing shows up in rio log, is this normal?),

Next, I downloaded frc-char using these instructions: Introduction to Robot Characterization — FIRST Robotics Competition documentation (wpilib.org). Then, I don’t do anything with the settings (I feel like this is wrong), and just open up the data logger.

I then make sure that I am connected to the romi wifi and click connect. It waits there for an infinite amount of time and that is where I am stuck.

I feel like I am messing up a part here however, this is what the instructions in the readme make it seem like.

Did you fill in all of your robot data in the python code? In the instructions it says to make sure you’re saving it and fill out the settings, including filling out team number, units, units per revolution, and all the python code below.

For the Romi, you’ll need to do the following:

  • Start up the frc-characterization data logger
  • Open the romi-characterization project in VS Code
  • Hit F5 (or the “Simulate on Desktop” command) to start the robot code. The Romi code runs on your development computer and not on the Romi itself
  • Once the sim GUI pops up, you should be able to click “Connect to Robot” on the frc-characterization data logger and start the tests
1 Like

What OS are you using? What version of pynetworktables?

I got this working eventually, it wasn’t clear to me that F5 was supposed to open up the sim GUI.
OS: Windows 10 Home 1909
Pynetworktables Version:2021.0.0

So I’ve cloned the GitHub code and throw the romi-characterization into vscode, then press f5 and get a,

java.io.IOException: wpiHaljni could not be loaded from path or an embedded resource.

All the fixes I’ve gotten from CD haven’t worked so im wondering if its something with my vscode.
Am I doing something wrong here?

Do you get this error with a normal program and the Romi? If not, did you open the entire repo as a project, or just the trajectory example? The repo has 3 projects in it, and vscode may not know which to launch. There are other possible path errors that can occur from just launching a repo from a random downloads folder too. I would suggest creating a new window in vscode and adding the downloaded folder (just the root of the trajectory example) to that project. Then try to run simulation.

1 Like

First time getting this error, no other programs get it. (Also asked my lead programmer to run it and got the same error, assuming we are doing something wrong) I’ve only opened the characterization folder not either simple-arm or Romi-trajectory, not sure what you mean by putting the entire download folder in vscode.

However I have noticed wpilib wants me to download 2021.2.1, and the popup states I’m on 2021.1.2, and when I go into extensions it says I’m on v2021.2.1. Whenever I click download it seems to download it but whenever i reopen vscode it always wants me to update. Im going to try a clean redownload of vscode later tonight and see if that might fix the issue with the wpiHaljni error and the weird downloading thing.

Just had the same issue. I created a new romi command project from the “command pallete” and cut and replaced the src folder with the folder from the characterization example and then it worked fine.

1 Like

Thank you!! This worked however very interesting issue indeed.

1 Like

Thanks for putting out this resource! I ran into an issue with frc-characterization that I haven’t been able to resolve - when I run quasistatic forward/backwards it works great, but dynamic forward/backwards does not work at all unless I set the step voltage to 12, at which point it goes full speed. Any other values do not cause the Romi to move at all.

Has anyone else encountered or resolved this?

1 Like