Closed cpeppler01 closed 4 years ago
Thanks for reporting this.
Root cause analysis: Scope: occurs only in Java (due to WPI Library JNI Layer throwing unhandled exceptions upon "unclean status" codes returned from underlying HAL. Trigger: The unclean status exception happens only for PWM resources when they are closed, due to an overaggressive error check in the underlying VMXpi Platform Library (vmxpi-hal) when a resource is deactivated without have any channels allocated to it. This case occurs in the VMX-pi wpilib hal (for PWM channels only) as it always unroutes PWM channels from PWM generator resources, and then only deallocates the PWM Generator resource once the number of routed channels drops to 0. This logic is in place to handle cases (e.g., FlexDIO PWM Generator Channels) which can route multiple channels per PWM Generator Resource.
The fix for this issue will be in the VMX-pi Platform Library (vmxpi-hal). This github issue will be closed once that release has ocurred.
This case is not exercised typically (robot applications typically don't close/release the resources they allocate). Until fixed, the recommended workaround is to either not close the PWM resource, or to add an exception handler around the code that invokes it.
We can only hope that the WPI Library will fix the policy of allowing unhandled exceptions to occur when unclean status codes are returned from the HAL, but we don't have control over that part.
This issue is resolved by an updated version of the Kauai Labs vmxpi-hal library for the Raspberry Pi (v. 1.1.220).
To install this updated library on your raspberry pi, after ensuring the raspberry pi is connected to the internet, from a console terminal run the following commands:
sudo apt-get update sudo apt-get install vmxpi-hal
If the installation does not work as expected, you may need to run these commands in order: sudo apt-get remove vmxpi-hal sudo apt-get install vmxpi-hal
Environment: Raspberry Pi v3B. VMX-pi model 0x32, hardware rev 60, firmware version 3.0.411
Overview: Attempting to control a Feetech (FiTec) Servo Motor, Model FS90MR. Physically connected to High Current DIO port 12, wpilib channel 0
Have had some luck, but trying to gain smooth control over the servo using wpilib Servo class, by using a basic joystick control (Y axis, Joystick 0).
Starting to work with teleopInit() to initialize the servo, and disabledInit() to stop the servo close the motor, and release the Servo object.
There is a repeatable exception thrown by VMXPI.cpp when calling close() on the allocated servo.
Here is relevant log info. Source code to Robot.java is attached.
Here is the code: