Romi Python Help?

We are looking for some help getting our Romis working with robotpy.

Ultimately we want to use them for a zero-auto tutorial, but for now, we would settle for just being able to get them to move.

We have code working in the simulator, but we cannot get it to drive the Romi. Here is what we tried

  1. Writing our own basic code and changing the end of the file to match the example…
if __name__ == "__main__":
    # If your ROMI isn't at the default address, set that here
    os.environ["HALSIMWS_HOST"] = ""
    os.environ["HALSIMWS_PORT"] = "3300"

The robot code still runs as expected in the simulator, but the Romi does not move.

Then, we tried to run the example itself located here

When we try that, we get the following error…

Traceback (most recent call last):
  File "/home/lekofraggle/commands-v2/romi/", line 41, in <module>
    from robotcontainer import RobotContainer
  File "/home/lekofraggle/commands-v2/romi/", line 10, in <module>
    import romi

So, we tried to install the romi module, but that is where we ran into issues.
when trying…
pip3 install robotpy[romi]
it cannot find the module.
When trying the old way…
pip3 install robotpy-romi
It installs the module, but the old one, and it uninstalls many of the current modules due to them being incompatible.

So, we are a bit at a loss. Does anyone have a step-by step install for the robotpy and Romi?
Thank you for all the work you all have done on robotpy. It is really looking good.

Robotpy support for romi hasn’t been updated for 2023. To use Romi with Python, you need to use a 2022 version of robotpy.

1 Like

Got lost in the shuffle. robotpy-romi 2023.4.2 is being built now.


Thank you both. That is incredible.

I have a few follow-up questions.

  1. Is there a recommended method to clean the install or update robotpy and all of the installed submodules?

  2. If all you want to do is drive, is the Romi library required to run the Romi (using the victor motor class rather than the Romi-specific motor, controller, and io)?

  3. Beyond setting the ip of the Romi in, and installing the sim module, is there anything else we need to do to connect to the Romi?

  • 1: pip install -U robotpy should do it
  • 2: I dunno, frc-docs might have something abotu this?
  • 3: I think that’s it

Thank you for your help. I was able to install the new Romi library, but it is still not working.

In Java, there is not a need for the separate Romi library if you do not need the onboard io. The only requirement is the environment variable lines in Gradle.

//Sets the websocket client remote host.
wpi.sim.envVar("HALSIMWS_HOST", "")
wpi.sim.addWebsocketsServer().defaultEnabled = true
wpi.sim.addWebsocketsClient().defaultEnabled = true

When you run the simulator, it connects and reports the connection attempts in the terminal window.

In Python, thus far, this is not happening. I tried our file (a basic single-file robot, and the example in the commands folder), but none of them seem to be connecting. The terminal reports looking for two ports (I do not have my computer with me right now, but neither of the ports is the one listed in It tries once and then stops looking. I see this line in the terminal for Java too, but then it adds another (Connection attempt 1, etc).

I am wondering if there is something else I may need to do to connect to the Romi with Python.

We are connected to the Romi and can see it in our browser.

I haven’t tried any of this, but what command line are you running with? In the example it mentions:

# To run the program you will need to explicitly use the ws-client option:
#    # Windows
#    py -3 sim --ws-client
#    # Linux/macOS
#    python sim --ws-client

What is the logging output that you’re getting on the command line?

1 Like

Thank you. That was it. I am so sorry that I missed that comment.
Thank you again. It works. I got the example working right away. I am using the 2023 libraries too :slight_smile: