PWF Time Of Flight Help

Hello everyone! Currently my team and I are using Playing With Fusions’ Time of Flight sensor. We have been using the example code they posted (which is just around 3 lines of time of flight related code) but it won’t actually print the distance. I’ve heard that I may need to set a target and I’m unaware of how to do that. I would appreciate any help or additional sample code to look at. Enclosed below is our code. And just to be clear, the code builds and deploys but it doesn’t actually print anything. Thanks in advance!

p.s: Despite having the latest version of the PWF library, it still will not let me connect to the configuration website. Due to this, I have just set its ID to 0 since I’ve heard that is what the sensor is automatically set to. Feel free to correct me if I’m wrong!

Robot.java (3.9 KB)

This is almost absolutely about not having the CAN ID if the sensor set.
I don’t think zero is going to work.
Cursory glance at the code shows you are doing what you need to do to create the sensor object and get the range from it.

When you deploy the code to the roborio, that is using the PWF library, this is what starts a web server on the rio at port 5812.

You are going to have to find a way to get to that web configuration page to set a CAN ID.

The IP you use to access the config web page depends on how your development computer is communicating with the roborio.

If wireless then it should be http://10.XX.YY.2:5812 where XX and YY are the digits of your team number

You could also try http://roboRIO-####-FRC.local:5812 (#### are your team number)

If connected via USB try
http://172.22.11.2:5812

Hello! Thank you very much for your advice! We have just tried this where we pushed the code to the robot and enabled but then searched up the links your provided. It kept loading for quite a while and wouldn’t give us much results. Honestly I can’t seem to tell what the issue is because we are using the latest version of wpilib and the latest version of the pwf library. Do you have any further suggestions by chance?

So 10.TE.AM.2:5812 (where TE.AM are the digits of your team number) doesn’t have any data? Try curl -v 10.TE.AM.2:5812 in a terminal and post the results here.

Now it does this but the value doesn’t update.

So the server is up but no data is being sent… I’ve never seen this before so all I can say is double check your wiring.

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