Squashed 'third_party/allwpilib_2016/' changes from 7f61816..3ce6feb
3ce6feb Updated release number for the new release
e054bbc This adds StopMotor() to the SpeedController interface for C++ and Java. For Java, this is as simple as just adding it, as all motors already have an implementation from MotorSafety that is correctly resolved. For C++, I had to override StopMotor in the classes that descend from SafePWM and explicitly call the SafePWM version. RobotDrive now calls StopMotor on each of its SpeedControllers, instead of calling Disable or setting the motor to 0.0 as it was doing previously.
a15b9dc Merge "More updates to the Gyro test fixing potential null pointer exception"
21b7213 Added Config routine to allow enabling/disabling of limit switch and soft limits. This improves upon the ConfigLimitMode routine, which does not allow certain combinations of enable/disabled limit features. Also keeps parity with LV and Java.
1b45237 Merge "Add an additional member variable for "stopped" which indicates the CAN motor controller has been explicitly stopped, but not disabled by the user (main use case is MotorSafety tripping). When Set() is called the next time the controller will be re-enabled automatically."
1096b15 Add an additional member variable for "stopped" which indicates the CAN motor controller has been explicitly stopped, but not disabled by the user (main use case is MotorSafety tripping). When Set() is called the next time the controller will be re-enabled automatically.
7da21fa More updates to the Gyro test fixing potential null pointer exception
ede5862 Rate-limit duplicate error messages to avoid flooding console.
c22284d Merge "artf4818: Fix CAN Talon JNI references with underscores."
cac3741 Merge "Updated PDP port of Talon and disabled PDP tests for Victor and Jaguar since the Victor and Jaguar don't draw enough current for the PDP to read above 0. PDP tests for both java and cpp only test the Talon now."
097aa8c Fixed the gyro deviation over time test
1d647b3 artf4818: Fix CAN Talon JNI references with underscores.
368cfc7 Merge "Fixed the motor tests by reducing speed to within the limits of the encoders we use. Also fixed java pid tolerances since getAvgError() was broken. It is now fixed and works properly. Added tests for both java and cpp that test if pid tolerances are working using fake input output pairs."
833e459 Updated PDP port of Talon and disabled PDP tests for Victor and Jaguar since the Victor and Jaguar don't draw enough current for the PDP to read above 0. PDP tests for both java and cpp only test the Talon now.
6c096a3 Fixed the motor tests by reducing speed to within the limits of the encoders we use. Also fixed java pid tolerances since getAvgError() was broken. It is now fixed and works properly. Added tests for both java and cpp that test if pid tolerances are working using fake input output pairs.
dd7eb0f Fixed robot drive for C++ Simulation
258a622 Merge "Update version number for Release 3 Print distinctive message on robot program startup Change-Id: Ic91b81bd298ee6730503933cf0e733702e4b4405"
b1386c6 Update version number for Release 3 Print distinctive message on robot program startup Change-Id: Ic91b81bd298ee6730503933cf0e733702e4b4405
a58de40 Merge "Removed publishing of java sim jar"
792d0d3 PDP Classes should support any PDP address
35df955 Merge "Remove maven local as a possible search location"
a0ce9ee Another improvement to HAL-joy getting to ensure it works in future RIO image updates.
0f02c31 Removed publishing of java sim jar
8435ac7 DriverStation::GetJoystickName(): Make work for stick>0.
b4cf4f4 Remove maven local as a possible search location
c3000c3 Merge "Fix HALGetJoystickDescriptor()."
4dec0b4 Merge "Fixed Simulation C++ API"
abc9c27 Fixed Simulation C++ API
b8ae9ec Fix HALGetJoystickDescriptor().
a60f874 Artf4800: Fixes HALGetJoystick*** Segfault
010b584 Merge "fix sim_ds launch script"
4429e16 Merge "Added build dir specification for sim javadoc to not overwrite athena javadoc"
ec9349b Initialized the m_sensors variable to fix artf4798.
9745af8 Added build dir specification for sim javadoc to not overwrite athena javadoc
4da8702 fix sim_ds launch script
05acf79 Fix C++ PIDController SetToleranceBuffer and OnTarget locking.
94a6b05 Merge "Fix onTarget() so that it returns false until there are any values retrieved"
d06053d Fix onTarget() so that it returns false until there are any values retrieved
74927cc Correctly set smart dashboard type for AnalogGyro and ADXRS450_Gyro.
070752f Merge "Fixed sim_ds script library path"
21a8bab Merge "PIDController feed forward term can now be calculated by the end user"
56bd6da Fixed sim_ds script library path
07710f1 Merge "Fixing install script... again"
e1cb61f Use absolute path for NT persistent storage.
09c7482 Fixing install script... again
a3b8bec PIDController feed forward term can now be calculated by the end user
790adb0 artf2612: Update license in source files.
042671c Merge "Removed gz_msgs from wpilibcSim"
c111690 Ultrasonic: replace linked list with std::set.
d71a8ed Removed gz_msgs from wpilibcSim
37259f7 Merge "Replaced linked list in Notifier with std::list"
cd17e7a Merge "Renamed Gyro to AnalogGyro to match athena API"
c5c8a87 Replaced linked list in Notifier with std::list
89405d8 Renamed Gyro to AnalogGyro to match athena API
4a19490 Merge "Adds CANTalon to LiveWindow"
c4a3567 Merge "Fixing the frcsim installer script"
295648f Adds CANTalon to LiveWindow
1b964a2 Merge "Fixes CAN devices in C++ library not showing in the livewindow"
7ba5cee Merge "HAL: Use extern "C" in implementation files."
d17d242 Fixes CAN devices in C++ library not showing in the livewindow
25a771a Added linear digital filters
7349c2c Fixing the frcsim installer script
c82122c Merge "Default bufLength for PIDController in Java should be 1"
58f3f97 Merge "Adds WaitResult to Java waitForInterrupt"
bc8ed12 HAL: Use extern "C" in implementation files.
4cac89e Default bufLength for PIDController in Java should be 1
64fcdcc Keep track of FPGA time rollovers with 64-bit time.
d30b283 Merge "Change C++ Notifier to allow std::function callback."
6ee3052 Merge "Rewrite C++ Notifier to use HAL multi-notifier support."
f5d09e2 Merge "Rewrite Java Notifier and update Interrupt JNI."
d0274aa Merge "Readded styleguide accidentally removed in the reorg"
68311ad Merge "Artf4179: Allow alternate I2C addresses for ADXL345_I2C"
dee12d4 Readded styleguide accidentally removed in the reorg
fa100df Fixed some typos in the comments of MotorEncoderFixture.java, a method name in CANMotorEncoderFixture.java, and the README files
3397b5c Adds WaitResult to Java waitForInterrupt
5f0dffd Artf4177: Use read byte count for ReadString
8564f33 Artf4179: Allow alternate I2C addresses for ADXL345_I2C
e52b52d Change C++ Notifier to allow std::function callback.
40b29e7 Rewrite C++ Notifier to use HAL multi-notifier support.
d126f45 Rewrite Java Notifier and update Interrupt JNI.
557805a Merge "finishing up FRCSim installer"
911b64b finishing up FRCSim installer
e24fe6f Merge "Artf4776 Fixes First DIO PWM usage errors"
f8f9284 Merge "Artf4774 Fixes HAL getHALErrorMessage missing error"
84428d5 Merge "Prevent double free in DigitalGlitchFilter"
a00a5ff Merge "Set correct error message"
9aeee98 Prevent double free in DigitalGlitchFilter
5d2186c working on install process for FRCSim 2016
7fdb616 Merge "This commit adds documentation generation, including grabbing ntcore sources, for both Java and C++. This will need changes made in the wpilib promotion tasks to copy the generatd documentation to the correct places."
f67ebca Improved READMEs
8a7c019 Artf4776 Fixes First DIO PWM usage errors
1cd2f9a Added libnipalu to make vision programs link properly
375b92a This commit adds documentation generation, including grabbing ntcore sources, for both Java and C++. This will need changes made in the wpilib promotion tasks to copy the generatd documentation to the correct places.
8d0a990 Set correct error message
b65401f Artf4774 Fixes HAL getHALErrorMessage missing error
5f918be Condition java sim build on -PmakeSim flag
53bd180 Merge "Add SPARK and SD540 motor controllers"
66cbe69 Fixed double free of DriverStation.
431f345 Repaired simulation build on linux
611593c Add Cmake wrappers and unzip desktop ntcore builds
51a18cd Add SPARK and SD540 motor controllers
c05e883 Merge changes I55ce71c6,I803680c1
2b80029 Rewrite CANTalon JNI layer.
ef4c45b Last feature addition for CANTalon java/C++ user-facing API.
Change-Id: Ia3a124978a426991890b6f8abbe07d34d75ba38d
git-subtree-dir: third_party/allwpilib_2016
git-subtree-split: 3ce6feb8acdeca46e93a55280fb6ace3a4d5bcd6
diff --git a/wpilibc/simulation/include/AnalogGyro.h b/wpilibc/simulation/include/AnalogGyro.h
new file mode 100644
index 0000000..e117330
--- /dev/null
+++ b/wpilibc/simulation/include/AnalogGyro.h
@@ -0,0 +1,50 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include "GyroBase.h"
+#include "simulation/SimGyro.h"
+
+#include <memory>
+
+class AnalogInput;
+class AnalogModule;
+
+/**
+ * Use a rate gyro to return the robots heading relative to a starting position.
+ * The AnalogGyro class tracks the robots heading based on the starting position. As the robot
+ * rotates the new heading is computed by integrating the rate of rotation returned
+ * by the sensor. When the class is instantiated, it does a short calibration routine
+ * where it samples the gyro while at rest to determine the default offset. This is
+ * subtracted from each sample to determine the heading. This gyro class must be used
+ * with a channel that is assigned one of the Analog accumulators from the FPGA. See
+ * AnalogInput for the current accumulator assignments.
+ */
+class AnalogGyro : public GyroBase
+{
+public:
+ static const uint32_t kOversampleBits;
+ static const uint32_t kAverageBits;
+ static const float kSamplesPerSecond;
+ static const float kCalibrationSampleTime;
+ static const float kDefaultVoltsPerDegreePerSecond;
+
+ explicit AnalogGyro(uint32_t channel);
+ virtual ~AnalogGyro() = default;
+ float GetAngle() const;
+ void Calibrate() override;
+ double GetRate() const;
+ void Reset();
+
+private:
+ void InitAnalogGyro(int channel);
+
+ SimGyro* impl;
+
+ std::shared_ptr<ITable> m_table;
+};
diff --git a/wpilibc/simulation/include/AnalogInput.h b/wpilibc/simulation/include/AnalogInput.h
index 59a3a85..8e857b4 100644
--- a/wpilibc/simulation/include/AnalogInput.h
+++ b/wpilibc/simulation/include/AnalogInput.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "simulation/SimFloatInput.h"
diff --git a/wpilibc/simulation/include/AnalogPotentiometer.h b/wpilibc/simulation/include/AnalogPotentiometer.h
index 786f36f..2dbcb3e 100644
--- a/wpilibc/simulation/include/AnalogPotentiometer.h
+++ b/wpilibc/simulation/include/AnalogPotentiometer.h
@@ -1,3 +1,10 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2016. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
+/*----------------------------------------------------------------------------*/
+
#pragma once
#include "AnalogInput.h"
diff --git a/wpilibc/simulation/include/Counter.h b/wpilibc/simulation/include/Counter.h
index 338efc0..2accacf 100644
--- a/wpilibc/simulation/include/Counter.h
+++ b/wpilibc/simulation/include/Counter.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "HAL/HAL.hpp"
diff --git a/wpilibc/simulation/include/CounterBase.h b/wpilibc/simulation/include/CounterBase.h
index 3352c29..683b681 100644
--- a/wpilibc/simulation/include/CounterBase.h
+++ b/wpilibc/simulation/include/CounterBase.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
/**
diff --git a/wpilibc/simulation/include/DigitalInput.h b/wpilibc/simulation/include/DigitalInput.h
index 1482e9c..92c4742 100644
--- a/wpilibc/simulation/include/DigitalInput.h
+++ b/wpilibc/simulation/include/DigitalInput.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "simulation/SimDigitalInput.h"
diff --git a/wpilibc/simulation/include/DoubleSolenoid.h b/wpilibc/simulation/include/DoubleSolenoid.h
index 122a439..ca38f1d 100644
--- a/wpilibc/simulation/include/DoubleSolenoid.h
+++ b/wpilibc/simulation/include/DoubleSolenoid.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "simulation/SimContinuousOutput.h"
diff --git a/wpilibc/simulation/include/DriverStation.h b/wpilibc/simulation/include/DriverStation.h
index f15985c..b96f1a7 100644
--- a/wpilibc/simulation/include/DriverStation.h
+++ b/wpilibc/simulation/include/DriverStation.h
@@ -1,112 +1,146 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
+#include "simulation/gz_msgs/msgs.h"
+
+#ifdef _WIN32
+ // Ensure that Winsock2.h is included before Windows.h, which can get
+ // pulled in by anybody (e.g., Boost).
+ #include <Winsock2.h>
+#endif
+
+#include <gazebo/transport/transport.hh>
#include "SensorBase.h"
#include "RobotState.h"
-#include "HAL/HAL.hpp"
-#include "HAL/cpp/Semaphore.hpp"
-#include "HAL/cpp/priority_mutex.h"
-#include "HAL/cpp/priority_condition_variable.h"
+#include <mutex>
#include <condition_variable>
-struct HALControlWord;
+struct HALCommonControlData;
class AnalogInput;
+using namespace gazebo;
+
/**
- * Provide access to the network communication data to / from the Driver
- * Station.
+ * Provide access to the network communication data to / from the Driver Station.
*/
-class DriverStation : public SensorBase, public RobotStateInterface {
- public:
- enum Alliance { kRed, kBlue, kInvalid };
+class DriverStation : public SensorBase, public RobotStateInterface
+{
+public:
+ enum Alliance
+ {
+ kRed,
+ kBlue,
+ kInvalid
+ };
- virtual ~DriverStation();
- static DriverStation &GetInstance();
- static void ReportError(std::string error);
+ virtual ~DriverStation() = default;
+ static DriverStation &GetInstance();
+ static void ReportError(std::string error);
+ static void ReportWarning(std::string error);
+ static void ReportError(bool is_error, int32_t code, const std::string& error, const std::string& location, const std::string& stack);
- static const uint32_t kJoystickPorts = 6;
+ static const uint32_t kBatteryChannel = 7;
+ static const uint32_t kJoystickPorts = 4;
+ static const uint32_t kJoystickAxes = 6;
- float GetStickAxis(uint32_t stick, uint32_t axis);
- int GetStickPOV(uint32_t stick, uint32_t pov);
- uint32_t GetStickButtons(uint32_t stick) const;
- bool GetStickButton(uint32_t stick, uint8_t button);
+ float GetStickAxis(uint32_t stick, uint32_t axis);
+ bool GetStickButton(uint32_t stick, uint32_t button);
+ short GetStickButtons(uint32_t stick);
- int GetStickAxisCount(uint32_t stick) const;
- int GetStickPOVCount(uint32_t stick) const;
- int GetStickButtonCount(uint32_t stick) const;
+ float GetAnalogIn(uint32_t channel);
+ bool GetDigitalIn(uint32_t channel);
+ void SetDigitalOut(uint32_t channel, bool value);
+ bool GetDigitalOut(uint32_t channel);
- bool GetJoystickIsXbox(uint32_t stick) const;
- int GetJoystickType(uint32_t stick) const;
- std::string GetJoystickName(uint32_t stick) const;
- int GetJoystickAxisType(uint32_t stick, uint8_t axis) const;
+ bool IsEnabled() const;
+ bool IsDisabled() const;
+ bool IsAutonomous() const;
+ bool IsOperatorControl() const;
+ bool IsTest() const;
+ bool IsFMSAttached() const;
- bool IsEnabled() const override;
- bool IsDisabled() const override;
- bool IsAutonomous() const override;
- bool IsOperatorControl() const override;
- bool IsTest() const override;
- bool IsDSAttached() const;
- bool IsNewControlData() const;
- bool IsFMSAttached() const;
- bool IsSysActive() const;
- bool IsSysBrownedOut() const;
+ uint32_t GetPacketNumber() const;
+ Alliance GetAlliance() const;
+ uint32_t GetLocation() const;
+ void WaitForData();
+ double GetMatchTime() const;
+ float GetBatteryVoltage() const;
+ uint16_t GetTeamNumber() const;
- Alliance GetAlliance() const;
- uint32_t GetLocation() const;
- void WaitForData();
- double GetMatchTime() const;
- float GetBatteryVoltage() const;
- /** Only to be used to tell the Driver Station what code you claim to be
- * executing
- * for diagnostic purposes only
- * @param entering If true, starting disabled code; if false, leaving disabled
- * code */
- void InDisabled(bool entering) { m_userInDisabled = entering; }
- /** Only to be used to tell the Driver Station what code you claim to be
- * executing
- * for diagnostic purposes only
- * @param entering If true, starting autonomous code; if false, leaving
- * autonomous code */
- void InAutonomous(bool entering) { m_userInAutonomous = entering; }
- /** Only to be used to tell the Driver Station what code you claim to be
- * executing
- * for diagnostic purposes only
- * @param entering If true, starting teleop code; if false, leaving teleop
- * code */
- void InOperatorControl(bool entering) { m_userInTeleop = entering; }
- /** Only to be used to tell the Driver Station what code you claim to be
- * executing
- * for diagnostic purposes only
- * @param entering If true, starting test code; if false, leaving test code */
- void InTest(bool entering) { m_userInTest = entering; }
- protected:
- DriverStation();
+ void IncrementUpdateNumber()
+ {
+ m_updateNumber++;
+ }
- void GetData();
+ /** Only to be used to tell the Driver Station what code you claim to be executing
+ * for diagnostic purposes only
+ * @param entering If true, starting disabled code; if false, leaving disabled code */
+ void InDisabled(bool entering)
+ {
+ m_userInDisabled = entering;
+ }
+ /** Only to be used to tell the Driver Station what code you claim to be executing
+ * for diagnostic purposes only
+ * @param entering If true, starting autonomous code; if false, leaving autonomous code */
+ void InAutonomous(bool entering)
+ {
+ m_userInAutonomous = entering;
+ }
+ /** Only to be used to tell the Driver Station what code you claim to be executing
+ * for diagnostic purposes only
+ * @param entering If true, starting teleop code; if false, leaving teleop code */
+ void InOperatorControl(bool entering)
+ {
+ m_userInTeleop = entering;
+ }
+ /** Only to be used to tell the Driver Station what code you claim to be executing
+ * for diagnostic purposes only
+ * @param entering If true, starting test code; if false, leaving test code */
+ void InTest(bool entering)
+ {
+ m_userInTest = entering;
+ }
- private:
- static DriverStation *m_instance;
- void ReportJoystickUnpluggedError(std::string message);
- void Run();
+protected:
+ DriverStation();
- HALJoystickAxes m_joystickAxes[kJoystickPorts];
- HALJoystickPOVs m_joystickPOVs[kJoystickPorts];
- HALJoystickButtons m_joystickButtons[kJoystickPorts];
- HALJoystickDescriptor m_joystickDescriptor[kJoystickPorts];
- mutable Semaphore m_newControlData{Semaphore::kEmpty};
- mutable priority_condition_variable m_packetDataAvailableCond;
- priority_mutex m_packetDataAvailableMutex;
- std::condition_variable_any m_waitForDataCond;
- priority_mutex m_waitForDataMutex;
- bool m_userInDisabled = false;
- bool m_userInAutonomous = false;
- bool m_userInTeleop = false;
- bool m_userInTest = false;
- double m_nextMessageTime = 0;
+private:
+ static void InitTask(DriverStation *ds);
+ static DriverStation *m_instance;
+ static uint8_t m_updateNumber;
+ ///< TODO: Get rid of this and use the semaphore signaling
+ static const float kUpdatePeriod;
+
+ void stateCallback(const msgs::ConstDriverStationPtr &msg);
+ void joystickCallback(const msgs::ConstFRCJoystickPtr &msg, int i);
+ void joystickCallback0(const msgs::ConstFRCJoystickPtr &msg);
+ void joystickCallback1(const msgs::ConstFRCJoystickPtr &msg);
+ void joystickCallback2(const msgs::ConstFRCJoystickPtr &msg);
+ void joystickCallback3(const msgs::ConstFRCJoystickPtr &msg);
+ void joystickCallback4(const msgs::ConstFRCJoystickPtr &msg);
+ void joystickCallback5(const msgs::ConstFRCJoystickPtr &msg);
+
+ uint8_t m_digitalOut = 0;
+ std::condition_variable m_waitForDataCond;
+ std::mutex m_waitForDataMutex;
+ mutable std::recursive_mutex m_stateMutex;
+ std::recursive_mutex m_joystickMutex;
+ double m_approxMatchTimeOffset = 0;
+ bool m_userInDisabled = false;
+ bool m_userInAutonomous = false;
+ bool m_userInTeleop = false;
+ bool m_userInTest = false;
+
+ transport::SubscriberPtr stateSub;
+ transport::SubscriberPtr joysticksSub[6];
+ msgs::DriverStationPtr state;
+ msgs::FRCJoystickPtr joysticks[6];
};
diff --git a/wpilibc/simulation/include/Encoder.h b/wpilibc/simulation/include/Encoder.h
index 89b1b3a..22b8657 100644
--- a/wpilibc/simulation/include/Encoder.h
+++ b/wpilibc/simulation/include/Encoder.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "simulation/SimEncoder.h"
diff --git a/wpilibc/simulation/include/Gyro.h b/wpilibc/simulation/include/Gyro.h
deleted file mode 100644
index 7e4e40a..0000000
--- a/wpilibc/simulation/include/Gyro.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
-/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
-/*----------------------------------------------------------------------------*/
-#pragma once
-
-#include "SensorBase.h"
-#include "PIDSource.h"
-#include "LiveWindow/LiveWindowSendable.h"
-#include "simulation/SimGyro.h"
-
-#include <memory>
-
-class AnalogInput;
-class AnalogModule;
-
-/**
- * Use a rate gyro to return the robots heading relative to a starting position.
- * The Gyro class tracks the robots heading based on the starting position. As the robot
- * rotates the new heading is computed by integrating the rate of rotation returned
- * by the sensor. When the class is instantiated, it does a short calibration routine
- * where it samples the gyro while at rest to determine the default offset. This is
- * subtracted from each sample to determine the heading. This gyro class must be used
- * with a channel that is assigned one of the Analog accumulators from the FPGA. See
- * AnalogInput for the current accumulator assignments.
- */
-class Gyro : public SensorBase, public PIDSource, public LiveWindowSendable
-{
-public:
- static const uint32_t kOversampleBits;
- static const uint32_t kAverageBits;
- static const float kSamplesPerSecond;
- static const float kCalibrationSampleTime;
- static const float kDefaultVoltsPerDegreePerSecond;
-
- explicit Gyro(uint32_t channel);
- virtual ~Gyro() = default;
- virtual float GetAngle() const;
- virtual double GetRate() const;
- virtual void Reset();
-
- // PIDSource interface
- void SetPIDSourceType(PIDSourceType pidSource) override;
- double PIDGet() override;
-
- void UpdateTable() override;
- void StartLiveWindowMode() override;
- void StopLiveWindowMode() override;
- std::string GetSmartDashboardType() const override;
- void InitTable(std::shared_ptr<ITable> subTable) override;
- std::shared_ptr<ITable> GetTable() const override;
-
-private:
- void InitGyro(int channel);
-
- SimGyro* impl;
-
- std::shared_ptr<ITable> m_table;
-};
diff --git a/wpilibc/simulation/include/IterativeRobot.h b/wpilibc/simulation/include/IterativeRobot.h
index 7c9104d..8a4cd4d 100644
--- a/wpilibc/simulation/include/IterativeRobot.h
+++ b/wpilibc/simulation/include/IterativeRobot.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "Timer.h"
diff --git a/wpilibc/simulation/include/Jaguar.h b/wpilibc/simulation/include/Jaguar.h
index 1f522d9..27325af 100644
--- a/wpilibc/simulation/include/Jaguar.h
+++ b/wpilibc/simulation/include/Jaguar.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "SafePWM.h"
diff --git a/wpilibc/simulation/include/Joystick.h b/wpilibc/simulation/include/Joystick.h
index 0922359..e4e46da 100644
--- a/wpilibc/simulation/include/Joystick.h
+++ b/wpilibc/simulation/include/Joystick.h
@@ -1,16 +1,14 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved.
- */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
#ifndef JOYSTICK_H_
#define JOYSTICK_H_
-#include <cstdint>
#include <memory>
-#include <vector>
#include "GenericHID.h"
#include "ErrorBase.h"
@@ -18,101 +16,64 @@
/**
* Handle input from standard Joysticks connected to the Driver Station.
- * This class handles standard input that comes from the Driver Station. Each
- * time a value is requested
- * the most recent value is returned. There is a single class instance for each
- * joystick and the mapping
+ * This class handles standard input that comes from the Driver Station. Each time a value is requested
+ * the most recent value is returned. There is a single class instance for each joystick and the mapping
* of ports to hardware buttons depends on the code in the driver station.
*/
-class Joystick : public GenericHID, public ErrorBase {
- public:
- static const uint32_t kDefaultXAxis = 0;
- static const uint32_t kDefaultYAxis = 1;
- static const uint32_t kDefaultZAxis = 2;
- static const uint32_t kDefaultTwistAxis = 2;
- static const uint32_t kDefaultThrottleAxis = 3;
- typedef enum {
- kXAxis,
- kYAxis,
- kZAxis,
- kTwistAxis,
- kThrottleAxis,
- kNumAxisTypes
- } AxisType;
- static const uint32_t kDefaultTriggerButton = 1;
- static const uint32_t kDefaultTopButton = 2;
- typedef enum { kTriggerButton, kTopButton, kNumButtonTypes } ButtonType;
- typedef enum { kLeftRumble, kRightRumble } RumbleType;
- typedef enum {
- kUnknown = -1,
- kXInputUnknown = 0,
- kXInputGamepad = 1,
- kXInputWheel = 2,
- kXInputArcadeStick = 3,
- kXInputFlightStick = 4,
- kXInputDancePad = 5,
- kXInputGuitar = 6,
- kXInputGuitar2 = 7,
- kXInputDrumKit = 8,
- kXInputGuitar3 = 11,
- kXInputArcadePad = 19,
- kHIDJoystick = 20,
- kHIDGamepad = 21,
- kHIDDriving = 22,
- kHIDFlight = 23,
- kHID1stPerson = 24
- } HIDType;
- explicit Joystick(uint32_t port);
- Joystick(uint32_t port, uint32_t numAxisTypes, uint32_t numButtonTypes);
- virtual ~Joystick() = default;
+class Joystick : public GenericHID, public ErrorBase
+{
+public:
+ static const uint32_t kDefaultXAxis = 1;
+ static const uint32_t kDefaultYAxis = 2;
+ static const uint32_t kDefaultZAxis = 3;
+ static const uint32_t kDefaultTwistAxis = 4;
+ static const uint32_t kDefaultThrottleAxis = 3;
+ typedef enum
+ {
+ kXAxis, kYAxis, kZAxis, kTwistAxis, kThrottleAxis, kNumAxisTypes
+ } AxisType;
+ static const uint32_t kDefaultTriggerButton = 1;
+ static const uint32_t kDefaultTopButton = 2;
+ typedef enum
+ {
+ kTriggerButton, kTopButton, kNumButtonTypes
+ } ButtonType;
- Joystick(const Joystick&) = delete;
- Joystick& operator=(const Joystick&) = delete;
+ explicit Joystick(uint32_t port);
+ Joystick(uint32_t port, uint32_t numAxisTypes, uint32_t numButtonTypes);
+ virtual ~Joystick() = default;
- uint32_t GetAxisChannel(AxisType axis) const;
- void SetAxisChannel(AxisType axis, uint32_t channel);
+ Joystick(const Joystick&) = delete;
+ Joystick& operator=(const Joystick&) = delete;
- virtual float GetX(JoystickHand hand = kRightHand) const override;
- virtual float GetY(JoystickHand hand = kRightHand) const override;
- virtual float GetZ() const override;
- virtual float GetTwist() const override;
- virtual float GetThrottle() const override;
- virtual float GetAxis(AxisType axis) const;
- float GetRawAxis(uint32_t axis) const override;
+ uint32_t GetAxisChannel(AxisType axis);
+ void SetAxisChannel(AxisType axis, uint32_t channel);
- virtual bool GetTrigger(JoystickHand hand = kRightHand) const override;
- virtual bool GetTop(JoystickHand hand = kRightHand) const override;
- virtual bool GetBumper(JoystickHand hand = kRightHand) const override;
- virtual bool GetRawButton(uint32_t button) const override;
- virtual int GetPOV(uint32_t pov = 0) const override;
- bool GetButton(ButtonType button) const;
- static Joystick *GetStickForPort(uint32_t port);
+ virtual float GetX(JoystickHand hand = kRightHand) const override;
+ virtual float GetY(JoystickHand hand = kRightHand) const override;
+ virtual float GetZ() const override;
+ virtual float GetTwist() const override;
+ virtual float GetThrottle() const override;
+ virtual float GetAxis(AxisType axis) const;
+ float GetRawAxis(uint32_t axis) const override;
- virtual float GetMagnitude() const;
- virtual float GetDirectionRadians() const;
- virtual float GetDirectionDegrees() const;
+ virtual bool GetTrigger(JoystickHand hand = kRightHand) const override;
+ virtual bool GetTop(JoystickHand hand = kRightHand) const override;
+ virtual bool GetBumper(JoystickHand hand = kRightHand) const override;
+ virtual bool GetRawButton(uint32_t button) const override;
+ virtual int GetPOV(uint32_t pov = 1) const override;
+ bool GetButton(ButtonType button) const;
+ static Joystick* GetStickForPort(uint32_t port);
- bool GetIsXbox() const;
- Joystick::HIDType GetType() const;
- std::string GetName() const;
- int GetAxisType(uint8_t axis) const;
+ virtual float GetMagnitude() const;
+ virtual float GetDirectionRadians() const;
+ virtual float GetDirectionDegrees() const;
- int GetAxisCount() const;
- int GetButtonCount() const;
- int GetPOVCount() const;
-
- void SetRumble(RumbleType type, float value);
- void SetOutput(uint8_t outputNumber, bool value);
- void SetOutputs(uint32_t value);
-
- private:
- DriverStation &m_ds;
- uint32_t m_port;
- ::std::vector<uint32_t> m_axes;
- ::std::vector<uint32_t> m_buttons;
- uint32_t m_outputs = 0;
- uint16_t m_leftRumble = 0;
- uint16_t m_rightRumble = 0;
+private:
+ DriverStation &m_ds;
+ uint32_t m_port;
+ std::unique_ptr<uint32_t[]> m_axes;
+ std::unique_ptr<uint32_t[]> m_buttons;
};
#endif
diff --git a/wpilibc/simulation/include/MotorSafety.h b/wpilibc/simulation/include/MotorSafety.h
index c718806..82c77d8 100644
--- a/wpilibc/simulation/include/MotorSafety.h
+++ b/wpilibc/simulation/include/MotorSafety.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#define DEFAULT_SAFETY_EXPIRATION 0.1
diff --git a/wpilibc/simulation/include/MotorSafetyHelper.h b/wpilibc/simulation/include/MotorSafetyHelper.h
index bbe7658..f124605 100644
--- a/wpilibc/simulation/include/MotorSafetyHelper.h
+++ b/wpilibc/simulation/include/MotorSafetyHelper.h
@@ -1,9 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved.
- */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "ErrorBase.h"
diff --git a/wpilibc/simulation/include/Notifier.h b/wpilibc/simulation/include/Notifier.h
new file mode 100644
index 0000000..0160aa4
--- /dev/null
+++ b/wpilibc/simulation/include/Notifier.h
@@ -0,0 +1,72 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <atomic>
+#include <functional>
+#include <list>
+#include <thread>
+
+#include "ErrorBase.h"
+#include "HAL/cpp/priority_mutex.h"
+
+typedef std::function<void()> TimerEventHandler;
+
+class Notifier : public ErrorBase {
+ public:
+ explicit Notifier(TimerEventHandler handler);
+
+ template <typename Callable, typename Arg, typename... Args>
+ Notifier(Callable&& f, Arg&& arg, Args&&... args)
+ : Notifier(std::bind(std::forward<Callable>(f),
+ std::forward<Arg>(arg),
+ std::forward<Args>(args)...)) {}
+ virtual ~Notifier();
+
+ Notifier(const Notifier&) = delete;
+ Notifier& operator=(const Notifier&) = delete;
+
+ void StartSingle(double delay);
+ void StartPeriodic(double period);
+ void Stop();
+
+ private:
+ static std::list<Notifier*> timerQueue;
+ static priority_recursive_mutex queueMutex;
+ static priority_mutex halMutex;
+ static void *m_notifier;
+ static std::atomic<int> refcount;
+
+ // Process the timer queue on a timer event
+ static void ProcessQueue(uint32_t mask, void *params);
+
+ // Update the FPGA alarm since the queue has changed
+ static void UpdateAlarm();
+
+ // Insert the Notifier in the timer queue
+ void InsertInQueue(bool reschedule);
+
+ // Delete this Notifier from the timer queue
+ void DeleteFromQueue();
+
+ // Address of the handler
+ TimerEventHandler m_handler;
+ // The relative time (either periodic or single)
+ double m_period = 0;
+ // Absolute expiration time for the current event
+ double m_expirationTime = 0;
+ // True if this is a periodic event
+ bool m_periodic = false;
+ // Indicates if this entry is queued
+ bool m_queued = false;
+ // Held by interrupt manager task while handler call is in progress
+ priority_mutex m_handlerMutex;
+ static std::thread m_task;
+ static std::atomic<bool> m_stopped;
+ static void Run();
+};
diff --git a/wpilibc/simulation/include/PWM.h b/wpilibc/simulation/include/PWM.h
index 52007fb..bc0b7da 100644
--- a/wpilibc/simulation/include/PWM.h
+++ b/wpilibc/simulation/include/PWM.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "SensorBase.h"
diff --git a/wpilibc/simulation/include/Relay.h b/wpilibc/simulation/include/Relay.h
index abc9ad5..5a1c680 100644
--- a/wpilibc/simulation/include/Relay.h
+++ b/wpilibc/simulation/include/Relay.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "MotorSafety.h"
diff --git a/wpilibc/simulation/include/RobotBase.h b/wpilibc/simulation/include/RobotBase.h
index a88dbb2..ff9c015 100644
--- a/wpilibc/simulation/include/RobotBase.h
+++ b/wpilibc/simulation/include/RobotBase.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "Base.h"
@@ -47,6 +49,7 @@
RobotBase& operator=(const RobotBase&) = delete;
DriverStation &m_ds;
+ transport::SubscriberPtr time_sub;
private:
static RobotBase *m_instance;
diff --git a/wpilibc/simulation/include/RobotDrive.h b/wpilibc/simulation/include/RobotDrive.h
index a181e46..8e9f8ca 100644
--- a/wpilibc/simulation/include/RobotDrive.h
+++ b/wpilibc/simulation/include/RobotDrive.h
@@ -1,12 +1,15 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "ErrorBase.h"
#include <stdlib.h>
+#include <memory>
#include "MotorSafety.h"
#include "MotorSafetyHelper.h"
@@ -37,11 +40,17 @@
uint32_t frontRightMotorChannel, uint32_t rearRightMotorChannel);
RobotDrive(SpeedController *leftMotor, SpeedController *rightMotor);
RobotDrive(SpeedController &leftMotor, SpeedController &rightMotor);
+ RobotDrive(std::shared_ptr<SpeedController> leftMotor,
+ std::shared_ptr<SpeedController> rightMotor);
RobotDrive(SpeedController *frontLeftMotor, SpeedController *rearLeftMotor,
SpeedController *frontRightMotor, SpeedController *rearRightMotor);
RobotDrive(SpeedController &frontLeftMotor, SpeedController &rearLeftMotor,
SpeedController &frontRightMotor, SpeedController &rearRightMotor);
- virtual ~RobotDrive();
+ RobotDrive(std::shared_ptr<SpeedController> frontLeftMotor,
+ std::shared_ptr<SpeedController> rearLeftMotor,
+ std::shared_ptr<SpeedController> frontRightMotor,
+ std::shared_ptr<SpeedController> rearRightMotor);
+ virtual ~RobotDrive() = default;
RobotDrive(const RobotDrive&) = delete;
RobotDrive& operator=(const RobotDrive&) = delete;
@@ -85,14 +94,14 @@
static const int32_t kMaxNumberOfMotors = 4;
- int32_t m_invertedMotors[kMaxNumberOfMotors];
+ int32_t m_invertedMotors[kMaxNumberOfMotors] = {1,1,1,1};
float m_sensitivity = 0.5;
double m_maxOutput = 1.0;
bool m_deleteSpeedControllers;
- SpeedController *m_frontLeftMotor = nullptr;
- SpeedController *m_frontRightMotor = nullptr;
- SpeedController *m_rearLeftMotor = nullptr;
- SpeedController *m_rearRightMotor = nullptr;
+ std::shared_ptr<SpeedController> m_frontLeftMotor;
+ std::shared_ptr<SpeedController> m_frontRightMotor;
+ std::shared_ptr<SpeedController> m_rearLeftMotor;
+ std::shared_ptr<SpeedController> m_rearRightMotor;
// FIXME: MotorSafetyHelper *m_safetyHelper;
private:
diff --git a/wpilibc/simulation/include/SafePWM.h b/wpilibc/simulation/include/SafePWM.h
index 577d853..4787cee 100644
--- a/wpilibc/simulation/include/SafePWM.h
+++ b/wpilibc/simulation/include/SafePWM.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "MotorSafety.h"
diff --git a/wpilibc/simulation/include/SampleRobot.h b/wpilibc/simulation/include/SampleRobot.h
index 38cb37d..a87bb4e 100644
--- a/wpilibc/simulation/include/SampleRobot.h
+++ b/wpilibc/simulation/include/SampleRobot.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "RobotBase.h"
diff --git a/wpilibc/simulation/include/Solenoid.h b/wpilibc/simulation/include/Solenoid.h
index b91da6e..4f6ac3a 100644
--- a/wpilibc/simulation/include/Solenoid.h
+++ b/wpilibc/simulation/include/Solenoid.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "simulation/SimContinuousOutput.h"
diff --git a/wpilibc/simulation/include/SpeedController.h b/wpilibc/simulation/include/SpeedController.h
index 96b6b17..e665d06 100644
--- a/wpilibc/simulation/include/SpeedController.h
+++ b/wpilibc/simulation/include/SpeedController.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "PIDOutput.h"
diff --git a/wpilibc/simulation/include/Talon.h b/wpilibc/simulation/include/Talon.h
index 4b7794a..d56d5ba 100644
--- a/wpilibc/simulation/include/Talon.h
+++ b/wpilibc/simulation/include/Talon.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "SafePWM.h"
diff --git a/wpilibc/simulation/include/Victor.h b/wpilibc/simulation/include/Victor.h
index b629bb4..ef3646e 100644
--- a/wpilibc/simulation/include/Victor.h
+++ b/wpilibc/simulation/include/Victor.h
@@ -1,8 +1,10 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved. */
+/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
/*----------------------------------------------------------------------------*/
+
#pragma once
#include "SafePWM.h"
diff --git a/wpilibc/simulation/include/WPILib.h b/wpilibc/simulation/include/WPILib.h
index b3477d4..d4e9bf2 100644
--- a/wpilibc/simulation/include/WPILib.h
+++ b/wpilibc/simulation/include/WPILib.h
@@ -47,7 +47,7 @@
#include "Counter.h"
#include "DigitalInput.h"
#include "Encoder.h"
-#include "Gyro.h"
+#include "AnalogGyro.h"
#include "GenericHID.h"
#include "Joystick.h"
#include "PIDController.h"
diff --git a/wpilibc/simulation/include/simulation/MainNode.h b/wpilibc/simulation/include/simulation/MainNode.h
index a76ef50..416c7a5 100644
--- a/wpilibc/simulation/include/simulation/MainNode.h
+++ b/wpilibc/simulation/include/simulation/MainNode.h
@@ -1,3 +1,9 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
+/*----------------------------------------------------------------------------*/
#ifndef _SIM_MAIN_NODE_H
#define _SIM_MAIN_NODE_H
@@ -39,10 +45,16 @@
transport::NodePtr main;
private:
MainNode() {
- gazebo::client::setup();
- main = transport::NodePtr(new transport::Node());
- main->Init("frc");
- gazebo::transport::run();
+ bool success = gazebo::client::setup();
+
+ if (success){
+ main = transport::NodePtr(new transport::Node());
+ main->Init("frc");
+ gazebo::transport::run();
+ }
+ else {
+ std::cout << "An error has occured setting up gazebo_client!" << std::endl;
+ }
}
};
diff --git a/wpilibc/simulation/include/simulation/SimContinuousOutput.h b/wpilibc/simulation/include/simulation/SimContinuousOutput.h
index 06a28e9..2c0d5da 100644
--- a/wpilibc/simulation/include/simulation/SimContinuousOutput.h
+++ b/wpilibc/simulation/include/simulation/SimContinuousOutput.h
@@ -1,3 +1,9 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
+/*----------------------------------------------------------------------------*/
#ifndef _SIM_SPEED_CONTROLLER_H
diff --git a/wpilibc/simulation/include/simulation/SimDigitalInput.h b/wpilibc/simulation/include/simulation/SimDigitalInput.h
index c85c19f..ca14b0f 100644
--- a/wpilibc/simulation/include/simulation/SimDigitalInput.h
+++ b/wpilibc/simulation/include/simulation/SimDigitalInput.h
@@ -1,3 +1,9 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
+/*----------------------------------------------------------------------------*/
#ifndef _SIM_DIGITAL_INPUT_H
diff --git a/wpilibc/simulation/include/simulation/SimEncoder.h b/wpilibc/simulation/include/simulation/SimEncoder.h
index 9f37723..254cbe4 100644
--- a/wpilibc/simulation/include/simulation/SimEncoder.h
+++ b/wpilibc/simulation/include/simulation/SimEncoder.h
@@ -1,3 +1,9 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
+/*----------------------------------------------------------------------------*/
#ifndef _SIM_ENCODER_H
diff --git a/wpilibc/simulation/include/simulation/SimFloatInput.h b/wpilibc/simulation/include/simulation/SimFloatInput.h
index 6271b96..bdc1c4c 100644
--- a/wpilibc/simulation/include/simulation/SimFloatInput.h
+++ b/wpilibc/simulation/include/simulation/SimFloatInput.h
@@ -1,3 +1,9 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
+/*----------------------------------------------------------------------------*/
#ifndef _SIM_FLOAT_INPUT_H
diff --git a/wpilibc/simulation/include/simulation/SimGyro.h b/wpilibc/simulation/include/simulation/SimGyro.h
index fcb81f6..85d9d27 100644
--- a/wpilibc/simulation/include/simulation/SimGyro.h
+++ b/wpilibc/simulation/include/simulation/SimGyro.h
@@ -1,3 +1,9 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
+/*----------------------------------------------------------------------------*/
#ifndef _SIM_GYRO_H
diff --git a/wpilibc/simulation/include/simulation/simTime.h b/wpilibc/simulation/include/simulation/simTime.h
index 20fe0c5..bd87ffa 100644
--- a/wpilibc/simulation/include/simulation/simTime.h
+++ b/wpilibc/simulation/include/simulation/simTime.h
@@ -1,3 +1,10 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
+/*----------------------------------------------------------------------------*/
+
#pragma once