After a few hours of struggling, I was able to get the simulator up and running. I am currently running the GearsBot example. I am having trouble getting the gyro from DriveTrain.java to appear in the LiveWindow when I run test mode. The encoders and rangefinder are both working fine, but no gyro widget appears. Has anyone else had this problem? The gyro works when I run Teleop or Autonomous (I can print the values to the SmartDashboard and they change appropriately as I turn the robot).
// Relevant Code
private SpeedController frontLeftMotor = new Talon(1);
private SpeedController rearLeftMotor = new Talon(2);
private SpeedController frontRightMotor = new Talon(3);
private SpeedController rearRightMotor = new Talon(4);
private RobotDrive drive = new RobotDrive(frontLeftMotor, rearLeftMotor, frontRightMotor, rearRightMotor);
private Encoder leftEncoder = new Encoder(1, 2);
private Encoder rightEncoder = new Encoder(3, 4);
private AnalogInput rangefinder = new AnalogInput(6);
private AnalogGyro gyro = new AnalogGyro(1);
public DriveTrain() {
super();
// Encoders may measure differently in the real world and in
// simulation. In this example the robot moves 0.042 barleycorns
// per tick in the real world, but the simulated encoders
// simulate 360 tick encoders. This if statement allows for the
// real robot to handle this difference in devices.
if (Robot.isReal()) {
leftEncoder.setDistancePerPulse(0.042);
rightEncoder.setDistancePerPulse(0.042);
} else {
// Circumference in ft = 4in/12(in/ft)*PI
leftEncoder.setDistancePerPulse((4.0 / 12.0 * Math.PI) / 360.0);
rightEncoder.setDistancePerPulse((4.0 / 12.0 * Math.PI) / 360.0);
}
// Let's show everything on the LiveWindow
LiveWindow.addActuator("Drive Train", "Front_Left Motor", (Talon) frontLeftMotor);
LiveWindow.addActuator("Drive Train", "Back Left Motor", (Talon) rearLeftMotor);
LiveWindow.addActuator("Drive Train", "Front Right Motor", (Talon) frontRightMotor);
LiveWindow.addActuator("Drive Train", "Back Right Motor", (Talon) rearRightMotor);
LiveWindow.addSensor("Drive Train", "Left Encoder", leftEncoder);
LiveWindow.addSensor("Drive Train", "Right Encoder", rightEncoder);
LiveWindow.addSensor("Drive Train", "Rangefinder", rangefinder);
LiveWindow.addSensor("Drive Train", "Gyro", gyro);
}
I am using the latest 2017 WPI software plugin and running Gazebo 8.