Read Romi On-Board USB

Hi!

Basically, i have this LiDaR code that i want to use on the romi. In order for the lidar to work and my program to read it’s data, i need to have access to dev/USB0. Right now, when i simulate the code (connected to romi) my code just says that “dev/USB0” is not a real port. However, if I connect my lidar to my mac port (and change to dev/usb-serial-0001 (i think)) then it works fine. I suspect that simulate just runs the code on my computer and jst gives the data to the romi to execute. However, I want my code to directly be run on the romi’s Raspberry PI. Thus, how can i do that?

Thank you!

(PS: I know that I’m very bad at explaining things so if you need any additional info please tell.)

You will need to run a separate application on the Romi and send the data over NT (just like a vision coprocessor). The Romi is built on the WPILibPi image which has some templates for creating vision programs in C++, Java, or Python, which you could use as a starting point. There is currently no way to run your robot code on the Romi itself.

1 Like

Yep, you’ll need to write that LidarForwarder app.

I’ll add that if you look at what’s aleady in /home/pi on your Romi, you will find python examples of writing to NetworkTables server. Those you can copy and paste.

You will also need to configure static IP on the wifi interface of PC where you are running Romi simulator (because this LidarForwarder will need to connect to NetworkTables server on that address, it needs to know what that address is).

(RoboRIO has a fixed IP normally and nobody says that it is ugly, so why not do the same too)

1 Like

Tbh, i think im fine with a cord for now since it sounds too complicated and its just a proof of concept TY tho!

Actually you don’t need to do that. We use a clever hack on the Romi to avoid it, by using the protocol that NT uses to get the robot IP from the DS in dashboard use cases. The Romi control server mocks the DS side of the protocol so when the sim connects to the Romi, the sim host address is provided as the robot address to the NT client.

You do have to disable firewalls on the PC though so it can make the connection.

@Peter_Johnson this will be handy, thanks!
Do yoh have an example code that gets this address?

The examples already do it. NetworkTableInstance.startDSClient() sets up the instance to get the server address from the DS server.