Inconsistent and odd behavior with WPIlib and Java

I’ve installed the latest WPILib 2024 beta and associated firmware with no problems.
Created the example XRP Reference project and ran it with WPILib:Simulate Robot Code.
And what I get is somewhat random behavior.

Sometimes it works exactly as I expect

  • When disabled it does nothing
  • In Autonomous it runs the Autonomous Distance Routing
  • In Teleop it drives and turn

But sometimes

  • In disabled, the servo arm randomly moves with no inputs from a joystick or keyboard
  • Sometimes it doesn’t nothing at all in autonomous or it drives very slowly in odd directions.
  • Sometimes it won’t drive at all, it ignores the joystick inputs.
  • When it won’t drive, I can set a breakpoint in arcadedrive and it’ll reach the breakpoint and the speed variable does show a non-zero value.
  • Sometimes when it won’t drive, setting a breakpoint does nothing even though the simulator looks as if the code is still running.

There are no errors in the terminal window.

When I tested this at home, it worked fine. When I brought it to the school to show the kid on the team I was only able to drive it once. And after that, no matter how many times I restarted the code and simulator, it never worked properly.

I have no idea how to debug the issue. Any suggestions?

I know that frustration of getting something to work on my home network, then taking it to school and having it fail partially or completely. Often depends on differences in how network admins have secured the district’s network (especially for elementary schools). That’s one of the reasons I like having the Pico-W for the XRP; you can always run your own network. When sys admins see what you are trying to achieve, they can be persuaded to find ways to make it possible.

Sorry, other than commiserate, I can’t help solve your challenge.

@ZeeQueue Any thoughts or suggestions?

Back at home running the same code I was trying to run last night at the school. The XRP works fine. It really does appear that there is some interference in the communication. I do not have any networking knowledge. Are there any settings that can be configured in the wifi connection that I could try?

The WPI docs say

The XRP provides a simple Web UI for configuration. It is accessible at http://<IP Address of XRP>:5000 . By default, this is http://192.168.42.1:5000 .

I get “this site can’t be reached” if I put that in my browser (when connected to the XRP wifi). How do I know what the correct address is?

FYI - I did try the following instructions:

If you are unsure about what mode the XRP is operating in, or which WiFi network it is connected to, you can connect the XRP to a computer via a USB cable. A USB storage device named PICODISK will appear, and the xrp-status.txt file within it will list the appropriate network information.

This was more difficult than it should have been. It took multiple tries, multiple cables, turning the XRP off/on and connection and/or disconnecting from its Wifi before I finally got the XRP-Status.txt file to appear. Mostly I got errors about the USB drive being invalid. But…once I did get to see the file, it said

Version: 1.0.0

Chip ID: 8360-4f2c
WiFi Mode: AP
AP SSID: XRP-8360-4f2c
AP PASS: xrp-wpilib
IP Address: 192.168.42.1

I unplugged the XRP, turned it back on. Connected to its Wifi, tried the IP address again and got:

# This site can’t be reached

**192.168.42.1** refused to connect.

We have seen a couple situations that can cause this.
1 - Some school have WiFi blockers that block devices that setup their own networks. You might check with your schools IT department to see if they have an WiFi blockers turned on.
2 - We have also seen the case where there are too many devices creating their own network in a room. For instance when there are more than a dozen XRPs all in FRC mode we start to loose connections.
3 - Distance. The XRP is a lower power WiFi device and we have seen when the robot gets too far away from the computer it can loose its connection.

As for the problems getting to the XRPs web page, I will see if @ZeeQueue has any suggestions.

That web address should work (especially if you are connecting to the AP created by the XRP). You mentioned that the network problems were NOT seen when you tested this at home right? Was the web page accessible then?

I have some plans to build a better configuration method, but this will take some time

I don’t think those apply here:

  1. We connect to our FRC robots all the time and we don’t have any issues with that. Sometimes we have multiple FRC robots running simultaneously.
  2. At the time I was testing, there was one XRP and 2 FRC robots. The FRC robots worked fine.
  3. The XRP was right next to me, less than 5 ft away.

Sorry, I should have been clear about that.
I only attempted to access the web page at home. I never tried it at the school. So I was not having the network connection issues that I described in the original thread.
Perhaps there is a specific order I should do things?

  • Should the robot on/off switch be on or off?
  • Should the USB cable be connected to the laptop or not?
  • When should i power the XRP off/on?
  • I assume that I should have the laptop connected to the XRP SSID, right?

Is there any other data I can collect for you to help figure this out?

As long as the Pico gets power, the WiFi and webserver should work fine. And yes, you should have the laptop connected to the AP that the XRP generates.

One thing you could try is wiping out the flash memory of the Pico and then re-installing the firmware. Follow the instructions here: Raspberry Pi Documentation - Raspberry Pi Pico and Pico W to wipe the memory, and then re-install the xrp-wpilib-1.0.0.uf2 firmware and see if that helps

I had just reinstalled the firmware prior to this happening.

To be exact, I had installed the WPIlib environment at home, tested the robot to see if it worked. All was fine.
Then I uninstalled and reverted back to the original python environment (to prove to myself that I knew how to do it).
And then I reinstalled with WPILib environment using the firmware version in your post. I did a brief test at home to ensure it worked and brought it to the school that night where everything ceased to function.

I did replace the batteries before bringing it to the school.

Unfortunately due to the holiday break, I won’t be able to test at the school until after 1/6. But please, if anyone has suggestions post them. At this point, the XRPs are useless which make me very sad :frowning: I was really looking forward to using them as a teaching tool.

Thanks

I’m reopening this issue because it’s back with a vengeance.
I am using the XRP at home in order to eliminate the issue of school interference.

I cannot get this robot to act reliably.
I am running the XRP example code from WPI “out of the box” with the only change being the joystick button for the steering motor because it maps differently on my xbox controller.

Initially it works great. Autos work, teleops work. Everything is fine.
But within less than 2 minutes it stops responding to all inputs from the controller.
I still have connectivity and can see the page at http://192.168.42.1:5000/
It looks like

{
    "configVersion": 1,
    "network": {
        "defaultAP": {
            "ssid": "XRP-8360-4f2c",
            "password": "xrp-wpilib"
        },
        "networkList": [
            {
                "ssid": "Test Network",
                "password": "Test Password"
            }
        ],
        "mode": "AP"
    }
}

As I type this, the simulator is still open and teleop is selected. The controller buttons do nothing at all.
And the XRP is periodically moving the servo on it’s own.
The simulator widget for the servo does not change when the servo moves. It just says:

true       init
0.000000   position

FYI - I did add a line of code in Arm.setAngle just to see if something was calling the setAngle routine when the servo starts moving on it’s own:

System.out.println("setting angle:" + angleDeg);

The code isn’t being called. So something is sending a signal to the servo that isn’t my code. However, when I shut down the simulator. The servo stops moving.

So in conclusion, I have a robot which only works for 1-2 minutes at a time and then loses the ability to be controlled. And something is causing the servo to move and it’s not my code.

I am using https://github.com/wpilibsuite/xrp-wpilib-firmware/releases/download/v1.0.1/xrp-wpilib-firmware-1.0.1.uf2
and this version of WPILIB
WPILib_Windows-2024.2.1.iso