Initial commit of the WPILib simulation support in an alpha quality state.
Fixes to deal with the switch to .hpp files in the HAL and other misc problems due to rebasing.
Added Omar's changes to the compressor interface
Fixes to make C++ plugin compile on linux.
Added import of the WPILibSim code from the graduate class. It shows up as wpilibJavaSim to follow the convention set by wpilibJava, wpilibJavaJNI and wpilibJavaFinal.
Fixed wpilibJavaSim artifactId to mirror the new convention.
Modified the build of the java plugin to pull in the simulation dependencies.
Added stacktrace printing.
Fixed support for creating projects.
Added support for the isReal() and isSimulation() methods along with the AnalogPotentiometer object to support simulating GearsBot.
Added support for a "WPILib Simulate" button.
Added GearsBot to the built in examples.
Added support for specifying the world file during project creation and switched the default from BluntObjectBot to GearsBot.
Removed unused import.
Added file browser for world files.
Added support for debugging in simulation.
Change simulate icon to be a Gazebo icon.
Switched over to the gazebo messaging system.
Updated location of default world file.
Reverted cmake change.
Fixed bug in WPILibJSim, added better logging and cleaned up code.
Made the frc_gazebo_plugin build using raw cmake instead of catkin, breaking the final ROS dependencies.
Added installation to frc_gazebo_plugin Makefile.
Fixed running of simulation to actually use frcsim.
Initial commit of simulation library for C++. Has the minimal subset of features necessary for having a Simple Robot run in teleoperated mode.
Added notes for generating protobuf messages.
Import of the debuild process into the main repository.
Moved frc_gazebo_plugin under simulation and removed the gazebo folder.
Updated the gazebo plugin to remove excessive printing and limit motor signal to [-1,1].
Updated WPILibJSim to support latching messages and to sleep for 20ms in iterative robot.
Reduced delay between starting frcsim and the users program to 1 second.
Updated GearsBot example.
Fixed a few minor issues for demoable state.
Added simulator support for Victors, Jaguars and Talons.
Added NetworkTables, SmartDashboard and LiveWindow to the simulator.
Added AnalogPotentiometer for simulation.
Added support for simulating encoders.
Added simulation support for Gyro.
Added IterativeRobot, Fixed Timers, Notifiers, PIDControllers and other minor fixes + cleanup.
Added RobotDrive support to simulation.
Separated out JavaGazebo so that SimDS will be able to reuse it.
Separated out SimDS into its own application..
Fixes so that the SimDS is distributed and runs properly for Java with the eclipse plugins.
Added DriverStation support to WPILibCSim
Cleanup of DriverStation, WaitUntilCommand and AnalogPotentiometer for WPILibCSim.
Cleanup of includes for WPILibCSim
Added AnalogPotentiometer to the real WPILibC.
Added AnalogPotentiometer to the real WPILibC.
Added GearsBot example to C++ eclipse plugin.
WPILibCSim fixes to work with launching from the plugin.
Package libwpilibsim in a deb file.
Added includes to plugin distribution.
Added support for external-limit-switches to Gazebo, Java and C++.
Added support for Gazebo Rangefinders and Analog channels to read their values in C++ and Java.
Added support for internal limit switches.
Updated GearsBot programs to use limit switches + range finders.
Added disabling of motors when robot is disabled to more closely mimic the real robot.
Fixes to deal with the switch to .hpp files in the HAL and other misc problems due to rebasing.
Change-Id: I624c5f4d0f28282616a7c92083575bf68adcdce2
2014-06-12 11:02:26 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* 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. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "Victor.h"
|
|
|
|
|
|
|
|
|
|
#include "LiveWindow/LiveWindow.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Common initialization code called by all constructors.
|
|
|
|
|
*
|
|
|
|
|
* Note that the Victor uses the following bounds for PWM values. These values were determined
|
|
|
|
|
* empirically and optimized for the Victor 888. These values should work reasonably well for
|
|
|
|
|
* Victor 884 controllers as well but if users experience issues such as asymmetric behavior around
|
|
|
|
|
* the deadband or inability to saturate the controller in either direction, calibration is recommended.
|
|
|
|
|
* The calibration procedure can be found in the Victor 884 User Manual available from IFI.
|
|
|
|
|
*
|
|
|
|
|
* - 206 = full "forward"
|
|
|
|
|
* - 131 = the "high end" of the deadband range
|
|
|
|
|
* - 128 = center of the deadband range (off)
|
|
|
|
|
* - 125 = the "low end" of the deadband range
|
|
|
|
|
* - 56 = full "reverse"
|
|
|
|
|
*/
|
|
|
|
|
void Victor::InitVictor(int slot, int channel) {
|
|
|
|
|
char buffer[50];
|
|
|
|
|
int n = sprintf(buffer, "pwm/%d/%d", slot, channel);
|
2014-06-23 11:51:34 -07:00
|
|
|
impl = new SimContinuousOutput(buffer);
|
Initial commit of the WPILib simulation support in an alpha quality state.
Fixes to deal with the switch to .hpp files in the HAL and other misc problems due to rebasing.
Added Omar's changes to the compressor interface
Fixes to make C++ plugin compile on linux.
Added import of the WPILibSim code from the graduate class. It shows up as wpilibJavaSim to follow the convention set by wpilibJava, wpilibJavaJNI and wpilibJavaFinal.
Fixed wpilibJavaSim artifactId to mirror the new convention.
Modified the build of the java plugin to pull in the simulation dependencies.
Added stacktrace printing.
Fixed support for creating projects.
Added support for the isReal() and isSimulation() methods along with the AnalogPotentiometer object to support simulating GearsBot.
Added support for a "WPILib Simulate" button.
Added GearsBot to the built in examples.
Added support for specifying the world file during project creation and switched the default from BluntObjectBot to GearsBot.
Removed unused import.
Added file browser for world files.
Added support for debugging in simulation.
Change simulate icon to be a Gazebo icon.
Switched over to the gazebo messaging system.
Updated location of default world file.
Reverted cmake change.
Fixed bug in WPILibJSim, added better logging and cleaned up code.
Made the frc_gazebo_plugin build using raw cmake instead of catkin, breaking the final ROS dependencies.
Added installation to frc_gazebo_plugin Makefile.
Fixed running of simulation to actually use frcsim.
Initial commit of simulation library for C++. Has the minimal subset of features necessary for having a Simple Robot run in teleoperated mode.
Added notes for generating protobuf messages.
Import of the debuild process into the main repository.
Moved frc_gazebo_plugin under simulation and removed the gazebo folder.
Updated the gazebo plugin to remove excessive printing and limit motor signal to [-1,1].
Updated WPILibJSim to support latching messages and to sleep for 20ms in iterative robot.
Reduced delay between starting frcsim and the users program to 1 second.
Updated GearsBot example.
Fixed a few minor issues for demoable state.
Added simulator support for Victors, Jaguars and Talons.
Added NetworkTables, SmartDashboard and LiveWindow to the simulator.
Added AnalogPotentiometer for simulation.
Added support for simulating encoders.
Added simulation support for Gyro.
Added IterativeRobot, Fixed Timers, Notifiers, PIDControllers and other minor fixes + cleanup.
Added RobotDrive support to simulation.
Separated out JavaGazebo so that SimDS will be able to reuse it.
Separated out SimDS into its own application..
Fixes so that the SimDS is distributed and runs properly for Java with the eclipse plugins.
Added DriverStation support to WPILibCSim
Cleanup of DriverStation, WaitUntilCommand and AnalogPotentiometer for WPILibCSim.
Cleanup of includes for WPILibCSim
Added AnalogPotentiometer to the real WPILibC.
Added AnalogPotentiometer to the real WPILibC.
Added GearsBot example to C++ eclipse plugin.
WPILibCSim fixes to work with launching from the plugin.
Package libwpilibsim in a deb file.
Added includes to plugin distribution.
Added support for external-limit-switches to Gazebo, Java and C++.
Added support for Gazebo Rangefinders and Analog channels to read their values in C++ and Java.
Added support for internal limit switches.
Updated GearsBot programs to use limit switches + range finders.
Added disabling of motors when robot is disabled to more closely mimic the real robot.
Fixes to deal with the switch to .hpp files in the HAL and other misc problems due to rebasing.
Change-Id: I624c5f4d0f28282616a7c92083575bf68adcdce2
2014-06-12 11:02:26 -07:00
|
|
|
|
|
|
|
|
// TODO: LiveWindow::GetInstance()->AddActuator("Victor", slot, channel, this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor that assumes the default digital module.
|
|
|
|
|
*
|
|
|
|
|
* @param channel The PWM channel on the digital module that the Victor is attached to.
|
|
|
|
|
*/
|
|
|
|
|
Victor::Victor(uint32_t channel)
|
|
|
|
|
{
|
|
|
|
|
InitVictor(1, channel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor that specifies the digital module.
|
|
|
|
|
*
|
|
|
|
|
* @param moduleNumber The digital module (1 or 2).
|
|
|
|
|
* @param channel The PWM channel on the digital module that the Victor is attached to (1..10).
|
|
|
|
|
*/
|
|
|
|
|
Victor::Victor(uint8_t moduleNumber, uint32_t channel)
|
|
|
|
|
{
|
|
|
|
|
InitVictor(moduleNumber, channel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Victor::~Victor()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the PWM value.
|
|
|
|
|
*
|
|
|
|
|
* 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 value between -1.0 and 1.0 to set.
|
|
|
|
|
* @param syncGroup Unused interface.
|
|
|
|
|
*/
|
|
|
|
|
void Victor::Set(float speed, uint8_t syncGroup)
|
|
|
|
|
{
|
|
|
|
|
impl->Set(speed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the recently set value of the PWM.
|
|
|
|
|
*
|
|
|
|
|
* @return The most recently set value for the PWM between -1.0 and 1.0.
|
|
|
|
|
*/
|
|
|
|
|
float Victor::Get()
|
|
|
|
|
{
|
|
|
|
|
return impl->Get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Common interface for disabling a motor.
|
|
|
|
|
*/
|
|
|
|
|
void Victor::Disable()
|
|
|
|
|
{
|
2014-06-23 11:51:34 -07:00
|
|
|
impl->Set(0);
|
Initial commit of the WPILib simulation support in an alpha quality state.
Fixes to deal with the switch to .hpp files in the HAL and other misc problems due to rebasing.
Added Omar's changes to the compressor interface
Fixes to make C++ plugin compile on linux.
Added import of the WPILibSim code from the graduate class. It shows up as wpilibJavaSim to follow the convention set by wpilibJava, wpilibJavaJNI and wpilibJavaFinal.
Fixed wpilibJavaSim artifactId to mirror the new convention.
Modified the build of the java plugin to pull in the simulation dependencies.
Added stacktrace printing.
Fixed support for creating projects.
Added support for the isReal() and isSimulation() methods along with the AnalogPotentiometer object to support simulating GearsBot.
Added support for a "WPILib Simulate" button.
Added GearsBot to the built in examples.
Added support for specifying the world file during project creation and switched the default from BluntObjectBot to GearsBot.
Removed unused import.
Added file browser for world files.
Added support for debugging in simulation.
Change simulate icon to be a Gazebo icon.
Switched over to the gazebo messaging system.
Updated location of default world file.
Reverted cmake change.
Fixed bug in WPILibJSim, added better logging and cleaned up code.
Made the frc_gazebo_plugin build using raw cmake instead of catkin, breaking the final ROS dependencies.
Added installation to frc_gazebo_plugin Makefile.
Fixed running of simulation to actually use frcsim.
Initial commit of simulation library for C++. Has the minimal subset of features necessary for having a Simple Robot run in teleoperated mode.
Added notes for generating protobuf messages.
Import of the debuild process into the main repository.
Moved frc_gazebo_plugin under simulation and removed the gazebo folder.
Updated the gazebo plugin to remove excessive printing and limit motor signal to [-1,1].
Updated WPILibJSim to support latching messages and to sleep for 20ms in iterative robot.
Reduced delay between starting frcsim and the users program to 1 second.
Updated GearsBot example.
Fixed a few minor issues for demoable state.
Added simulator support for Victors, Jaguars and Talons.
Added NetworkTables, SmartDashboard and LiveWindow to the simulator.
Added AnalogPotentiometer for simulation.
Added support for simulating encoders.
Added simulation support for Gyro.
Added IterativeRobot, Fixed Timers, Notifiers, PIDControllers and other minor fixes + cleanup.
Added RobotDrive support to simulation.
Separated out JavaGazebo so that SimDS will be able to reuse it.
Separated out SimDS into its own application..
Fixes so that the SimDS is distributed and runs properly for Java with the eclipse plugins.
Added DriverStation support to WPILibCSim
Cleanup of DriverStation, WaitUntilCommand and AnalogPotentiometer for WPILibCSim.
Cleanup of includes for WPILibCSim
Added AnalogPotentiometer to the real WPILibC.
Added AnalogPotentiometer to the real WPILibC.
Added GearsBot example to C++ eclipse plugin.
WPILibCSim fixes to work with launching from the plugin.
Package libwpilibsim in a deb file.
Added includes to plugin distribution.
Added support for external-limit-switches to Gazebo, Java and C++.
Added support for Gazebo Rangefinders and Analog channels to read their values in C++ and Java.
Added support for internal limit switches.
Updated GearsBot programs to use limit switches + range finders.
Added disabling of motors when robot is disabled to more closely mimic the real robot.
Fixes to deal with the switch to .hpp files in the HAL and other misc problems due to rebasing.
Change-Id: I624c5f4d0f28282616a7c92083575bf68adcdce2
2014-06-12 11:02:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
|
|
|
|
void Victor::PIDWrite(float output)
|
|
|
|
|
{
|
|
|
|
|
Set(output);
|
|
|
|
|
}
|
|
|
|
|
|