merged from frcsim branch

verified to work on real robots
adds sim eclipse plugins, fixed JavaGazebo, made wpilibC++Sim build on windows
 - Java and C++ simulation robot programs run on windows
 - simulation eclipse plugin delivers models and gazebo plugins
 - Java Gazebo now respects GAZEBO_IP variables and can work across networks
 - hal and network tables win32 hacked to work on windows
 - smart dashboard broken on windows due to network tables hacks
 - wpilibC++Sim, gz_msgs, and frcsim_gazebo_plugins build with CMake
 - removed constexpr for cross platform compatibility
 - msgs generated using .protos as a part of build process
 - some spare and unused cmake/pom files deleted
 - simulation ubuntu debians removed entirely
 - refactored CMake project flags and macros
 - updated to match non-sim C++ API
 - fixed and updated documentation
 - servo added to simulation

Change-Id: Ia702ff0f1fee10d77f543810ad88f56696443b05
This commit is contained in:
peter mitrano
2015-04-26 19:19:57 -04:00
parent 4e46692191
commit 29d029fa61
211 changed files with 2143 additions and 6491 deletions

View File

@@ -54,7 +54,7 @@ public class AnalogPotentiometer implements Potentiometer, LiveWindowSendable {
m_init_analog_input = true;
initPot(input, scale, offset);
}
/**
* AnalogPotentiometer constructor.
*
@@ -73,7 +73,7 @@ public class AnalogPotentiometer implements Potentiometer, LiveWindowSendable {
m_init_analog_input = false;
initPot(input, scale, offset);
}
/**
* AnalogPotentiometer constructor.
*
@@ -90,7 +90,7 @@ public class AnalogPotentiometer implements Potentiometer, LiveWindowSendable {
public AnalogPotentiometer(final int channel, double scale) {
this(channel, scale, 0);
}
/**
* AnalogPotentiometer constructor.
*
@@ -116,7 +116,7 @@ public class AnalogPotentiometer implements Potentiometer, LiveWindowSendable {
public AnalogPotentiometer(final int channel) {
this(channel, 1, 0);
}
/**
* AnalogPotentiometer constructor.
*
@@ -190,7 +190,7 @@ public class AnalogPotentiometer implements Potentiometer, LiveWindowSendable {
public ITable getTable(){
return m_table;
}
public void free(){
if(m_init_analog_input){
m_analog_input.free();

View File

@@ -162,7 +162,7 @@ public abstract class RobotBase {
System.exit(1);
return;
}
// Set some implementations so that the static methods work properly
Timer.SetImplementation(new SimTimer());
RobotState.SetImplementation(DriverStation.getInstance());
@@ -173,10 +173,15 @@ public abstract class RobotBase {
try {
resources = RobotBase.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
} catch (IOException e) {e.printStackTrace();}
System.out.println("resources = |"+ resources +"|");
while (resources != null && resources.hasMoreElements()) {
try {
Manifest manifest = new Manifest(resources.nextElement().openStream());
robotName = manifest.getMainAttributes().getValue("Robot-Class");
if (manifest.getMainAttributes().getValue("Robot-Class") != null){
robotName = manifest.getMainAttributes().getValue("Robot-Class");
}
} catch (IOException e) {e.printStackTrace();}
}

View File

@@ -0,0 +1,192 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable;
import edu.wpi.first.wpilibj.simulation.SimSpeedController;
import edu.wpi.first.wpilibj.tables.ITable;
import edu.wpi.first.wpilibj.tables.ITableListener;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
/**
* Standard hobby style servo.
*
* The range parameters default to the appropriate values for the Hitec HS-322HD servo provided
* in the FIRST Kit of Parts in 2008.
*/
public class Servo implements SpeedController, LiveWindowSendable{
private static final double kMaxServoAngle = 180.0;
private static final double kMinServoAngle = 0.0;
protected static final double kDefaultMaxServoPWM = 2.4;
protected static final double kDefaultMinServoPWM = .6;
private SimSpeedController impl;
private int channel;
/**
* Common initialization code called by all constructors.
*
* InitServo() assigns defaults for the period multiplier for the servo PWM control signal, as
* well as the minimum and maximum PWM values supported by the servo.
*
*/
private void initServo() {
LiveWindow.addActuator("Servo", channel, this);
impl = new SimSpeedController("simulator/pwm/"+channel);
}
/**
* Set the PWM value.
*
* @deprecated
*
* The PWM value is set using a range of -1.0 to 1.0, appropriately
* scaling the value for the FPGA.
*
* @param speed The speed to set. Value should be between -1.0 and 1.0.
* @param syncGroup The update group to add this Set() to, pending UpdateSyncGroup(). If 0, update immediately.
*/
public void set(double speed, byte syncGroup) {
impl.set(speed, syncGroup);
}
/**
* Write out the PID value as seen in the PIDOutput base object.
*
* @param output Write out the PWM value as was found in the PIDController
*/
public void pidWrite(double output) {
impl.pidWrite(output);
}
/**
* Constructor.<br>
*
* By default {@value #kDefaultMaxServoPWM} ms is used as the maxPWM value<br>
* By default {@value #kDefaultMinServoPWM} ms is used as the minPWM value<br>
*
* @param channel The PWM channel to which the servo is attached. 0-9 are on-board, 10-19 are on the MXP port
*/
public Servo(final int channel) {
this.channel = channel;
initServo();
}
private double getServoAngleRange() {
return kMaxServoAngle - kMinServoAngle;
}
/**
* Set the servo position.
*
* Servo values range from -1.0 to 1.0 corresponding to the range of full left to full right.
*
* @param value Position from -1.0 to 1.0.
*/
public void set(double value) {
impl.set(value);
}
/**
* Get the servo position.
*
* Servo values range from -1.0 to 1.0 corresponding to the range of full left to full right.
*
* @return Position from -1.0 to 1.0.
*/
public double get() {
return impl.get();
}
/**
* Disable the speed controller
*/
public void disable() {
impl.set(0);
}
/**
* Set the servo angle.
*
* Assume that the servo angle is linear with respect to the PWM value (big assumption, need to test).
*
* Servo angles that are out of the supported range of the servo simply "saturate" in that direction
* In other words, if the servo has a range of (X degrees to Y degrees) than angles of less than X
* result in an angle of X being set and angles of more than Y degrees result in an angle of Y being set.
*
* @param degrees The angle in degrees to set the servo.
*/
public void setAngle(double degrees) {
if (degrees < kMinServoAngle) {
degrees = kMinServoAngle;
} else if (degrees > kMaxServoAngle) {
degrees = kMaxServoAngle;
}
set((degrees - kMinServoAngle) / getServoAngleRange());
}
/**
* Get the servo angle.
*
* Assume that the servo angle is linear with respect to the PWM value (big assumption, need to test).
* @return The angle in degrees to which the servo is set.
*/
public double getAngle() {
return impl.get() * getServoAngleRange() + kMinServoAngle;
}
/**
* {@inheritDoc}
*/
@Override
public ITable getTable() {
return m_table;
}
/*
* Live Window code, only does anything if live window is activated.
*/
public String getSmartDashboardType() {
return "Servo";
}
private ITable m_table;
private ITableListener m_table_listener;
/**
* {@inheritDoc}
*/
public void initTable(ITable subtable) {
m_table = subtable;
updateTable();
}
/**
* {@inheritDoc}
*/
public void updateTable() {
if (m_table != null) {
m_table.putNumber("Value", get());
}
}
/**
* {@inheritDoc}
*/
public void startLiveWindowMode() {
m_table_listener = new ITableListener() {
public void valueChanged(ITable itable, String key, Object value, boolean bln) {
set(((Double) value).doubleValue());
}
};
m_table.addTableListener("Value", m_table_listener, true);
}
/**
* {@inheritDoc}
*/
public void stopLiveWindowMode() {
// TODO: Broken, should only remove the listener from "Value" only.
m_table.removeTableListener(m_table_listener);
}
}