Hi, first-time mentor, first post here. I’m trying to get Eclipse working with Gazebo, but having some issues with the joystick inputs.
I’ve set up FRCSim on Ubuntu 14.04, as described in the WPI lib docs. Gazebo 6 runs fine, The sim_ds command seems to work fine, it recognizes my Logitech F710 as a RumblePad 2, fwiw.
When I run the jstest-gtk program, that shows the controller and registers Axis 0 and Axis 1 with full range of input – values change correctly when I use the controller.
However, when I run one of the example Robot programs in Eclipse (Java simulation build target), the values it reports from the joystick are all zeros.
My Robot program right now it basically all Joystick debug:
package org.usfirst.frc.team1.robot;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.buttons.JoystickButton;
import edu.wpi.first.wpilibj.command.PrintCommand;
public class Robot extends IterativeRobot {
RobotDrive myRobot;
Joystick joystick;
public void robotInit() {
myRobot = new RobotDrive(0, 1);
joystick = new Joystick(0);
myRobot.setExpiration(0.1);
// myRobot.setSafetyEnabled(true);
// while (isOperatorControl() && isEnabled()) {
Thread t = new Thread(() -> {
while (!Thread.interrupted()) {
double l = -1 * joystick.getX(), r = -1 * joystick.getRawAxis(0);
System.out.println(l + " " + r);
// Create some buttons
JoystickButton d_up = new JoystickButton(joystick, 5);
JoystickButton d_right = new JoystickButton(joystick, 6);
JoystickButton d_down = new JoystickButton(joystick, 7);
JoystickButton d_left = new JoystickButton(joystick, 8);
JoystickButton l2 = new JoystickButton(joystick, 9);
JoystickButton r2 = new JoystickButton(joystick, 10);
JoystickButton l1 = new JoystickButton(joystick, 11);
JoystickButton r1 = new JoystickButton(joystick, 12);
// Connect the buttons to commands
d_up.whenPressed(new PrintCommand("up"));
d_down.whenPressed(new PrintCommand("down"));
d_right.whenPressed(new PrintCommand("right"));
d_left.whenPressed(new PrintCommand("left"));
r1.whenPressed(new PrintCommand("r1"));
r2.whenPressed(new PrintCommand("r2"));
l1.whenPressed(new PrintCommand("l1"));
l2.whenPressed(new PrintCommand("l2"));
}
});
t.start();
}
}
I’m running sim_ds in terminal. Once it launches (and says “claims to have found 1 controllers”), I click the Logitech controller (first item in the list, rest are “Empty joystick”) and then click “Enable” on Teleop). One possibly useful thing is that when I stop the Eclipse program, sim_ds spits out the following:
WARNING|Gazebo Transport: Can't handle publisher_del
WARNING|Gazebo Transport: Can't handle publisher_del
WARNING|Gazebo Transport: Ignoring unsubscribe: topic: "/gazebo/frc/ds/state"
host: "0.0.0.0"
port: 45388
msg_type: "gazebo.msgs.DriverStation"
latching: false
WARNING|Gazebo Transport: Ignoring unsubscribe: topic: "/gazebo/frc/ds/joysticks/0"
host: "0.0.0.0"
port: 45388
msg_type: "gazebo.msgs.Joystick"
latching: false
Also, the controller is showing in the OS as js0:
$ ls /dev/input/js0
/dev/input/js0
It seems like I’m not connecting to the correct controller in my robot code, but not sure what it would be besides
Joystick(0);