New LED mode! (RSL sync)

I was bored and realised that I could measure roborio input current to detect when the RSLs on our robot turned on. What happened next, I’d say, follows quite naturally:

49 Likes

but-why

5 Likes

Bigger light = Bigger safety

23 Likes

I think you mean “why not?”

6 Likes

maybe easier to see in stands for RSL status? other than that, I dont see a reason or against doing it lol.

1 Like

I love this.

9 Likes

What a neat solution to… What a neat feature! Love it.

10 Likes

Can there be a code release? I’d be interested in how the implementation of this works.

3 Likes

I forgot to push to our github, but here’s some rough half-pseudo code:

// This is in a method which eventually gets called by periodic() in the LED subsystem
// THRESHOLD is a value in between the rio's input current with the RSL off and with the RSL on
boolean rslOn = RobotController.getInputCurrent() > THRESHOLD;

if(rslOn) {
    leds.orange();
} else {
    leds.off();
}

I’ll post the actual code here the next time I’m in the shop.

6 Likes

don’t listen to the haters, this is a useful feature. most of the time RSLs aren’t visible from every angle, but LEDs intended for driver feedback are. i wanted to make our LEDs sync with the RSL this year but couldn’t think of a way this clever.

4 Likes

One thing I want to change is to use a trigger to detect rises and falls in roborio current rather than using a hardcoded setpoint, to make this more consistent with various batteries and whatnot. For a first go, though, I think I did pretty well. :​)

2 Likes

I’d be curious if you could have it figure out the sync as I assume it pulses at a constant frequency, it could just figure out the sync using the current

2 Likes

Did you look at trying to reverse engineer the logic of the RSL light? Could it be running off the FPGA timestamp? On enable save the FPGA time, if time elapsed is in the first half of a period turn LED on, if its in the second half of the period turn LED off. Maybe you need some fudge factor.

pseudo code:

onEnable(){
 enableTime = Timer.getFPGATimeStamp()
}

udpateLEDS() {
 period =1.000 //assuming the period of the RSL is 1s
 
 if( (Timer.getFPGATimeStamp() - enableTime) % period < period / 2){
  turnLedOn()
}
 else {
  turnLedOff()
}
1 Like

So glad someone actually did this! Does make me wonder if there will be an update to the rules. FIRST limits the number of RSL lights to 2 (Not sure if its just a current limit reason on the rio or what). Think ether way it will be entertaining :slight_smile: Looking forward to 3d pulse animations from the RSL. Has science gone too far…

Very cool! Is there a way to access FPGA variables directly in Java and C++? In LabVIEW, you can do something like this…
RSL Access
But I’ve never tried to read these variables before, so I legitimately don’t know if that will give you the on/off behavior you’d want. Basing it off the current measurement sounds more fun.

2 Likes

Thanks!

In c++ there is a way to access the lower level api to read the rsl value. We can expose that to a higher level in both java and c++ if there is interest.

Note you might see a way to write the rsl as well. Please please do not do this, csas and ftas really do depend on that light working properly to diagnose issues. We will absolutely not be exposing a way to do that at a high level.

14 Likes

A JNI for it would be super helpful

4 Likes

I would love to see a native method in wpilibj to read the RSL state. Doing this light pattern with official code would make myself (and my mentors) much happier than these silly workarounds. :smile:

1 Like

this season we had a system designed initially for our drivers and human players but also as a side effect, was a treat for the judges

If the lights were off, that means no power or code

Magenta - Robot Disabled

Animated Magenta - Robot Running an Autonomous Routine
(not just Autonomous mode but also our lineup and balance automations in teleop. this really helped the judges see what’s being automated in a match and I believe helped us win our autonomous award)

Yellow - Robot in Teleop, Cone Mode

Purple - Robot in Teleop, Cube Mode

edit to note my cake day! I didn’t even realize!
Love you chief delphi and community! been a user for some years but hardly ever posted till this season

3 Likes