Logitech Controller Buttons and Controlling Actuators

Yes, I have posted about each of these things separately before. But the problems persist.

No, I still have not read the rulebook. I know I should have long ago, but it is too late now.

Our team is doomed if we can’t figure these things out.

Are you using the Logitech “fakebox” controller that came with the Rookie Starter Kit? If so, do you know what numbers correspond to what buttons? I got this from my last post, but it is not accurate with our controller; for instance, our A button is 6, not 0. Is there a way to set those numbers somehow, or a place where I can see them all?

Do you use AndyMark actuators on your robot? The .set() method of the Servo class does not seem to work for us, even when we put it in RobotInit rather than a button press.

Here is all of our code:
Robot Backup 3-1-19.java (4.3 KB)

Naturally I cannot show you any pictures of the wiring right now. Let’s just pretend that it is flawless.

Thank you for any help you can give us.

Logitech F310 gamepad correct?

We are using that one and here is our button mapping:

Button Mapping (expand me!)
    const int X = 1,
        A = 2,
        B = 3,
        Y = 4,
        LB = 5,
        RB = 6,
        LT = 7,
        RT = 8,
        BACK = 9,
        START = 10,
        LMELEE = 11,
        RMELEE = 12;

This is using the mode where the two triggers show up as buttons. (Note we use C++, but the button mapping should be the same).

Other than the indentation and exact numbers most of your code seems to be right.

Can you explain a bit more what you were seeing on the robot?

Also, don’t despair too bad, each even will have CSAs (orange hats) that can help with these issues at the event.

1 Like

Bottom line: You can see the button numbers for any controller by plugging it into your driver station and going to the USB tab. Select the controller you need to characterize and as you press the buttons and move the joysticks the display will show you what button number and joystick axis is being used.

Code like the following will probably not behave properly if you keep the button down for more than 20ms (highly likely).

// Toggle the tulip's position
if (A.get()) {
  if (tulipPos == 0.5) {
    tulipPos = 1;
  }
  else {
    tulipPos = 0.5;
  }
  tulip.set(tulipPos);
}

The teleopPeriodic() method is called every 20ms by default and the code shown here will, as long as the button is held, toggle the setting for tulip back and forth. This is probably not what you want. The last time through with the button down will win.

You probably just want to change state if the value of A.get() is true and different from the last cycle. You want something more like this.

// Toggle the tulip's position
if (A.get()) {
  if (!lastTime) {
    lastTime = true;
    if (tulipPos == 0.5) {
      tulipPos = 1;
    }
    else {
      tulipPos = 0.5;
    }
    tulip.set(tulipPos);
  }
}
else {
  lastTime = false;
}

I hope this helps,
Steve

1 Like

It only shows the numbers for the first few buttons. The others light up boxes that have no numbers next to them – which is very unhelpful.

I think so. Although, ours has little triangles on the Start and Back buttons that don’t show up in any other pictures.

What’s wrong with the indentation?

What do you mean? For the buttons, they give an error in the RioLog when they are not set to the correct number. For the actuator, it just doesn’t work. Here’s a picture of it:

That is a very good point. I don’t think it’s the problem, because we tried the .set() in the RobotInit not tied to any buttons, but it was definitely a problem. Thank you!

Looking at the link you provided for button mapping, it appears to have multiple modes which change button configuration. Can you make sure that it is in the correct mod (X/D switch on back, and mode light)?

curses at window’s built in code reader Nothing, it was just not displaying right for me. It actually is better than our code…

Waz’s suggestion is an important one to make sure to implement, but since you said it wasn’t the full cause… Try instead of putting the code in robot init (since most controllers are disabled when the robot is disabled) put it in teleopInit and do tulip.set(1.0); If that works make sure 0.0 works. If those do then it must be something with the triggering code, if it doesn’t work then it may be electrical or mechanical.

1 Like

I will do that. Thank you for all your advice.

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