diff --git a/.gitignore b/.gitignore index b72e166cc7..90fdfbc8da 100644 --- a/.gitignore +++ b/.gitignore @@ -179,8 +179,11 @@ __pycache__ # PDT-specific .buildpath -# sbteclipse plugin +# sbteclipse plugin .target # TeXlipse plugin .texlipse + +#catkin stuff +package.xml diff --git a/Building.md b/Building.md index ac2eb42e20..1978a4d982 100644 --- a/Building.md +++ b/Building.md @@ -1,30 +1,47 @@ -Building everything requires Maven -mvn package -DembeddedJDKHome=/home/patrick/Downloads/arm-jdk1.7.0_45/ -TODO... Explain maven.... -TODO.. how to import into eclipse correctly... +Building everything requires Maven, and the arm jdk -Building C++ only ------------------- +To build eclipse plugins (also build wpilibc/j) +======================== +./gradlew eclipsePlugins //this is what is most often used -C++ requires cmake if not run from maven, and is much faster. -Make a new directory and then run: -``` -mkdir build && cd build -cmake .. -DCMAKE_TOOLCHAIN_FILE=../arm-toolchain.cmake -G "MSYS Makefiles" -make # multicore add -j(num of cpu cores + 1), so -j3 on dual core for faster compile -make install DESTDIR=/some/dir/you/want/to/put/all/headers/and/libs #optional -`` +other possible targets are "build" or "frcuserprogram" -Note that you will receive a warning about libstdc++, but the build should complete successfully -Alternatively, if you like IDEs, you can import it directly into QtDeveloper, or a number of other IDEs such as Code::Blocks or Eclipse. See CMake documentation for details. -Eclipse demo: -``` -cd .. -mkdir build && cd build -cmake -DCMAKE_TOOLCHAIN_FILE=../allwpilib/arm-toolchain.cmake .. -G "Eclipse CDT4 - Unix Makefiles" -``` -and then import that directory into eclipse. Eclipse will detect a CDT project and standard tools will work. +To build on CMake Projects (gz_msgs, frc_gazebo_plugins, WPILIbC++Sim +========================= + //STARTING FROM ALLWPILIB DIRECTORY + $> mkdir build + $> cd build + + // on linux + $> cmake .. && make -j4 + + // on windows + $> ..\configure.bat + $> jom + +## You can build subprojects of CMake stuff +To find all of them, you can navigate to "build" and type "make " +Examples: + make WPILibC++Sim + make dc_motor + make gz_msgs + make clean + +## Note: For the latest version of FRCSim that uses the NI Driverstation, there is a circular dependency between CMake and Gradle projects. + wpilibc++sim depends on hal which is gradle, but eclipse plugins depends on wpilibc++sim which is cmake + so if you want everything to work nicely, run: + ./gradlew :hal:build + mkdir build; cd build //if you haven't already done so + cmake .. && make -j4 + ./gradlew eclipsePlugins //or whatever else + +Other gradle options +======================== +./gradlew tasks //list some available tasks + +TODO: Explain maven.... +TODO: how to import into eclipse correctly... GCC versions ------------ diff --git a/CMakeLists.txt b/CMakeLists.txt index b18a7fb550..45bc24cb53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,20 +1,59 @@ cmake_minimum_required(VERSION 2.8) -project(All-WPILib) -set(CMAKE_BUILD_TYPE Debug) -# TODO: When the compiler allows us to actually call deprecated functions from -# within deprecated functions, remove -Wno-error=deprecated-declarations -# (this will cause calling deprecated functions to be treated as a warning -# rather than an error). -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-error=deprecated-declarations -fPIC") +project(AllC++Sim) -file(GLOB_RECURSE NI_LIBS ni-libraries/*.so*) -list(REMOVE_ITEM NI_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/ni-libraries/libwpi.so ${CMAKE_CURRENT_SOURCE_DIR}/ni-libraries/libwpi_2015.so) -SET(WPI_LD_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/ni-libraries/libwpi.so ${CMAKE_CURRENT_SOURCE_DIR}/ni-libraries/libwpi_2015.so) -get_filename_component(WPILIB_INCLUDES wpilibc/wpilibC++/include REALPATH) -get_filename_component(HAL_API_INCLUDES hal/include REALPATH) -get_filename_component(NWT_API_INCLUDES networktables/cpp/include REALPATH) -file(GLOB_RECURSE COM_SRC_FILES wpilibc/wpilibC++/src/*.cpp) +include(CheckCXXCompilerFlag) +include (FindPkgConfig) +include(GNUInstallDirs) -add_subdirectory(hal) -add_subdirectory(networktables/cpp) -add_subdirectory(wpilibc) +#copied from GazeboUtils.cmake +macro (APPEND_TO_CACHED_STRING _string _cacheDesc) + FOREACH (newItem ${ARGN}) + SET (${_string} "${${_string}} ${newItem}" CACHE INTERNAL ${_cacheDesc} FORCE) + ENDFOREACH (newItem ${ARGN}) +endmacro (APPEND_TO_CACHED_STRING) + +#check for depenedencies +find_package(gazebo REQUIRED) +find_package(Boost COMPONENTS system filesystem REQUIRED) +find_package(Protobuf REQUIRED) + +if (NOT PROTOBUF_FOUND) + MESSAGE ("Missing: Google Protobuf (libprotobuf-dev)") +endif() +if (NOT PROTOBUF_PROTOC_EXECUTABLE) + MESSAGE ( "Missing: Google Protobuf Compiler (protobuf-compiler)") +endif() +if (NOT PROTOBUF_PROTOC_LIBRARY) + MESSAGE ("Missing: Google Protobuf Compiler Library (libprotoc-dev)") +endif() + +#on windows we produce .dlls with no prefix +if(WIN32) + #allows us to define constexpr and noexcept in macros + #since msvc 2013 doesn't support them + add_definitions(-D_ALLOW_KEYWORD_MACROS) + + # defines things like M_PI + add_definitions(-D_USE_MATH_DEFINES) + + # get rid of min max macros on windows + add_definitions(-DNOMINMAX) + + # aww yea + add_definitions(-DWIN32_LEAN_AND_MEAN) + + SET(CMAKE_FIND_LIBRARY_PREFIXES "") + SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll") +endif() + +if (MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFRC_SIMULATOR /MDd /Zi") +else () + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -DFRC_SIMULATOR -Wno-unused-parameter -pthread -fPIC -fpermissive") +endif() + + +include_directories("build") +add_subdirectory(simulation/gz_msgs) +add_subdirectory(wpilibc/wpilibC++Sim) +add_subdirectory(simulation/frc_gazebo_plugins) diff --git a/cmake/.gitignore b/cmake/.gitignore deleted file mode 100644 index 535c157308..0000000000 --- a/cmake/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -target/ \ No newline at end of file diff --git a/cmake/pom.xml b/cmake/pom.xml deleted file mode 100644 index d1730d87ce..0000000000 --- a/cmake/pom.xml +++ /dev/null @@ -1,151 +0,0 @@ - - - 4.0.0 - edu.wpi.first.wpilib.cmake - cpp-root - 1.0.0 - pom - - - unix-properties - - Unix Makefiles - - - - unix - - - - - MAC-properties - - Unix Makefiles - - - - mac - - - - - windows-properties - - MSYS Makefiles - - - - windows - - - - - - - - com.googlecode.cmake-maven-project - cmake-maven-plugin - 2.8.11-b4 - - - cmake - generate-resources - - generate - - - - - - - - - - cmake2 - generate-resources - - compile - - - install - - - - - .. - ${project.build.directory}/cmake - ${project.build.directory}/cmake - ${cmakeGenerator} - release - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.7 - - - - set-version-info - - run - - process-sources - - - - - - - - - - - true - - - - - unzip-cpp-includes - compile - - run - - - - cpp-sos=${version-info} - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.2 - - - zip-cpp-includes - compile - - attach-artifact - - - - - ${project.build.directory}/${project.build.finalName}.zip - zip - - - ${project.build.directory}/cmake/target-root/lib/libHALAthena.a - a - - - - - - - - - diff --git a/configure.bat b/configure.bat new file mode 100644 index 0000000000..21bac69ecf --- /dev/null +++ b/configure.bat @@ -0,0 +1,46 @@ +:: This file is a helper for allC++Sim +:: +:: Usage: cd /build && ../configure +:: +:: WARNING -- this is only temporary, and only meant for debug, and only works on my computer +@set WS=C:\Users\peter\gz-ws +@set BOOST_PATH=%WS%\boost_1_56_0 +@set BOOST_LIBRARY_DIR=%BOOST_PATH%\lib64-msvc-12.0 + +@set PROTOBUF_PATH=%WS%\protobuf-2.6.0-win64-vc12 + +@set OGRE_PATH=%WS%\ogre_src_v1-8-1-vc12-x64-release-debug\build\install\Debug +@set OGRE_INCLUDE_DIR=%OGRE_PATH%\include;%OGRE_PATH%\include\OGRE;%OGRE_PATH%\include\OGRE\RTShaderSystem;%OGRE_PATH%\include\OGRE\Terrain;%OGRE_PATH%\include\OGRE\Paging +@set OGRE_LIBRARY_DIR=%OGRE_PATH%\lib\Debug +set OGRE_LIB_SUFFIX=_d.lib +@set OGRE_LIBS=%OGRE_LIBRARY_DIR%\OgreMain%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgreOverlay%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgreRTShaderSystem%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgreTerrain%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgrePaging%OGRE_LIB_SUFFIX% +@set OGRE_LIBS=%OGRE_LIBRARY_DIR%\OgreMain%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgreRTShaderSystem%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgreTerrain%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgrePaging%OGRE_LIB_SUFFIX% + +@set FREEIMAGE_PATH=%WS%\FreeImage-vc12-x64-release-debug +@set FREEIMAGE_INCLUDE_DIR=%FREEIMAGE_PATH%\Source + +@set TBB_PATH=%WS%\tbb43_20141023oss +@set TBB_INCLUDEDIR=%TBB_PATH%\include + +@set DLFCN_WIN32_PATH=%WS%\dlfcn-win32-vc12-x64-release-debug\build\install\Debug +@set DLFCN_WIN32_INCLUDE_DIR=%DLFCN_WIN32_PATH%\include + +@set TINY_XML_INCLUDE_DIR=%WS%\sdformat\src\win\tinyxml + +@set GAZEBO_PATH=%WS%\gazebo\build\install\Debug\lib\cmake\gazebo +@set SDFORMAT_PATH=%WS%\sdformat\build\install\Debug\lib\cmake\sdformat +@set IGNITION-MATH_PATH=%WS%\ign-math\build\install\Debug\lib\cmake\ignition-math2 + +@set INCLUDE=%TINY_XML_INCLUDE_DIR%;%FREEIMAGE_INCLUDE_DIR%;%TBB_INCLUDEDIR%;%DLFCN_WIN32_INCLUDE_DIR%;%INCLUDE% +@set LIB=%LIB% + +cmake -G "NMake Makefiles"^ + -DCMAKE_INSTALL_PREFIX=build^ + -DCMAKE_PREFIX_PATH="%GAZEBO_PATH%;%SDFORMAT_PATH%;%IGNITION-MATH_PATH%"^ + -DOGRE_FOUND=1^ + -DOGRE_INCLUDE_DIRS="%OGRE_INCLUDE_DIR%"^ + -DOGRE_LIBRARIES="%OGRE_LIBS%"^ + -DPROTOBUF_SRC_ROOT_FOLDER="%PROTOBUF_PATH%"^ + -DBOOST_ROOT="%BOOST_PATH%"^ + -DBOOST_LIBRARYDIR="%BOOST_LIBRARY_DIR%"^ + .. diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/installer/AbstractInstaller.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/installer/AbstractInstaller.java index e27848680c..a597bdec30 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/installer/AbstractInstaller.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/installer/AbstractInstaller.java @@ -1,6 +1,8 @@ package edu.wpi.first.wpilib.plugins.core.installer; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -45,7 +47,38 @@ public abstract class AbstractInstaller { */ protected abstract InputStream getInstallResourceStream(); - public void installIfNecessary() { + /** + * + * @param sourcePath the file location of the zip file EX "/resources/simuation.zip" + * @param destinationPath the file location to unzip into EX "/home/peter/wpilib/simulation/plugins" + */ + public void installIfNecessary(String sourcePath, String destinationPath){ + //we're installing from this directory + InputStream sourceStream; + try { + sourceStream = new FileInputStream(sourcePath); + File destFile = new File(destinationPath); + installIfNecessary(sourceStream, destFile); + } catch (FileNotFoundException e) { + WPILibCore.logInfo("source zip file was not found: "+sourcePath); + } + } + + /** + * This function will delete an old wpilib subfolder if necessary and then copy + * the resource stream to the intended directory. + * + * @throws InstallException if bad things happen ... + */ + public void installIfNecessary(){ + installIfNecessary(getInstallResourceStream(), installLocation); + } + + /** + * I'm thinking maybe instead of final things, + * create a UnzipJob class to extend Job and have these as parameters to the constructor* + */ + public void installIfNecessary(final InputStream sourceStream,final File destination) { final Job installJob = new Job("Install " + getFeatureName()) { @Override @@ -56,14 +89,14 @@ public abstract class AbstractInstaller { if (!isInstalled()) { WPILibCore.logInfo("Install necessary for " + getFeatureName()); try { - install(); + install(sourceStream,destination); } catch (InstallException e) { WPILibCore.logError("Error installing "+getFeatureName(), e); return new Status(IStatus.ERROR, WPILibCore.PLUGIN_ID, getErrorMessage(e)); } } - + updateInstalledVersion(version); WPILibCore.logInfo("Installed" + getFeatureName()); @@ -98,6 +131,7 @@ public abstract class AbstractInstaller { } /** + * * This function has been updated to guarantee that the wpilib folder date * is older than the jar file being run, which ensures up to date tools. * @@ -108,38 +142,41 @@ public abstract class AbstractInstaller { } /** - * This function will delete an old wpilib subfolder if necessary and then copy - * the resource stream to the intended directory. * - * @throws InstallException if bad things happen ... + * @TODO this function is very long and complicated. If all it does is unzip, it shouldn't be so hard. + * + * @param sourceStream input stream of zip file + * @param destination desired location for output of unzipping + * @throws InstallException */ - protected void install() throws InstallException { - if(installLocation.exists()) { - if(!removeFileHandler(installLocation, true)) { + protected void install(InputStream sourceStream, File destination) throws InstallException { + if(destination.exists()) { + if(!removeFileHandler(destination, true)) { MessageDialog.openError(null, "Error", String.format("Could not update the old wpilib folder.%n" + "Please close any WPILib tools and restart Eclipse.")); } - + //removeFileHandler(installLocation, false); } - installLocation.mkdirs(); + destination.mkdirs(); final String osName = System.getProperty("os.name"); try { - if (osName.startsWith("Mac OS X") || osName.startsWith("Linux")) { // Unix-like OSes must preserve the executable bit; call unzip + // Unix-like OSes must preserve the executable bit; call unzip + if (osName.startsWith("Mac OS X") || osName.startsWith("Linux")) { final File tmpFile = File.createTempFile(getFeatureName()+"-", ".zip"); try { // Copy to temporary file - try (final InputStream zip = getInstallResourceStream(); + try (final InputStream zip = sourceStream; final FileOutputStream fout = new FileOutputStream(tmpFile)) { copyStreams(zip, fout); } // Call 'unzip' - final String[] cmd = {"unzip" , "-o", tmpFile.getAbsolutePath(), "-d", installLocation.getAbsolutePath()}; - WPILibCore.logInfo("unzip "+tmpFile.getAbsolutePath()+" -d "+installLocation.getAbsolutePath()); - final Process unzipProcess = DebugPlugin.exec(cmd, installLocation); + final String[] cmd = {"unzip", "-q", "-o", tmpFile.getAbsolutePath(), "-d", destination.getAbsolutePath()}; + WPILibCore.logInfo("unzip "+tmpFile.getAbsolutePath()+" -d "+destination.getAbsolutePath()); + final Process unzipProcess = DebugPlugin.exec(cmd, destination); try (final InputStream is = unzipProcess.getInputStream()) { copyStreams(is, System.out); // Copy output to console } @@ -153,11 +190,11 @@ public abstract class AbstractInstaller { tmpFile.delete(); } } else { - ZipInputStream zip = new ZipInputStream(getInstallResourceStream()); + ZipInputStream zip = new ZipInputStream(sourceStream); ZipEntry entry = zip.getNextEntry(); while (entry != null) { WPILibCore.logInfo("\tZipEntry " + entry + ": " + entry.getSize()); - File f = new File(installLocation, entry.getName()); + File f = new File(destination, entry.getName()); if (entry.isDirectory()) { f.mkdirs(); } else { @@ -176,6 +213,7 @@ public abstract class AbstractInstaller { } } + private static void copyStreams(InputStream source, OutputStream destination) throws IOException { byte[] buffer = new byte[1024]; int len; diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/launching/SimulationNotification.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/launching/SimulationNotification.java index 50307734a7..c1d2756e2b 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/launching/SimulationNotification.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/launching/SimulationNotification.java @@ -3,6 +3,7 @@ package edu.wpi.first.wpilib.plugins.core.launching; import java.awt.Desktop; import java.io.File; import java.io.IOException; +import java.lang.System; import java.net.URI; import java.net.URISyntaxException; @@ -15,7 +16,7 @@ import edu.wpi.first.wpilib.plugins.core.WPILibCore; public class SimulationNotification { private static final String URL = "https://wpilib.screenstepslive.com/s/4485/m/23353"; private static final String SIMULATION_UNSUPPORTED_MSG = - "Simulation is unsupported on your current setup.\n" + + "Simulation may not be support on your operating system.\n" + "For more information see: " + URL; public static void showUnsupported() { @@ -32,12 +33,8 @@ public class SimulationNotification { } public static boolean supportsSimulation() { - String[] cmd = {"frcsim", "--version"}; - try { - DebugPlugin.exec(cmd, new File(System.getProperty("user.home"))); - return true; - } catch (CoreException e) { - return false; - } + String os = System.getProperty("os.name"); + //for now this is good enough, but we still need better handling if they have this OS but have not installed FRCSim + return (os.equals("Windows 8") || os.equals("Windows 7") || os.equals("Linux") || os.equals("Windows 8.1")); } } diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/pom.xml index a11a566e1e..41d996c84a 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/pom.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/pom.xml @@ -25,6 +25,7 @@ + maven-resources-plugin 2.6 diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/.cproject b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/.cproject index d447f25523..726e9639c5 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/.cproject +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/.cproject @@ -3,7 +3,13 @@ - + + + + + + + @@ -12,7 +18,7 @@ - + - + + @@ -70,27 +77,31 @@ - + - + - + @@ -108,7 +119,7 @@ @@ -124,26 +135,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.properties index 91004e36d0..bbc581204b 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.properties +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.properties @@ -5,11 +5,7 @@ build.dir=build out.exe=Debug/${out} # Simulation -simulation.world.file=/usr/share/frcsim/worlds/GearsBotDemo.world -sim.exe=Simulate/${out} -wpilib.sim=${wpilib}/sim -sim.tools=${wpilib.sim}/tools -sim.lib=${wpilib.sim}/lib +simulation.world.file=$world # Use the current C++ library by default cpp-version=current diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.properties index f5a723b622..25c1ae0d55 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.properties +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.properties @@ -14,3 +14,9 @@ roboRIOAllowedImages=23 wpilib.ant.dir=${wpilib}/ant jsch.jar=${wpilib.ant.dir}/jsch-0.1.50.jar classloadertask.jar=${wpilib.ant.dir}/ant-classloadertask.jar + +#simulation stuff +sim.exe=Simulate/${out} +wpilib.sim=${wpilib}/sim +sim.tools=${wpilib.sim}/tools +sim.lib=${wpilib.sim}/lib diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.xml index c64936357d..a0a53df74b 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.xml @@ -104,17 +104,15 @@ - [simulate] Running Gazebo. - - - + + + + + + [simulate] You may now run Gazebo - - [simulate] Running DriverStation. - - - + [simulate] You can now run your DriverStation! diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.xml index 8c34c98008..666273a39e 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.xml @@ -174,17 +174,15 @@ - [simulate] Running Gazebo. - - - + + + + + [simulate] You may now run Gazebo - [simulate] Running DriverStation. - - - + [debug-simulate] You may now run your DriverStation. @@ -206,10 +204,7 @@ - [debug-simulate] Running DriverStation. - - - + [debug-simulate] you may now run your DriverStation. diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation.feature/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation.feature/build.properties new file mode 100644 index 0000000000..64f93a9f0b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation.feature/edu.wpi.first.wpilib.plugins.simulation.feature/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation.feature/edu.wpi.first.wpilib.plugins.simulation.feature/build.properties new file mode 100644 index 0000000000..64f93a9f0b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation.feature/edu.wpi.first.wpilib.plugins.simulation.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation.feature/edu.wpi.first.wpilib.plugins.simulation.feature/feature.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation.feature/edu.wpi.first.wpilib.plugins.simulation.feature/feature.xml new file mode 100644 index 0000000000..5fbee73367 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation.feature/edu.wpi.first.wpilib.plugins.simulation.feature/feature.xml @@ -0,0 +1,26 @@ + + + + + [Enter Feature Description here.] + + + + [Enter Copyright Description here.] + + + + [Enter License Description here.] + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation.feature/feature.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation.feature/feature.xml new file mode 100644 index 0000000000..c022e1df0e --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation.feature/feature.xml @@ -0,0 +1,59 @@ + + + + + FRC Robot Simulation Program Development Environment. + + + + * Copyright (c) 2015 FIRST and WPI +* All rights reserved. + + + + * Copyright (c) 2015 FIRST and WPI +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or +* without modification, are permitted provided that the following +* conditions are met: +* Redistributions of source code must retain the above +* copyright notice, this list of conditions and the following +* disclaimer. Redistributions in binary form must reproduce the +* above copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. Neither the name of the FIRST nor the +* names of its contributors may be used to endorse or promote +* products derived from this software without specific prior +* written permission. +* +* THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +* EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation.feature/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation.feature/pom.xml new file mode 100644 index 0000000000..fadc4bcfc3 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation.feature/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins.simulation.feature + eclipse-feature + + + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + .. + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/.gitignore b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/.gitignore new file mode 100644 index 0000000000..18a93a3940 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/.gitignore @@ -0,0 +1,2 @@ +#ignore libraries. They will be copied from frc_gazebo_plugins/build/plugins +*.so diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/META-INF/MANIFEST.MF b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..af2d405d39 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: WPILib_Robot_Simulation +Bundle-SymbolicName: edu.wpi.first.wpilib.plugins.simulation;singleton:=true +Bundle-Version: 0.1.0.qualifier +Bundle-Activator: edu.wpi.first.wpilib.plugins.simulation.WPILibSimulationPlugin +Require-Bundle: org.eclipse.core.runtime, + edu.wpi.first.wpilib.plugins.core;bundle-version="0.1.0", + org.eclipse.jface;bundle-version="3.10.2", + org.eclipse.ui;bundle-version="3.106.1" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy +Bundle-Vendor: Worcester Polytechnic Institute diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/README.md b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/README.md new file mode 100644 index 0000000000..ad5c5cd3ce --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/README.md @@ -0,0 +1,10 @@ +#Notes on the simulation eclipse plugin +Should download models when installed + +build with the rest of the eclipse plugins using: + + //if you're in the eclipse-plugins directory + mvn package + + //otherwise in the base dir + ./gradlew eclipsePlugins //no colons here! diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/build.properties new file mode 100644 index 0000000000..e1d4e2a14e --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/build.properties @@ -0,0 +1,8 @@ +source.. = src/main/java/ +output.. = target/classes/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + resources/ + src.include = src/,\ + resources/ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/plugin.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/plugin.xml new file mode 100644 index 0000000000..f967023aa9 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/plugin.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/pom.xml new file mode 100644 index 0000000000..1aa2b760e9 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/pom.xml @@ -0,0 +1,158 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins.simulation + eclipse-plugin + + + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + .. + + + + DEVELOPMENT + ${project.build.directory}\simulation-zip + + + + + WPILib Maven Repository + http://first.wpi.edu/FRC/roborio/maven/ + + + + + + + . + + resources/configuration.properties + + true + + + + + maven-resources-plugin + 2.6 + + + copy-plugins-to-simulation-zip + generate-sources + + copy-resources + + + ${simulation-zip} + + + ../../build/simulation/frc_gazebo_plugins/ + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.7 + + + + + set-version-info + + run + + process-sources + + + + + + + + + + + true + + + + + + generate-simulation-zip + compile + + run + + + + + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.apache.maven.plugins + + + maven-dependency-plugin + + [2.8,) + + copy + + + + + + + + + + + + + + + + + + + + edu.wpi.first.wpilib + sfx + zip + LATEST + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/resources/configuration.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/resources/configuration.properties new file mode 100644 index 0000000000..cbfaca2ede --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/resources/configuration.properties @@ -0,0 +1,2 @@ +timestamp=${timestamp} +version=${version} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/src/main/java/edu/wpi/first/wpilib/plugins/simulation/WPILibSimulationPlugin.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/src/main/java/edu/wpi/first/wpilib/plugins/simulation/WPILibSimulationPlugin.java new file mode 100644 index 0000000000..779f98f50c --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/src/main/java/edu/wpi/first/wpilib/plugins/simulation/WPILibSimulationPlugin.java @@ -0,0 +1,104 @@ +package edu.wpi.first.wpilib.plugins.simulation; + +/** + * @author peter mitrano + */ + +import java.io.File; +import java.util.Properties; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Status; +import org.eclipse.ui.IStartup; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.core.ant.AntPropertiesParser; +import edu.wpi.first.wpilib.plugins.simulation.installer.SimulationInstaller; + +public class WPILibSimulationPlugin extends AbstractUIPlugin implements IStartup{ + + // The plug-in ID + public static final String PLUGIN_ID = "WPILib_Java_Robot_Development"; //$NON-NLS-1$ + + // The shared instance + private static WPILibSimulationPlugin plugin; + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + plugin = null; + super.stop(bundleContext); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static WPILibSimulationPlugin getDefault() { + return plugin; + } + + public String getCurrentVersion() { + try { + Properties props = new AntPropertiesParser( + WPILibSimulationPlugin.class.getResourceAsStream("/resources/configuration.properties")). + getProperties(); + if (props.getProperty("version").startsWith("$")) { + return "DEVELOPMENT"; + } else { + return props.getProperty("version"); + } + } catch (CoreException e) { + WPILibSimulationPlugin.logError("Error getting properties.", e); + return "DEVELOPMENT"; + } + } + + public String getSimulationDir() { + return WPILibCore.getDefault().getWPILibBaseDir() + + File.separator + "simulation"; + } + + public String getPluginsDir() { + return getSimulationDir() + File.separator + "plugins"; + } + + public static void logInfo(String msg) { + getDefault().getLog().log(new Status(Status.INFO, PLUGIN_ID, Status.OK, msg, null)); + } + + private static void logError(String msg, CoreException e) { + getDefault().getLog().log(new Status(Status.ERROR, PLUGIN_ID, Status.OK, msg, e)); + } + + public String getJavaPath() { + return WPILibCore.getDefault().getWPILibBaseDir() + + File.separator + "java" + File.separator + "current"; + } + + @Override + public void earlyStartup() { + SimulationInstaller simulationInstaller = new SimulationInstaller(getCurrentVersion()); + //downloads and copies the models from collabnet and unzips to + //wpilib/simulation/models and wpilib/simulation/worlds + simulationInstaller.installModels(); + //extracts and copies the gazebo plugins from simulation.zip to wpilib/simulation/plugins + simulationInstaller.installPlugins(); + + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/src/main/java/edu/wpi/first/wpilib/plugins/simulation/installer/SimulationInstaller.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/src/main/java/edu/wpi/first/wpilib/plugins/simulation/installer/SimulationInstaller.java new file mode 100644 index 0000000000..2f7c511057 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/src/main/java/edu/wpi/first/wpilib/plugins/simulation/installer/SimulationInstaller.java @@ -0,0 +1,89 @@ +package edu.wpi.first.wpilib.plugins.simulation.installer; + +/** + * @author peter mitrano + */ + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; + +import javax.net.ssl.HttpsURLConnection; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.osgi.service.log.LogEntry; + +import edu.wpi.first.wpilib.plugins.core.installer.AbstractInstaller; +import edu.wpi.first.wpilib.plugins.simulation.WPILibSimulationPlugin; +import edu.wpi.first.wpilib.plugins.simulation.preferences.PreferenceConstants; + +public class SimulationInstaller extends AbstractInstaller { + + public SimulationInstaller(String version) { + // copy gazebo plugins wpilib/simulation/plugins + super(version, WPILibSimulationPlugin.getDefault().getPreferenceStore() + .getString(PreferenceConstants.LIBRARY_INSTALLED), + WPILibSimulationPlugin.getDefault().getPluginsDir()); + } + + public void installModels() { + // download models + // temporarily hardcoding link, but should be smarter + + String inputFilePath = WPILibSimulationPlugin.getDefault() + .getSimulationDir() + File.separator + "models.zip"; + File inputFile = new File(inputFilePath); + + try { + if (inputFile.exists()) { + WPILibSimulationPlugin.logInfo("models doesn't need to be downloaded again"); + } else { + URL url = new URL("https://usfirst.collab.net/sf/frs/do/downloadFile/projects.wpilib/frs.simulation.frcsim_gazebo_models/frs1162?dl=1"); + HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); + try (InputStream stream = con.getInputStream()) { + WPILibSimulationPlugin.logInfo("downloading models zip"); + Files.copy(stream, Paths.get(inputFilePath)); + } + } + // unzip + WPILibSimulationPlugin.logInfo("unzipping to "+ WPILibSimulationPlugin.getDefault().getSimulationDir()); + super.installIfNecessary(inputFilePath, WPILibSimulationPlugin.getDefault().getSimulationDir()); + } catch (MalformedURLException mue) { + WPILibSimulationPlugin + .logInfo("Malformed URL Exception when downloading models"); + WPILibSimulationPlugin.logInfo(mue.getLocalizedMessage()); + } catch (IOException ioe) { + WPILibSimulationPlugin + .logInfo("IO Exception when downloading models"); + WPILibSimulationPlugin.logInfo(ioe.getLocalizedMessage()); + } + + } + + public void installPlugins() { + super.installIfNecessary(); + } + + @Override + protected String getFeatureName() { + return "simulation"; + } + + @Override + protected void updateInstalledVersion(String version) { + IPreferenceStore prefs = WPILibSimulationPlugin.getDefault() + .getPreferenceStore(); + prefs.setValue(PreferenceConstants.LIBRARY_INSTALLED, version); + + } + + @Override + protected InputStream getInstallResourceStream() { + return SimulationInstaller.class + .getResourceAsStream("/resources/simulation.zip"); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/src/main/java/edu/wpi/first/wpilib/plugins/simulation/preferences/PreferenceConstants.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/src/main/java/edu/wpi/first/wpilib/plugins/simulation/preferences/PreferenceConstants.java new file mode 100644 index 0000000000..df939cdce2 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/src/main/java/edu/wpi/first/wpilib/plugins/simulation/preferences/PreferenceConstants.java @@ -0,0 +1,10 @@ +package edu.wpi.first.wpilib.plugins.simulation.preferences; + +/** + * @author peter mitrano + * + * Constant definitions for plug-in preferences + */ +public class PreferenceConstants { + public static final String LIBRARY_INSTALLED = "libraryVersion_current"; +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/src/main/java/edu/wpi/first/wpilib/plugins/simulation/preferences/PreferenceInitializer.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/src/main/java/edu/wpi/first/wpilib/plugins/simulation/preferences/PreferenceInitializer.java new file mode 100644 index 0000000000..02ed687f91 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.simulation/src/main/java/edu/wpi/first/wpilib/plugins/simulation/preferences/PreferenceInitializer.java @@ -0,0 +1,25 @@ +package edu.wpi.first.wpilib.plugins.simulation.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; + +/** + * @author peter mitrano + * + * Class used to initialize default preference values. + */ +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + public void initializeDefaultPreferences() { + IPreferenceStore store = WPILibCore.getDefault().getPreferenceStore(); + if (!store.contains(PreferenceConstants.LIBRARY_INSTALLED)) + store.setValue(PreferenceConstants.LIBRARY_INSTALLED, "none"); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/site.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/site.xml index f6498c4bba..6286845aec 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/site.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/site.xml @@ -6,6 +6,9 @@ + + + Core WPILib Robot Development Tools. diff --git a/eclipse-plugins/pom.xml b/eclipse-plugins/pom.xml index fe3ab7034e..376a31b53f 100644 --- a/eclipse-plugins/pom.xml +++ b/eclipse-plugins/pom.xml @@ -11,6 +11,8 @@ edu.wpi.first.wpilib.plugins.core edu.wpi.first.wpilib.plugins.core.feature + edu.wpi.first.wpilib.plugins.simulation + edu.wpi.first.wpilib.plugins.simulation.feature edu.wpi.first.wpilib.plugins.cpp edu.wpi.first.wpilib.plugins.cpp.feature edu.wpi.first.wpilib.plugins.java diff --git a/hal/include/Log.hpp b/hal/include/Log.hpp index eb221e79c4..81b7b8427e 100644 --- a/hal/include/Log.hpp +++ b/hal/include/Log.hpp @@ -4,7 +4,11 @@ #include #include #include -#include +#ifdef _WIN32 + #include +#else + #include +#endif inline std::string NowTime(); @@ -88,6 +92,17 @@ typedef Log FILELog; if (level > FILELog::ReportingLevel()) ; \ else Log().Get(level) + +#ifdef _WIN32 +inline std::string NowTime() +{ + SYSTEMTIME st; + GetLocalTime(&st); + char result[100] = {0}; + sprintf(result, "%d:%d:%d.%d", st.wHour , st.wMinute , st.wSecond , st.wMilliseconds); + return result; +} +#else inline std::string NowTime() { char buffer[11]; @@ -101,3 +116,4 @@ inline std::string NowTime() sprintf(result, "%s.%03ld", buffer, (long)tv.tv_usec / 1000); return result; } +#endif diff --git a/networktables/cpp/include/NTBase.h b/networktables/cpp/include/NTBase.h new file mode 100644 index 0000000000..b6d2d995e8 --- /dev/null +++ b/networktables/cpp/include/NTBase.h @@ -0,0 +1,10 @@ +//this file is used for hacking + +#ifndef NT_BASE_H_ +#define NT_BASE_H_ + +#if defined(_MSC_VER) + #define noexcept throw() +#endif + +#endif \ No newline at end of file diff --git a/networktables/cpp/include/NTErrorBase.h b/networktables/cpp/include/NTErrorBase.h index 2c081290bf..599daf076c 100644 --- a/networktables/cpp/include/NTErrorBase.h +++ b/networktables/cpp/include/NTErrorBase.h @@ -8,23 +8,22 @@ #define _ERROR_BASE_H #if defined WIN32 -#include -#define wpi_setErrnoErrorWithContext(context) -#define wpi_setErrnoError() -#define wpi_setImaqErrorWithContext(code, context) -#define wpi_setErrorWithContext(code, context) -#define wpi_setError(code) -#define wpi_setStaticErrorWithContext(object, code, context) +#define wpi_setErrnoErrorWithContext(context) +#define wpi_setErrnoError() +#define wpi_setImaqErrorWithContext(code, context) +#define wpi_setErrorWithContext(code, context) +#define wpi_setError(code) +#define wpi_setStaticErrorWithContext(object, code, context) #define wpi_setStaticError(object, code) -#define wpi_setGlobalErrorWithContext(code, context) -#define wpi_setGlobalError(code) +#define wpi_setGlobalErrorWithContext(code, context) +#define wpi_setGlobalError(code) #define wpi_setWPIErrorWithContext(error, context) -#define wpi_setWPIError(error) -#define wpi_setStaticWPIErrorWithContext(object, error, context) -#define wpi_setStaticWPIError(object, error) -#define wpi_setGlobalWPIErrorWithContext(error, context) -#define wpi_setGlobalWPIError(error) +#define wpi_setWPIError(error) +#define wpi_setStaticWPIErrorWithContext(object, error, context) +#define wpi_setStaticWPIError(object, error) +#define wpi_setGlobalWPIErrorWithContext(error, context) +#define wpi_setGlobalWPIError(error) /** * Base class for most objects. @@ -35,7 +34,7 @@ class ErrorBase { //TODO: Consider initializing instance variables and cleanup in destructor public: - + }; #endif diff --git a/networktables/cpp/include/OSAL/Synchronized.h b/networktables/cpp/include/OSAL/Synchronized.h index 15deb2b2e8..8560d16a57 100644 --- a/networktables/cpp/include/OSAL/Synchronized.h +++ b/networktables/cpp/include/OSAL/Synchronized.h @@ -10,31 +10,6 @@ #define NT_CRITICAL_REGION(s) { NTSynchronized _sync(s); #define NT_END_REGION } -#if defined WIN32 - -#include - -class NTReentrantSemaphore -{ -public: - explicit NTReentrantSemaphore(){ - m_semaphore = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE); - }; - ~NTReentrantSemaphore(){ - semDelete(m_semaphore); - }; - void take(){ - semTake(m_semaphore, WAIT_FOREVER); - }; - void give(){ - semGive(m_semaphore); - }; -private: - SEM_ID m_semaphore; -}; - -#else - #include class NTReentrantSemaphore @@ -59,7 +34,6 @@ private: pthread_mutexattr_t mta; pthread_mutex_t m_semaphore; }; -#endif // WIN32 /** * Provide easy support for critical regions. @@ -76,18 +50,9 @@ class NTSynchronized public: explicit NTSynchronized(NTReentrantSemaphore&); //TODO remove vxworks SEM_ID support -#if defined WIN32 - explicit NTSynchronized(SEM_ID); -#endif virtual ~NTSynchronized(); private: -#if defined WIN32 - bool usingSem; - NTReentrantSemaphore* m_sem; - SEM_ID m_semaphore; -#else NTReentrantSemaphore& m_semaphore; -#endif }; diff --git a/networktables/cpp/include/OSAL/Task.h b/networktables/cpp/include/OSAL/Task.h deleted file mode 100644 index e8f693c164..0000000000 --- a/networktables/cpp/include/OSAL/Task.h +++ /dev/null @@ -1,75 +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. */ -/*----------------------------------------------------------------------------*/ - -#ifndef __NTTASK_H__ -#define __NTTASK_H__ - -#if defined WIN32 - -#include "NTErrorBase.h" - -/** - * WPI task is a wrapper for the native Task object. - * All WPILib tasks are managed by a static task manager for simplified cleanup. - **/ -class NTTask : public ErrorBase -{ -public: - static const UINT32 kDefaultPriority = 101; - static const INT32 kInvalidTaskID = -1; - - NTTask(const char* name, FUNCPTR function, INT32 priority = kDefaultPriority, UINT32 stackSize = 20000); - virtual ~NTTask(); - - NTTask(const NTTask&) = delete; - NTTask& operator=(const NTTask&) = delete; - - #ifdef WIN32 - bool Start(void * arg0); - #else - bool Start(UINT32 arg0 = 0, UINT32 arg1 = 0, UINT32 arg2 = 0, UINT32 arg3 = 0, UINT32 arg4 = 0, - UINT32 arg5 = 0, UINT32 arg6 = 0, UINT32 arg7 = 0, UINT32 arg8 = 0, UINT32 arg9 = 0); - #endif - - bool Restart(); - bool Stop(); - - bool IsReady(); - bool IsSuspended(); - - bool Suspend(); - bool Resume(); - - bool Verify(); - - INT32 GetPriority(); - bool SetPriority(INT32 priority); - const char* GetName(); - INT32 GetID(); - - #ifdef WIN32 - FUNCPTR m_function; - void * m_Arg; - #endif -private: - char* m_taskName; - - #ifdef WIN32 - bool StartInternal(); - HANDLE m_Handle; - DWORD m_ID; - #else - FUNCPTR m_function; - INT32 m_taskID; - #endif - - UINT32 m_stackSize; - INT32 m_priority; - bool HandleError(STATUS results); -}; - -#endif // WIN32 -#endif // __TASK_H__ diff --git a/networktables/cpp/include/networktables2/connection/BadMessageException.h b/networktables/cpp/include/networktables2/connection/BadMessageException.h index c1fad836c3..53cc9cb984 100644 --- a/networktables/cpp/include/networktables2/connection/BadMessageException.h +++ b/networktables/cpp/include/networktables2/connection/BadMessageException.h @@ -8,6 +8,7 @@ #ifndef BADMESSAGEEXCEPTION_H_ #define BADMESSAGEEXCEPTION_H_ +#include "NTBase.h" #include #include diff --git a/networktables/cpp/include/networktables2/thread/DefaultThreadManager.h b/networktables/cpp/include/networktables2/thread/DefaultThreadManager.h index a4394d44b2..494f30bdfe 100644 --- a/networktables/cpp/include/networktables2/thread/DefaultThreadManager.h +++ b/networktables/cpp/include/networktables2/thread/DefaultThreadManager.h @@ -17,11 +17,7 @@ class PeriodicNTThread; #include "networktables2/thread/NTThreadManager.h" #include "networktables2/thread/NTThread.h" -#if defined WIN32 -#include "OSAL/Task.h" -#else #include -#endif class DefaultThreadManager : public NTThreadManager{ public: @@ -30,21 +26,11 @@ public: class PeriodicNTThread : public NTThread { private: -#if defined WIN32 - const char* name; - NTTask* thread; -#else pthread_t thread; -#endif PeriodicRunnable* r; bool run; -#if defined WIN32 - int _taskMain(); - static int taskMain(PeriodicNTThread* o); -#else//TODO make return int for pthread as well void _taskMain(); static void* taskMain(PeriodicNTThread* o); -#endif public: PeriodicNTThread(PeriodicRunnable* r, const char* name); virtual ~PeriodicNTThread(); diff --git a/networktables/cpp/include/networktables2/util/IOException.h b/networktables/cpp/include/networktables2/util/IOException.h index e4a3670697..b3b0a06435 100644 --- a/networktables/cpp/include/networktables2/util/IOException.h +++ b/networktables/cpp/include/networktables2/util/IOException.h @@ -8,6 +8,7 @@ #ifndef IOEXCEPTION_H_ #define IOEXCEPTION_H_ +#include "NTBase.h" #include /** @@ -17,31 +18,31 @@ class IOException : public std::exception{ public: /** * Creates a new IOException with the given message. - * + * * @param message The message to associate with this exception. */ IOException(const char* message); - + /** * Creates a new IOException with the given message and * error value. - * + * * @param message The message to associate with this exception. * @param errorValue The integer code to associate with this exception. */ IOException(const char* message, int errorValue); - + /** * Gets the message associated with this exception. - * + * * @return The message associated with this exception. */ const char* what() const noexcept; - + /** * Determines whether this exception indicates that an EOF * was encountered. - * + * * @return True if this exception indicates that an EOF was encountered. * False otherwise. */ diff --git a/networktables/cpp/include/networktables2/util/IllegalStateException.h b/networktables/cpp/include/networktables2/util/IllegalStateException.h index a4e423e323..5d7863ac5d 100644 --- a/networktables/cpp/include/networktables2/util/IllegalStateException.h +++ b/networktables/cpp/include/networktables2/util/IllegalStateException.h @@ -8,6 +8,7 @@ #ifndef ILLEGALSTATEEXCEPTION_H_ #define ILLEGALSTATEEXCEPTION_H_ +#include "NTBase.h" #include #include diff --git a/networktables/cpp/include/tables/ITableListener.h b/networktables/cpp/include/tables/ITableListener.h index 582a79313e..b046ebef41 100644 --- a/networktables/cpp/include/tables/ITableListener.h +++ b/networktables/cpp/include/tables/ITableListener.h @@ -8,10 +8,9 @@ #ifndef ITABLELISTENER_H_ #define ITABLELISTENER_H_ - class ITableListener; - +#include "NTBase.h" #include "tables/ITable.h" #include @@ -42,7 +41,11 @@ class ITableListener { private: template - struct[[deprecated]] NullDeleter { + struct +#if !defined(_MSC_VER) + [[deprecated]] +#endif + NullDeleter { void operator()(T*) const noexcept {}; }; }; diff --git a/networktables/cpp/lib/Win32/src/main/native/OSAL/Synchronized.cpp b/networktables/cpp/lib/Win32/src/main/native/OSAL/Synchronized.cpp index 763c98cc7e..80d6cb4e23 100644 --- a/networktables/cpp/lib/Win32/src/main/native/OSAL/Synchronized.cpp +++ b/networktables/cpp/lib/Win32/src/main/native/OSAL/Synchronized.cpp @@ -3,78 +3,22 @@ /* 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 "stdafx.h" + +// Previous version used semaphores. +// This version was copied from the "Athena" version of network tables. +// It uses pthread and is much simpler #include "OSAL/Synchronized.h" +#include -//TODO see what the STATUS is suppose to return for success -STATUS semGive (SEM_ID semId) +pthread_mutexattr_t mta; +bool hasInit = false; + +NTSynchronized::NTSynchronized(NTReentrantSemaphore& semaphore):m_semaphore(semaphore) { - ::LeaveCriticalSection( semId ); - return 0; -} -STATUS semTake (SEM_ID semId, int timeout) -{ - if (timeout==WAIT_FOREVER) - ::EnterCriticalSection( semId ); - else - { - BOOL result; - int TimeOut=0; - do - { - result=::TryEnterCriticalSection( semId ); - if (result==0) - Sleep(10); - } while ((result==0)&&(TimeOut++take(); -} - -/** - * This destructor unlocks the semaphore. - */ NTSynchronized::~NTSynchronized() { - if(usingSem) - m_sem->give(); - else - semGive(m_semaphore); + m_semaphore.give(); } diff --git a/networktables/cpp/lib/Win32/src/main/native/OSAL/System.cpp b/networktables/cpp/lib/Win32/src/main/native/OSAL/System.cpp index c6b16dddcb..3d6f21720b 100644 --- a/networktables/cpp/lib/Win32/src/main/native/OSAL/System.cpp +++ b/networktables/cpp/lib/Win32/src/main/native/OSAL/System.cpp @@ -6,15 +6,17 @@ * Author: Mitchell Wills */ -#include "windows.h" +#include +#include #include "networktables2/util/System.h" //#include "semLib.h" #include //#include // for sysClkRateGet //#include // for taskDelay -//timeGetTime() uses Winmm.lib +//timeGetTime() uses Winmm.lib #pragma comment (lib,"Winmm.lib") #pragma comment( lib, "Ws2_32" ) + void sleep_ms(unsigned long ms){ //taskDelay((INT32)((double)sysClkRateGet() * ms / 1000)); Sleep(ms); diff --git a/networktables/cpp/lib/Win32/src/main/native/OSAL/Task.cpp b/networktables/cpp/lib/Win32/src/main/native/OSAL/Task.cpp deleted file mode 100644 index a4abcf5d9f..0000000000 --- a/networktables/cpp/lib/Win32/src/main/native/OSAL/Task.cpp +++ /dev/null @@ -1,316 +0,0 @@ -#include "stdafx.h" -#include "OSAL/Task.h" - -#include "NetworkCommunication/UsageReporting.h" -#include "WPIErrors.h" -#include -#include - - -//const UINT32 NTTask::kDefaultPriority; -//const INT32 NTTask::kInvalidTaskID; - -/** - * Create but don't launch a task. - * @param name The name of the task. "FRC_" will be prepended to the task name. - * @param function The address of the function to run as the new task. - * @param priority The priority for the task. - * @param stackSize The size of the stack for the task - */ -NTTask::NTTask(const char* name, FUNCPTR function, INT32 priority, UINT32 stackSize) -{ - //m_taskID = kInvalidTaskID; - m_Handle=NULL; - m_function = function; - m_priority = priority; - m_stackSize = stackSize; - m_taskName = new char[strlen(name) + 5]; - strcpy(m_taskName, "FRC_"); - strcpy(m_taskName+4, name); - - //TODO see if we want to debug out this... it may be interesting info - #if 0 - static INT32 instances = 0; - instances++; - #endif -} - -NTTask::~NTTask() -{ - //if (m_taskID != kInvalidTaskID) Stop(); - if (m_Handle) - Stop(); - delete [] m_taskName; - m_taskName = NULL; -} - -// The thread callback -DWORD thread_proc( void *p_ptr ) -{ // Get the pointer to myself - NTTask *p_this = (NTTask*)p_ptr; - assert( p_this ); - - (*p_this->m_function)( p_this->m_Arg ); - return 0; -} - -//This sets the name of the thread, which can help to identify threads in win32 -#define MS_VC_EXCEPTION 0x406D1388 -static void set_thread_name( const char *p_thread_name, DWORD ID ) -{ -#pragma pack(push,8) - typedef struct tagTHREADNAME_INFO - { DWORD dwType; // Must be 0x1000. - LPCSTR szName; // Pointer to name (in user addr space). - DWORD dwThreadID; // Thread ID (-1=caller thread). - DWORD dwFlags; // Reserved for future use, must be zero. - - } THREADNAME_INFO; -#pragma pack(pop) - - // Set the information - THREADNAME_INFO info = { 0x1000, p_thread_name, ID, 0 }; - - // Raise the exception - __try { ::RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info ); } - __except( EXCEPTION_EXECUTE_HANDLER ) {} -} - -bool NTTask::StartInternal() -{ - if (m_Handle) - { - assert(false); // This may be lifted... just want to see if it happens - Stop(); - } - - m_Handle = ::CreateThread( NULL, m_stackSize, (LPTHREAD_START_ROUTINE)thread_proc, (void*)this, NULL, &m_ID ); - if (m_ID!=NULL) - set_thread_name(m_taskName,m_ID); - return m_Handle!=NULL; -} - -/** - * Starts this task. - * If it is already running or unable to start, it fails and returns false. - */ -bool NTTask::Start(void *arg0) -{ - m_Arg=arg0; - return StartInternal(); -} - -/** - * Restarts a running task. - * If the task isn't started, it starts it. - * @return false if the task is running and we are unable to kill the previous instance - */ -bool NTTask::Restart() -{ - //return HandleError(taskRestart(m_taskID)); - Stop(); - return StartInternal(); -} - -/** - * Kills the running task. - * @returns true on success false if the task doesn't exist or we are unable to kill it. - */ -bool NTTask::Stop() -{ - if (!m_Handle) return false; - bool ok = true; - // Wait for the thread to finish - #ifdef _DEBUG - try_again: - #endif _DEBUG - - //const int TimeOut=2000; - const int TimeOut=INFINITE; - if ( ::WaitForSingleObject( m_Handle , TimeOut ) == WAIT_TIMEOUT ) - { // Signal the thread as having been terminated - //if ( m_p_error ) *m_p_error = true; - - // If this gets triggered we have a bug in the code. -#ifdef _DEBUG - switch( ::MessageBoxW( NULL, L"A thread being used by the application\n" - L"has taken to long to exit and so is about\n" - L"to be terminated to avoid locking-up\n" - L"the application.\n\n" - L"Click ABORT to debug.\n" - L"Click RETRY to wait for a bit longer.\n" - L"Click IGNORE to terminate the thread.\n\n" - L"This message is NOT displayed in release mode.", - L"Thread exit has timed out.", - MB_ABORTRETRYIGNORE ) ) - { case IDRETRY: goto try_again; - case IDABORT: ::DebugBreak(); break; - case IDIGNORE: break; - } -#endif _DEBUG - - // Free thread memory - CONTEXT c_ = {0}; - c_.ContextFlags = CONTEXT_FULL; - ::GetThreadContext( m_Handle, &c_ ); - MEMORY_BASIC_INFORMATION Info_ = {0}; - -#ifdef _M_X64 - ::VirtualQuery( (PVOID) c_.Rsp, &Info_, sizeof(Info_) ); -#else - ::VirtualQuery( (PVOID) c_.Esp, &Info_, sizeof(Info_) ); -#endif - // Terminate the thread - ::TerminateThread( m_Handle, 0 ); - - // Free the memory - ::VirtualFree( Info_.AllocationBase, 0, MEM_RELEASE ); - } - - //if (Verify()) - //{ - // ok = HandleError(taskDelete(m_taskID)); - //} - //m_taskID = kInvalidTaskID; - // The thread has finished - - CloseHandle( m_Handle ); - m_Handle = NULL; - return ok; -} - -/** - * Returns true if the task is ready to execute (i.e. not suspended, delayed, or blocked). - * @return true if ready, false if not ready. - */ -bool NTTask::IsReady() -{ - //return taskIsReady(m_taskID); - return m_Handle!=NULL; -} - -/** - * Returns true if the task was explicitly suspended by calling Suspend() - * @return true if suspended, false if not suspended. - */ -bool NTTask::IsSuspended() -{ - //return taskIsSuspended(m_taskID); - return false; -} - -/** - * Pauses a running task. - * Returns true on success, false if unable to pause or the task isn't running. - */ -bool NTTask::Suspend() -{ - //return HandleError(taskSuspend(m_taskID)); - assert(false); - return false; -} - -/** - * Resumes a paused task. - * Returns true on success, false if unable to resume or if the task isn't running/paused. - */ -bool NTTask::Resume() -{ - //return HandleError(taskResume(m_taskID)); - assert(false); - return false; -} - -/** - * Verifies a task still exists. - * @returns true on success. - */ -bool NTTask::Verify() -{ - //return taskIdVerify(m_taskID) == OK; - return true; -} - -/** - * Gets the priority of a task. - * @returns task priority or 0 if an error occured - */ -INT32 NTTask::GetPriority() -{ - //if (HandleError(taskPriorityGet(m_taskID, &m_priority))) - // return m_priority; - //else - // return 0; - return m_priority; -} - -/** - * This routine changes a task's priority to a specified priority. - * Priorities range from 0, the highest priority, to 255, the lowest priority. - * Default task priority is 100. - * @param priority The priority the task should run at. - * @returns true on success. - */ -bool NTTask::SetPriority(INT32 priority) -{ - m_priority = priority; - //return HandleError(taskPrioritySet(m_taskID, m_priority)); - return true; -} - -/** - * Returns the name of the task. - * @returns Pointer to the name of the task or NULL if not allocated - */ -const char* NTTask::GetName() -{ - return m_taskName; -} - -/** - * Get the ID of a task - * @returns Task ID of this task. NTTask::kInvalidTaskID (-1) if the task has not been started or has already exited. - */ -INT32 NTTask::GetID() -{ - //if (Verify()) - // return m_taskID; - if (m_Handle) - return m_ID; - return kInvalidTaskID; -} - -/** - * Handles errors generated by task related code. - */ -bool NTTask::HandleError(STATUS results) -{ - if (results != ERROR) return true; - //switch(errnoGet()) - //{ - //case S_objLib_OBJ_ID_ERROR: - // wpi_setWPIErrorWithContext(TaskIDError, m_taskName); - // break; - // - //case S_objLib_OBJ_DELETED: - // wpi_setWPIErrorWithContext(TaskDeletedError, m_taskName); - // break; - // - //case S_taskLib_ILLEGAL_OPTIONS: - // wpi_setWPIErrorWithContext(TaskOptionsError, m_taskName); - // break; - // - //case S_memLib_NOT_ENOUGH_MEMORY: - // wpi_setWPIErrorWithContext(TaskMemoryError, m_taskName); - // break; - // - //case S_taskLib_ILLEGAL_PRIORITY: - // wpi_setWPIErrorWithContext(TaskPriorityError, m_taskName); - // break; - - //default: - // printErrno(errnoGet()); - // wpi_setWPIErrorWithContext(TaskError, m_taskName); - //} - return false; -} diff --git a/networktables/cpp/lib/Win32/src/main/native/networktables2/stream/FDIOStream.cpp b/networktables/cpp/lib/Win32/src/main/native/networktables2/stream/FDIOStream.cpp index 0e8d23cf55..72b6f69dff 100644 --- a/networktables/cpp/lib/Win32/src/main/native/networktables2/stream/FDIOStream.cpp +++ b/networktables/cpp/lib/Win32/src/main/native/networktables2/stream/FDIOStream.cpp @@ -1,22 +1,24 @@ -#include "stdafx.h" /* * FDIOStream.cpp * * Created on: Sep 27, 2012 */ + //make sure this comes before windows.h +#include #include "networktables2/stream/FDIOStream.h" #include "networktables2/util/IOException.h" #include "networktables2/util/EOFException.h" +#include #include #include +#include #include #include -#include #include #include - +#include FDIOStream::FDIOStream(int _fd){ fd = _fd; @@ -24,7 +26,7 @@ FDIOStream::FDIOStream(int _fd){ u_long on = 1; if (ioctlsocket(fd, FIONBIO, &on)) { - ::close(fd); + ::_close(fd); throw IOException("Could not set socket to non-blocking mode"); } } @@ -38,7 +40,7 @@ int FDIOStream::read(void* ptr, int numbytes){ return 0; char* bufferPointer = (char*)ptr; int totalRead = 0; - while (totalRead < numbytes) + while (totalRead < numbytes) { int numRead=recv(fd, bufferPointer, numbytes-totalRead, 0); if(numRead == 0){ @@ -77,7 +79,7 @@ int Send( int sockfd,char* Data, size_t sizeData ) if (!Result_) { char Buffer[128]; - sprintf(Buffer,"Send() failed: WSA error=%d\n",WSAGetLastError()); + sprintf_s(Buffer,"Send() failed: WSA error=%d\n",WSAGetLastError()); OutputDebugStringA(Buffer); } @@ -86,7 +88,7 @@ int Send( int sockfd,char* Data, size_t sizeData ) int FDIOStream::write(const void* ptr, int numbytes) { - int numWrote = ::write(fd, (char*)ptr, numbytes); + int numWrote = ::_write(fd, (char*)ptr, numbytes); if(numWrote==numbytes) return numWrote; @@ -106,12 +108,12 @@ int FDIOStream::write(const void* ptr, int numbytes) throw IOException("Select returned an error on write"); if (FD_ISSET(fd, &fdSet)) { - numWrote = ::write(fd, (char*)ptr, numbytes); + numWrote = ::_write(fd, (char*)ptr, numbytes); if(numWrote==numbytes) return numWrote; } } - + perror("write error: "); fflush(stderr); throw IOException("Could not write all bytes to fd stream"); @@ -126,7 +128,7 @@ void FDIOStream::close() if (fd != INVALID_SOCKET) { char Buffer[128]; - sprintf(Buffer,"closesocket %d\n",fd); + sprintf_s(Buffer,"closesocket %d\n",fd); OutputDebugStringA(Buffer); shutdown( fd, SD_BOTH ); diff --git a/networktables/cpp/lib/Win32/src/main/native/networktables2/stream/SocketServerStreamProvider.cpp b/networktables/cpp/lib/Win32/src/main/native/networktables2/stream/SocketServerStreamProvider.cpp index 93634ecb0b..36a9cc1af8 100644 --- a/networktables/cpp/lib/Win32/src/main/native/networktables2/stream/SocketServerStreamProvider.cpp +++ b/networktables/cpp/lib/Win32/src/main/native/networktables2/stream/SocketServerStreamProvider.cpp @@ -4,7 +4,6 @@ * Created on: Sep 27, 2012 * Author: Mitchell Wills */ -#include "stdafx.h" #include "networktables2/stream/SocketServerStreamProvider.h" #include "networktables2/stream/FDIOStream.h" @@ -12,6 +11,7 @@ #include #include +#include #include #include #include diff --git a/networktables/cpp/lib/Win32/src/main/native/networktables2/stream/SocketStreamFactory.cpp b/networktables/cpp/lib/Win32/src/main/native/networktables2/stream/SocketStreamFactory.cpp index 7b362a6639..f3b3399047 100644 --- a/networktables/cpp/lib/Win32/src/main/native/networktables2/stream/SocketStreamFactory.cpp +++ b/networktables/cpp/lib/Win32/src/main/native/networktables2/stream/SocketStreamFactory.cpp @@ -4,10 +4,9 @@ * Created on: Nov 3, 2012 * Author: Mitchell Wills */ -#include "stdafx.h" - #include #include +#include #include #include #include @@ -53,7 +52,7 @@ IOStream *SocketStreamFactory::createStream(){ server = gethostbyname(host); - if (server == NULL) + if (server == NULL) throw 1; memset(&serv_addr, 0, sizeof(serv_addr)); @@ -75,7 +74,7 @@ IOStream *SocketStreamFactory::createStream(){ // [9/10/2013 JamesK] { char Buffer[128]; - sprintf(Buffer,"connecting %d\n",sockfd); + sprintf_s(Buffer,"connecting %d\n",sockfd); OutputDebugStringA(Buffer); } if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) == 0) @@ -117,7 +116,7 @@ IOStream *SocketStreamFactory::createStream(){ if (ErrorMsg) { char Buffer[1024]; - sprintf(Buffer,"ErrorMsg=%s WSA error=%d\n",ErrorMsg,WSAGetLastError()); + sprintf_s(Buffer,"ErrorMsg=%s WSA error=%d\n",ErrorMsg,WSAGetLastError()); OutputDebugStringA(Buffer); printf("ErrorMsg=%s WSA error=%d\n",ErrorMsg,WSAGetLastError()); diff --git a/networktables/cpp/lib/Win32/src/main/native/networktables2/thread/DefaultThreadManager.cpp b/networktables/cpp/lib/Win32/src/main/native/networktables2/thread/DefaultThreadManager.cpp index dcc8267d44..366198bbd8 100644 --- a/networktables/cpp/lib/Win32/src/main/native/networktables2/thread/DefaultThreadManager.cpp +++ b/networktables/cpp/lib/Win32/src/main/native/networktables2/thread/DefaultThreadManager.cpp @@ -3,58 +3,44 @@ * * Created on: Sep 21, 2012 * Author: Mitchell Wills + * Re-Created on: June 26, 2015 + * Author: Peter Mitrano */ -#include "../../../../../../../../stdafx.h" + +// Previous version used semaphores. +// This version was copied from the "Athena" version of network tables. +// It uses pthread and is much simpler #include "networktables2/thread/DefaultThreadManager.h" +#include #include -PeriodicNTThread::PeriodicNTThread(PeriodicRunnable* _r, const char* _name) : - name(_name), thread(new NTTask(name, (FUNCPTR)PeriodicNTThread::taskMain)), r(_r), run(true) -{ - fprintf(stdout, "Starting task: %s\n", name); - fflush(stdout); - thread->Start(this); +PeriodicNTThread::PeriodicNTThread(PeriodicRunnable* _r, const char* name) : r(_r), run(true){ + if(pthread_create(&thread, NULL, (void* (*)(void*))PeriodicNTThread::taskMain, (void*)this)) + throw std::exception(); } - -PeriodicNTThread::~PeriodicNTThread() -{ - stop(); - //TODO somehow do this async - if (thread) - { - delete thread; - thread=NULL; - } +PeriodicNTThread::~PeriodicNTThread(){ + stop(); + if(thread.x == pthread_self().x){ + fprintf(stderr, "WARNING: thread destructor called from this thread\n"); + } + pthread_join(thread, NULL); } - -int PeriodicNTThread::taskMain(PeriodicNTThread* o) -{ - //static wrapper - return o->_taskMain(); -} - -int PeriodicNTThread::_taskMain(){ - try { - while(run){ - r->run(); - } - } catch (...) { - fprintf(stdout, "Task exited with uncaught exception %s\n", name); - fflush(stdout); - return 1; - } - fprintf(stdout, "Task exited normally: %s\n", name); - fflush(stdout); +void* PeriodicNTThread::taskMain(PeriodicNTThread* o){//static wrapper + o->_taskMain(); return 0; } -void PeriodicNTThread::stop() -{ - run = false; +void PeriodicNTThread::_taskMain(){ + while(run){ + r->run(); + } +} +void PeriodicNTThread::stop() { + run = false; + //pthread_cancel(thread); } - bool PeriodicNTThread::isRunning() { - return thread->IsReady(); + return pthread_kill(thread, 0) == 0; } NTThread* DefaultThreadManager::newBlockingPeriodicThread(PeriodicRunnable* r, const char* name) { diff --git a/simulation/JavaGazebo/pom.xml b/simulation/JavaGazebo/pom.xml deleted file mode 100644 index 1d2f3a74f3..0000000000 --- a/simulation/JavaGazebo/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - 4.0.0 - org.gazebosim - JavaGazebo - jar - 0.1.0-SNAPSHOT - - - - docline-java8-disable - - [1.8, - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - -Xdoclint:none - - - - - - - - - - com.google.protobuf - protobuf-java - 2.5.0 - - - - - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - - - - org.apache.maven.plugins - maven-source-plugin - 2.3 - - - - diff --git a/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Connection.java b/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Connection.java index 5ddbfa39b0..994c78f0fc 100644 --- a/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Connection.java +++ b/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Connection.java @@ -5,6 +5,7 @@ import gazebo.msgs.GzTime.Time; import java.io.IOException; import java.net.ConnectException; +import java.net.InetAddress; import java.io.InputStream; import java.io.OutputStream; import java.net.ServerSocket; @@ -64,9 +65,17 @@ public class Connection { public void serve(final ServerCallback cb) throws IOException { ssocket = new ServerSocket(0); - host = ssocket.getInetAddress().getHostAddress(); // TODO: get globally addressable name. + host = ssocket.getInetAddress().getHostAddress(); port = ssocket.getLocalPort(); + //enable user to change master uri via environment variable GAZEBO_MASTER_URI + //TODO : allow for automatic guesing of IP. Look at Connection.cc in gazebo for C++ example + String user_defined_ip = System.getenv("GAZEBO_IP"); + if (user_defined_ip != null) { + host = InetAddress.getByName(user_defined_ip).getHostAddress();; + LOG.warning("Using custom host: "+host); + } + new Thread("Gazebo Server Thread") { @Override public void run() { diff --git a/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Node.java b/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Node.java index 90ff433378..455d4527cc 100644 --- a/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Node.java +++ b/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Node.java @@ -52,10 +52,30 @@ public class Node implements Runnable, ServerCallback { } public void waitForConnection() throws IOException, InterruptedException { + //enable user to change master uri via environment variable GAZEBO_MASTER_URI + String user_defined_uri = System.getenv("GAZEBO_MASTER_URI"); + String gazebo_master_uri = "localhost"; + int port = 11345; + if (user_defined_uri != null) { + String[] parts = user_defined_uri.split(":"); + if (parts.length != 2){ + LOG.severe("invalid GAZEBO_MASTER_URI " + user_defined_uri+ ". URI must be of the form HOSTNAME:PORT"); + LOG.warning("using default GAZEBO_MASTER_URI=localhost:11345"); + } + else { + gazebo_master_uri = parts[0]; + port = Integer.parseInt(parts[1]); + } + } + server.serve(this); - master.connectAndWait("localhost", 11345); + + LOG.info("GAZEBO_MASTER_URI is host=" + gazebo_master_uri + " port="+port); + + master.connectAndWait(gazebo_master_uri, port); + initializeConnection(); - + new Thread(this).start(); LOG.info("Serving on: "+server.host+":"+server.port); } @@ -66,9 +86,9 @@ public class Node implements Runnable, ServerCallback { String type = defaultMessage.getDescriptorForType().getFullName(); Publisher pub = new Publisher(topic, type, server.host, server.port); publishers.put(topic, pub); - + Publish req = Publish.newBuilder().setTopic(topic).setMsgType(type) - .setHost(server.host).setPort(server.port).build(); + .setHost(server.host).setPort(server.port).build(); try { master.writePacket("advertise", req); } catch (IOException e) { @@ -76,7 +96,7 @@ public class Node implements Runnable, ServerCallback { } return pub; } - + public synchronized Subscriber subscribe(String topic, T defaultMessage, SubscriberCallback cb) { topic = fixTopic(topic); @@ -84,7 +104,7 @@ public class Node implements Runnable, ServerCallback { if (subscriptions.containsKey(topic)) { throw new RuntimeException("Multiple subscribers for: "+topic); } - + String type = defaultMessage.getDescriptorForType().getFullName(); Subscribe req = Subscribe.newBuilder().setTopic(topic).setMsgType(type) .setHost(server.host).setPort(server.port).setLatching(false).build(); @@ -93,7 +113,7 @@ public class Node implements Runnable, ServerCallback { } catch (IOException e) { e.printStackTrace(); // FIXME: Shouldn't happen, should probably complain louder } - + Subscriber s = new Subscriber<>(topic, type, cb, defaultMessage, server.host, server.port); subscriptions.put(topic, s); @@ -122,7 +142,7 @@ public class Node implements Runnable, ServerCallback { e.printStackTrace(); // FIXME: Log } } - + private synchronized void initializeConnection() throws IOException { Packet initData = master.read(); if (!initData.getType().equals("version_init")) { @@ -135,12 +155,12 @@ public class Node implements Runnable, ServerCallback { String_V ns = String_V.parseFrom(namespaceData.getSerializedData()); namespaces.addAll(ns.getDataList()); LOG.info(namespaces.toString()); - - Packet publisherData = master.read(); + + Packet publisherData = master.read(); if (publisherData.getType().equals("publishers_init")) { Publishers pubs = Publishers.parseFrom(publisherData.getSerializedData()); for (Publish pub : pubs.getPublisherList()) { - PublisherRecord record = new RemotePublisherRecord(pub); + PublisherRecord record = new RemotePublisherRecord(pub); publishers.put(record.getTopic(), record); } LOG.info(publishers.toString()); @@ -148,7 +168,7 @@ public class Node implements Runnable, ServerCallback { LOG.severe("No publisher data received."); } } - + public synchronized void processPacket(Packet packet) throws InvalidProtocolBufferException { if (packet.getType().equals("publisher_add")) { PublisherRecord pub = new RemotePublisherRecord(Publish.parseFrom(packet.getSerializedData())); @@ -157,7 +177,7 @@ public class Node implements Runnable, ServerCallback { LOG.info("ACK "+pub.getTopic()); return; // This is us } - + LOG.info("New Publisher: "+pub.getTopic()); LOG.fine("Publisher: "+Publish.parseFrom(packet.getSerializedData())); publishers.put(pub.getTopic(), pub); @@ -169,7 +189,7 @@ public class Node implements Runnable, ServerCallback { LOG.info("Ignoring subscription request on (local) "+pub.getTopic()); return; // This is us } - + LOG.info("PUBSUB found for "+pub.getTopic()); LOG.fine("Publisher: "+Publish.parseFrom(packet.getSerializedData())); subscriptions.get(pub.getTopic()).connect(pub); @@ -185,6 +205,9 @@ public class Node implements Runnable, ServerCallback { } @Override + /** + * This is called when another node requests subscription to a topic we are publishing + */ public void handle(Connection conn) throws IOException { LOG.fine("Handling new connection"); Packet msg = conn.read(); @@ -192,7 +215,7 @@ public class Node implements Runnable, ServerCallback { LOG.warning("Read null message."); return; } - + if (msg.getType().equals("sub")) { Subscribe sub = Subscribe.parseFrom(msg.getSerializedData()); if (!publishers.containsKey(sub.getTopic())) { @@ -205,11 +228,12 @@ public class Node implements Runnable, ServerCallback { PublisherRecord pub = publishers.get(sub.getTopic()); if (!pub.getMsgType().equals(sub.getMsgType())) { LOG.severe(String.format("Message type mismatch requested=%d publishing=%s\n", - pub.getMsgType(), sub.getMsgType())); + pub.getMsgType(), sub.getMsgType())); return; } LOG.info("CONN " + sub.getTopic()); + //Tell the publisher that it has recieved a connection from a subscriver pub.connect(conn); } else { LOG.warning("Unknown message type: " + msg.getType()); diff --git a/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Publisher.java b/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Publisher.java index 6f9c622fe3..ebf9749bbe 100644 --- a/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Publisher.java +++ b/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Publisher.java @@ -65,6 +65,10 @@ public class Publisher implements PublisherRecord { } @Override + /** + * This function is called when another topic requests a subscription to a topic I am publishing + * Called in Node.java in the handle() function + */ public synchronized void connect(Connection conn) { LOG.fine("Handling subscriber connection for topic: "+topic); if (latching && lastMsg != null) { diff --git a/simulation/README.md b/simulation/README.md new file mode 100644 index 0000000000..eb58dd59d8 --- /dev/null +++ b/simulation/README.md @@ -0,0 +1,29 @@ +## Simulation Directory + +Observe the following directory structure + +. +|-- frc_gazebo_plugins (contains Gazebo Plugins) +| |-- clock +| |-- dc_motor +| |-- encoder +| |-- gyro +| |-- plugins +| |-- pneumatic_piston +| |-- potentiometer +| |-- rangefinder +| |-- servo +| +|-- frcsim.bat (launches gazebo with model/plugin paths on windows) +|-- frcsim.sh (launches gazebo with model/plugin paths on linux/mac) +|-- install.sh (convenient linux script to install Eclipse, Eclipse Plugins, and Gazebo) +|-- JavaGazebo (java library used by java simulation. Equivelant of the C++ gazebo_transport) +|-- SimDS (linux driverstation) + +The gazbeo plugins are currently built with CMake. +Eventually they will be built with gradle. + +All of this is delivered to students via the eclipse plugins + +## Building +see the top level building.md diff --git a/simulation/debs/.gitignore b/simulation/debs/.gitignore deleted file mode 100644 index 30236f9391..0000000000 --- a/simulation/debs/.gitignore +++ /dev/null @@ -1,54 +0,0 @@ -# General -*.log -build/ -screensteps/ -trash/ - -# TMP -*/*/debian/files -*/*/models/ -*/*/worlds -*/*/plugins/ -*/*/features/ -*/*/src/ -*/*/devel/ -*/*/.* -*/*/include/ -*/*/msgs/ - -*/*/clock/ -*/*/dc_motor/ -*/*/docs/ -*/*/encoder/ -*/*/*.doxy -*/*/gyro/ -*/*/limit_switch/ -*/*/pneumatic_piston/ -*/*/potentiometer/ -*/*/rangefinder/ -*/*/*.gradle -frcsim-gazebo-plugins/frcsim-gazebo-plugins/Makefile - -# General Build Artifacts -*.dsc -*.deb -*.orig.tar.gz -*.debian.tar.gz -*.changes -*.build -*.substvars -*/*/debian/*/DEBIAN/ - -# Specific Build Artifacts -frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/frcsim-gazebo-plugins/ -frcsim-gazebo-models/frcsim-gazebo-models/debian/frcsim-gazebo-models/ -frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/frcsim-eclipse-plugins/ -frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin/debian/frcsim-eclipse-toolchain-plugin/ -frcsim/frcsim/debian/frcsim/ -frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/frcsim-libwpilibsim-cpp/ - -frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/CMakeLists.txt - -# Generated Repository -repository/db/ -repository/dists/ \ No newline at end of file diff --git a/simulation/debs/Makefile b/simulation/debs/Makefile deleted file mode 100644 index 3b737513da..0000000000 --- a/simulation/debs/Makefile +++ /dev/null @@ -1,202 +0,0 @@ -codename=trusty -allwpilib=../.. - -package-version = 1 -gazebo-plugins-version = 0.2 -gazebo-plugins-package-version = $(gazebo-plugins-version)-$(package-version) -gazebo-models-version = 0.3 -gazebo-models-package-version = $(gazebo-models-version)-$(package-version) -gazebo-models-orig-url = https://usfirst.collab.net/sf/frs/do/downloadFile/projects.wpilib/frs.simulation.frcsim_gazebo_models/frs1070?dl=1 -eclipse-plugins-version = 0.1 -eclipse-plugins-package-version = $(eclipse-plugins-version)-$(package-version) -eclipse-toolchain-version = 0.1 -eclipse-toolchain-package-version = $(eclipse-toolchain-version)-$(package-version) -libwpilibsim-version = 0.1 -libwpilibsim-package-version = $(libwpilibsim-version)-$(package-version) -frcsim-version = 0.1 -frcsim-package-version = $(frcsim-version)-$(package-version) - -# Main Targets -.PHONY: all jenkins allwpilib pull debs update-repository clean-repository clean install - -all: update-repository - -jenkins: update-repository - -allwpilib: - cd $(allwpilib) && mvn -T 8 clean package -Dwith-eclipse-plugins -DskipTests -DskipIT - -orig: orig-frcsim-gazebo-plugins orig-frcsim-gazebo-models orig-frcsim-eclipse-plugins \ - orig-frcsim-libwpilibsim-cpp orig-frcsim - -debs: debs-frcsim-gazebo-plugins debs-frcsim-gazebo-models debs-frcsim-eclipse-plugins \ - debs-frcsim-libwpilibsim-cpp debs-frcsim - -update-repository: debs clean-repository - cd repository && reprepro includedeb $(codename) ../frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-package-version)_amd64.deb - cd repository && reprepro includedeb $(codename) ../frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-package-version)_i386.deb - cd repository && reprepro includedeb $(codename) ../frcsim-gazebo-models/frcsim-gazebo-models_$(gazebo-models-package-version)_all.deb - cd repository && reprepro includedeb $(codename) ../frcsim-eclipse-plugins/frcsim-eclipse-plugins_$(eclipse-plugins-package-version)_all.deb - # cd repository && reprepro includedeb $(codename) ../frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin_$(eclipse-toolchain-package-version)_all.deb - cd repository && reprepro includedeb $(codename) ../frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-package-version)_amd64.deb - cd repository && reprepro includedeb $(codename) ../frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-package-version)_i386.deb - cd repository && reprepro includedeb $(codename) ../frcsim/frcsim_$(frcsim-package-version)_all.deb - echo Repository Updated - -clean-repository: - cd repository && reprepro remove $(codename) frcsim-gazebo-plugins - cd repository && reprepro remove $(codename) frcsim-gazebo-models - cd repository && reprepro remove $(codename) frcsim-eclipse-plugins - # cd repository && reprepro remove $(codename) frcsim-eclipse-toolchain-plugin - cd repository && reprepro remove $(codename) frcsim-libwpilibsim-cpp - cd repository && reprepro remove $(codename) frcsim - -clean: - -rm frcsim-gazebo-models/frcsim-gazebo-models_$(gazebo-models-version).orig.tar.gz - -rm frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-version).orig.tar.gz - -rm frcsim-eclipse-plugins/frcsim-eclipse-plugins_$(eclipse-plugins-version).orig.tar.gz - -rm frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin_$(eclipse-toolchain-version).orig.tar.gz - -rm frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-version).orig.tar.gz - -rm frcsim/frcsim_$(frcsim-version).orig.tar.gz - - -rm frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-package-version)_amd64.deb - -rm frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-package-version)_i386.deb - -rm frcsim-gazebo-models/frcsim-gazebo-models_$(gazebo-models-package-version)_all.deb - -rm frcsim-eclipse-plugins/frcsim-eclipse-plugins_$(eclipse-plugins-package-version)_all.deb - -rm frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin_$(eclipse-toolchain-package-version)_all.deb - -rm frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-package-version)_amd64.deb - -rm frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-package-version)_i386.deb - -rm -r frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/allwpilib - -rm frcsim/frcsim_$(frcsim-package-version)_all.deb - -install: - sudo dpkg -i frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-package-version)_amd64.deb \ - frcsim-gazebo-models/frcsim-gazebo-models_$(gazebo-models-package-version)_all.deb \ - frcsim-eclipse-plugins/frcsim-eclipse-plugins_$(eclipse-plugins-package-version)_all.deb \ - frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-package-version)_amd64.deb \ - frcsim/frcsim_$(frcsim-package-version)_all.deb - -# orig support (for faster parallel builds) -.PHONY: orig-frcsim-gazebo-plugins orig-frcsim-gazebo-models orig-frcsim-eclipse-plugins \ - orig-frcsim-eclipse-toolchain-plugin orig-frcsim-libwpilibsim-cpp orig-frcsim -.PHONY: pull-gazebo-plugins pull-eclipse-plugins pull-libwpilibsim-cpp - -orig-frcsim-gazebo-models: frcsim-gazebo-models/frcsim-gazebo-models_$(gazebo-models-version).orig.tar.gz -frcsim-gazebo-models/frcsim-gazebo-models_$(gazebo-models-version).orig.tar.gz: - cd frcsim-gazebo-models && \ - wget --no-check-certificate $(gazebo-models-orig-url) -O frcsim-gazebo-models_$(gazebo-models-version).orig.tar.gz && \ - tar xvf frcsim-gazebo-models_$(gazebo-models-version).orig.tar.gz - -orig-frcsim-gazebo-plugins: frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-version).orig.tar.gz -pull-gazebo-plugins: - cp -rf -t frcsim-gazebo-plugins/frcsim-gazebo-plugins/ $(allwpilib)/simulation/frc_gazebo_plugins/* - echo Increment version? -frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-version).orig.tar.gz: pull-gazebo-plugins - cd frcsim-gazebo-plugins/frcsim-gazebo-plugins && debuild clean - rm -f frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-version).orig.tar.gz - cd frcsim-gazebo-plugins && tar --exclude="./debian" -czvf \ - frcsim-gazebo-plugins_$(gazebo-plugins-version).orig.tar.gz frcsim-gazebo-plugins - -orig-frcsim-eclipse-plugins: frcsim-eclipse-plugins/frcsim-eclipse-plugins_$(eclipse-plugins-version).orig.tar.gz -pull-eclipse-plugins: - rm -rf frcsim-eclipse-plugins/frcsim-eclipse-plugins/plugins - rm -rf frcsim-eclipse-plugins/frcsim-eclipse-plugins/features - mkdir -p frcsim-eclipse-plugins/frcsim-eclipse-plugins/plugins - mkdir -p frcsim-eclipse-plugins/frcsim-eclipse-plugins/features - cp $(allwpilib)/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/target/site/plugins/edu.wpi.first.wpilib.plugins.java_* frcsim-eclipse-plugins/frcsim-eclipse-plugins/plugins - cp $(allwpilib)/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/target/site/plugins/edu.wpi.first.wpilib.plugins.cpp_* frcsim-eclipse-plugins/frcsim-eclipse-plugins/plugins - cp $(allwpilib)/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/target/site/plugins/edu.wpi.first.wpilib.plugins.core_* frcsim-eclipse-plugins/frcsim-eclipse-plugins/plugins - cp $(allwpilib)/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/target/site/features/edu.wpi.first.wpilib.plugins.java.feature_* frcsim-eclipse-plugins/frcsim-eclipse-plugins/features - cp $(allwpilib)/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/target/site/features/edu.wpi.first.wpilib.plugins.cpp.feature_* frcsim-eclipse-plugins/frcsim-eclipse-plugins/features - cp $(allwpilib)/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/target/site/features/edu.wpi.first.wpilib.plugins.core.feature_* frcsim-eclipse-plugins/frcsim-eclipse-plugins/features - echo Increment version? -frcsim-eclipse-plugins/frcsim-eclipse-plugins_$(eclipse-plugins-version).orig.tar.gz: pull-eclipse-plugins - cd frcsim-eclipse-plugins/frcsim-eclipse-plugins && debuild clean - rm -f frcsim-eclipse-plugins/frcsim-eclipse-plugins_$(eclipse-plugins-version).orig.tar.gz - cd frcsim-eclipse-plugins && tar --exclude="./debian" -czvf \ - frcsim-eclipse-plugins_$(eclipse-plugins-version).orig.tar.gz frcsim-eclipse-plugins - -orig-frcsim-eclipse-toolchain-plugin: frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin_$(eclipse-toolchain-version).orig.tar.gz -pull-eclipse-toolchain: - rm -rf frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin/plugins - rm -rf frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin/features - mkdir -p frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin/plugins - mkdir -p frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin/features - cp $(allwpilib)/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/target/site/plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux_* frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin/plugins/ - cp $(allwpilib)/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/target/site/features/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature_* frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin/features/ - echo Increment version? -frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin_$(eclipse-toolchain-version).orig.tar.gz: pull-eclipse-toolchain - cd frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin && debuild clean - rm -f frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin_$(eclipse-toolchain-version).orig.tar.gz - cd frcsim-eclipse-toolchain-plugin && tar --exclude="./debian" -czvf \ - frcsim-eclipse-toolchain-plugin_$(eclipse-toolchain-version).orig.tar.gz frcsim-eclipse-toolchain-plugin - -orig-frcsim-libwpilibsim-cpp: frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-version).orig.tar.gz -pull-libwpilibsim-cpp: - mkdir -p frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/allwpilib - cp -rf $(allwpilib)/hal frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/allwpilib - mkdir -p frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/allwpilib/networktables - cp -rf $(allwpilib)/networktables/cpp frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/allwpilib/networktables - mkdir -p frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/allwpilib/wpilibc - cp -r $(allwpilib)/wpilibc/wpilibC++ frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/allwpilib/wpilibc/wpilibC++ - cp -r $(allwpilib)/wpilibc/wpilibC++Sim frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/allwpilib/wpilibc/wpilibC++Sim - echo 'cmake_minimum_required(VERSION 2.8)' > frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/CMakeLists.txt - echo 'project(WPILibSim)' >> frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/CMakeLists.txt - echo 'add_subdirectory(allwpilib/wpilibc/wpilibC++Sim)' >> frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/CMakeLists.txt - echo Increment version? -frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-version).orig.tar.gz: pull-libwpilibsim-cpp - cd frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp && debuild clean - rm -f frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-version).orig.tar.gz - cd frcsim-libwpilibsim-cpp && tar --exclude="./debian" -czvf \ - frcsim-libwpilibsim-cpp_$(libwpilibsim-version).orig.tar.gz frcsim-libwpilibsim-cpp - -orig-frcsim: frcsim/frcsim_$(frcsim-version).orig.tar.gz -frcsim/frcsim_$(frcsim-version).orig.tar.gz: - cd frcsim/frcsim && debuild clean - rm -f frcsim/frcsim_$(frcsim-version).orig.tar.gz - cd frcsim && tar --exclude="./debian" -czvf \ - frcsim_$(frcsim-version).orig.tar.gz frcsim - -# debs support (for faster parallel builds) -.PHONY: debs-frcsim-gazebo-plugins debs-frcsim-gazebo-models debs-frcsim-eclipse-plugins \ - debs-frcsim-eclipse-toolchain-plugin debs-frcsim-libwpilibsim-cpp debs-frcsim - -debs-frcsim-gazebo-plugins: frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-package-version)_amd64.deb frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-package-version)_i386.deb -frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-package-version)_i386.deb: frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-version).orig.tar.gz frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-package-version)_amd64.deb - cd frcsim-gazebo-plugins/frcsim-gazebo-plugins && make clean - cd frcsim-gazebo-plugins && sbuild --arch=i386 -A -d trusty-i386 frcsim-gazebo-plugins_$(gazebo-plugins-package-version).dsc -frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-package-version)_amd64.deb: frcsim-gazebo-plugins/frcsim-gazebo-plugins_$(gazebo-plugins-version).orig.tar.gz - cd frcsim-gazebo-plugins/frcsim-gazebo-plugins && debuild --no-lintian -us -uc -aamd64 - -debs-frcsim-gazebo-models: frcsim-gazebo-models/frcsim-gazebo-models_$(gazebo-models-package-version)_all.deb -frcsim-gazebo-models/frcsim-gazebo-models_$(gazebo-models-package-version)_all.deb: frcsim-gazebo-models/frcsim-gazebo-models_$(gazebo-models-version).orig.tar.gz - cd frcsim-gazebo-models/frcsim-gazebo-models && debuild --no-lintian -us -uc - -debs-frcsim-eclipse-plugins: frcsim-eclipse-plugins/frcsim-eclipse-plugins_$(eclipse-plugins-package-version)_all.deb -frcsim-eclipse-plugins/frcsim-eclipse-plugins_$(eclipse-plugins-package-version)_all.deb: frcsim-eclipse-plugins/frcsim-eclipse-plugins_$(eclipse-plugins-version).orig.tar.gz - cd frcsim-eclipse-plugins/frcsim-eclipse-plugins && debuild --no-lintian -us -uc - -debs-frcsim-eclipse-toolchain-plugin: frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin_$(eclipse-toolchain-package-version)_all.deb -frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin_$(eclipse-toolchain-package-version)_all.deb: frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin_$(eclipse-toolchain-version).orig.tar.gz - cd frcsim-eclipse-toolchain-plugin/frcsim-eclipse-toolchain-plugin && debuild --no-lintian -us -uc - -debs-frcsim-libwpilibsim-cpp: frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-package-version)_amd64.deb frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-package-version)_i386.deb -frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-package-version)_i386.deb: frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-version).orig.tar.gz frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-package-version)_amd64.deb - cd frcsim-libwpilibsim-cpp && sbuild --arch=i386 -A -d trusty-i386 frcsim-libwpilibsim-cpp_$(libwpilibsim-package-version).dsc -frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-package-version)_amd64.deb: frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp_$(libwpilibsim-version).orig.tar.gz - cd frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp && debuild --no-lintian -us -uc -aamd64 - -debs-frcsim: frcsim/frcsim_$(frcsim-package-version)_all.deb -frcsim/frcsim_$(frcsim-package-version)_all.deb: frcsim/frcsim_$(frcsim-version).orig.tar.gz - cd frcsim/frcsim && debuild --no-lintian -us -uc - -### SBUILD -# -# For building 32-bit builds on 64-bit machines -# -# $ mk-sbuild --arch i386 --personality=linux32 trusty -# To CHANGE the golden image: sudo schroot -c source:trusty-i386 -u root -# To ENTER an image snapshot: schroot -c trusty-i386 -# To BUILD within a snapshot: sbuild -A -d trusty-i386 PACKAGE*.dsc -# -# sbuild --arch=i386 -A -d trusty-i386 frcsim-gazebo-plugins_0.2-1.dsc diff --git a/simulation/debs/README.org b/simulation/debs/README.org deleted file mode 100644 index 7514e366df..0000000000 --- a/simulation/debs/README.org +++ /dev/null @@ -1,20 +0,0 @@ - -* Setting up apt-repository -: sudo apt-get install reprepro -http://kaivanov.blogspot.com/2012/08/creating-apt-repository-with-reprepro.html -** One-Time -- Get signing key -: gpg --armor --output frcsim.key --export - -** To build and add debs -: make -: rsync -r repository/ adhenning@ccc.wpi.edu:public_html/frcsim # Syncs repo - -** To use -: sudo nano /etc/apt/sources.list.d/frcsim-latest.list -: deb http://users.wpi.edu/~adhenning/frcsim raring main -: deb-src http://users.wpi.edu/~adhenning/frcsim raring main - -: curl -H GET users.wpi.edu/~adhenning/frcsim.key | sudo apt-key add - -: sudo apt-get update -: sudo apt-get install frcsim diff --git a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/Makefile b/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/Makefile deleted file mode 100644 index 6915b97601..0000000000 --- a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -prefix = /usr -eclipsedir = $(prefix)/share/eclipse/dropins/frcsim -plugindir = $(eclipsedir)/plugins -featuredir = $(eclipsedir)/features - -all: clean - sh ./genfeatures.sh - -clean: - rm -rf build - -install: all - mkdir -p $(DESTDIR)$(plugindir) - mkdir -p $(DESTDIR)$(featuredir) - install plugins/** $(DESTDIR)$(plugindir) - cp -r build/features/** $(DESTDIR)$(featuredir) diff --git a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/changelog b/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/changelog deleted file mode 100644 index 5fd3453658..0000000000 --- a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -frcsim-eclipse-plugins (0.1-1) trusty; urgency=low - - * Initial release. - - -- Alex Henning Wed, 14 May 2014 21:04:27 -0400 diff --git a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/compat b/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/compat deleted file mode 100644 index ec635144f6..0000000000 --- a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/control b/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/control deleted file mode 100644 index 75b9f6036b..0000000000 --- a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/control +++ /dev/null @@ -1,13 +0,0 @@ -Source: frcsim-eclipse-plugins -Maintainer: Alex Henning -Section: misc -Priority: optional -Standards-Version: 3.9.4 -Build-Depends: debhelper (>= 9) - -Package: frcsim-eclipse-plugins -Architecture: all -Depends: ${shlibs:Depends}, ${misc:Depends}, eclipse, eclipse-jdt, eclipse-cdt, eclipse-rse, eclipse-cdt-launch-remote, g++, libwebkitgtk-1.0-0, frcsim-libwpilibsim-cpp -Description: FRC plugin for developing code for RoboRIO and WPILibSim. - This plugin allows the usage of eclipse for development of WPILib - robot code for the RoboRIO and simulation in gazebo. \ No newline at end of file diff --git a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/copyright b/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/copyright deleted file mode 100644 index d7484bdd8c..0000000000 --- a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/copyright +++ /dev/null @@ -1,25 +0,0 @@ -Copyright -Copyright (c) 2009 FIRST -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the FIRST nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/rules b/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/rules deleted file mode 100755 index cbe925d758..0000000000 --- a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/rules +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/make -f -%: - dh $@ diff --git a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/source/format b/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/source/format deleted file mode 100644 index 46ebe02665..0000000000 --- a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (quilt) \ No newline at end of file diff --git a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/genfeatures.sh b/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/genfeatures.sh deleted file mode 100644 index 8363a2d0ae..0000000000 --- a/simulation/debs/frcsim-eclipse-plugins/frcsim-eclipse-plugins/genfeatures.sh +++ /dev/null @@ -1,8 +0,0 @@ -mkdir -p build/zips/features -mkdir -p build/features -for i in features/*.jar; do - echo $i - cp $i build/zips/$i.zip; - mkdir build/$i - unzip build/zips/$i.zip -d build/$i -done diff --git a/simulation/debs/frcsim-eclipse-plugins/version b/simulation/debs/frcsim-eclipse-plugins/version deleted file mode 100644 index 6da28dde76..0000000000 --- a/simulation/debs/frcsim-eclipse-plugins/version +++ /dev/null @@ -1 +0,0 @@ -0.1.1 \ No newline at end of file diff --git a/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/Makefile b/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/Makefile deleted file mode 100644 index 1d5f3b130d..0000000000 --- a/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -prefix = /usr -frcsimdir = $(prefix)/share/frcsim -modeldir = $(frcsimdir)/models -worlddir = $(frcsimdir)/worlds - -all: - echo Should download files - -clean: - echo Cleaning - -install: all - mkdir -p $(DESTDIR)$(modeldir) - mkdir -p $(DESTDIR)$(worlddir) - cp -r models/** $(DESTDIR)$(modeldir) - cp -r worlds/** $(DESTDIR)$(worlddir) diff --git a/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/changelog b/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/changelog deleted file mode 100644 index 618ea80006..0000000000 --- a/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/changelog +++ /dev/null @@ -1,17 +0,0 @@ -frcsim-gazebo-models (0.3-1) trusty; urgency=medium - - * Fixed GearsBot gyro - - -- Alex Henning Tue, 12 Aug 2014 09:32:27 -0400 - -frcsim-gazebo-models (0.2-1) trusty; urgency=medium - - * New models using the smaller plugins - - -- Alex Henning Mon, 07 Jul 2014 12:52:50 -0700 - -frcsim-gazebo-models (0.1-1) trusty; urgency=low - - * Initial release. - - -- Alex Henning Wed, 14 May 2014 17:13:26 -0400 diff --git a/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/compat b/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/compat deleted file mode 100644 index ec635144f6..0000000000 --- a/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/control b/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/control deleted file mode 100644 index a6a8d02f4b..0000000000 --- a/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/control +++ /dev/null @@ -1,13 +0,0 @@ -Source: frcsim-gazebo-models -Maintainer: Alex Henning -Section: misc -Priority: optional -Standards-Version: 3.9.4 -Build-Depends: debhelper (>= 9) - -Package: frcsim-gazebo-models -Architecture: all -Depends: ${shlibs:Depends}, ${misc:Depends}, frcsim-gazebo-plugins -Description: FRC models that can be used in Gazebo. - Models that can be used in Gazebo to simulate FRC-like - robots are controllable through WPILibSim (Java or C++) \ No newline at end of file diff --git a/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/copyright b/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/copyright deleted file mode 100644 index d7484bdd8c..0000000000 --- a/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/copyright +++ /dev/null @@ -1,25 +0,0 @@ -Copyright -Copyright (c) 2009 FIRST -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the FIRST nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/rules b/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/rules deleted file mode 100755 index cbe925d758..0000000000 --- a/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/rules +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/make -f -%: - dh $@ diff --git a/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/source/format b/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/source/format deleted file mode 100644 index 46ebe02665..0000000000 --- a/simulation/debs/frcsim-gazebo-models/frcsim-gazebo-models/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (quilt) \ No newline at end of file diff --git a/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/changelog b/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/changelog deleted file mode 100644 index 58e45a5e4c..0000000000 --- a/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/changelog +++ /dev/null @@ -1,11 +0,0 @@ -frcsim-gazebo-plugins (0.2-1) trusty; urgency=medium - - * Split plugin into many parts. - - -- Alex Henning Wed, 02 Jul 2014 13:50:38 -0700 - -frcsim-gazebo-plugins (0.1-1) trusty; urgency=low - - * Initial release - - -- Alex Henning Wed, 14 May 2014 16:22:26 -0400 diff --git a/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/compat b/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/compat deleted file mode 100644 index ec635144f6..0000000000 --- a/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/control b/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/control deleted file mode 100644 index 7d115e1fc1..0000000000 --- a/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/control +++ /dev/null @@ -1,13 +0,0 @@ -Source: frcsim-gazebo-plugins -Maintainer: Alex Henning -Section: misc -Priority: optional -Standards-Version: 3.9.4 -Build-Depends: debhelper (>= 9), gazebo3, libgazebo-dev, libavcodec-dev, libavformat-dev, libswscale-dev - -Package: frcsim-gazebo-plugins -Architecture: i386 amd64 -Depends: ${shlibs:Depends}, ${misc:Depends}, gazebo3, libgazebo-dev, libavcodec-dev, libswscale-dev -Description: FRC plugin for controlling robots in the gazebo plugin. - This plugin allows robots in gazebo to communicate with WPILib - programs and enables the control of the robots. \ No newline at end of file diff --git a/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/copyright b/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/copyright deleted file mode 100644 index d7484bdd8c..0000000000 --- a/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/copyright +++ /dev/null @@ -1,25 +0,0 @@ -Copyright -Copyright (c) 2009 FIRST -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the FIRST nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/rules b/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/rules deleted file mode 100755 index 1b48bf7732..0000000000 --- a/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/rules +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/make -f -%: - dh $@ - -override_dh_strip: - strip --remove-section=.comment --remove-section=.note --strip-unneeded debian/frcsim-gazebo-plugins/usr/lib/frcsim/plugins/libgz_potentiometer.so diff --git a/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/source/format b/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/source/format deleted file mode 100644 index 46ebe02665..0000000000 --- a/simulation/debs/frcsim-gazebo-plugins/frcsim-gazebo-plugins/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (quilt) \ No newline at end of file diff --git a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/Makefile b/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/Makefile deleted file mode 100644 index 588fe4dee1..0000000000 --- a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -prefix = /usr -lib.dir = $(prefix)/lib -build.dir = build -allwpilib = ../.. - -all: - mkdir -p $(build.dir) - cd build && cmake .. && make - # cp -r $(allwpilib)/wpilibc/wpilibC++ build - # cd ${build.dir} && ALLWPILIB=$(allwpilib) cmake .. && make - -clean: - rm -rf $(build.dir) - -install: all - mkdir -p $(DESTDIR)$(lib.dir) - install build/allwpilib/wpilibc/wpilibC++Sim/libWPILibSim.so $(DESTDIR)$(lib.dir) - # install $(build.dir)/libWPILibSim.so $(DESTDIR)$(lib.dir) - # install $(build.dir)/build/wpilibC++/libWPILib.a $(DESTDIR)$(lib.dir) diff --git a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/changelog b/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/changelog deleted file mode 100644 index f337b6ba2e..0000000000 --- a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -frcsim-libwpilibsim-cpp (0.1-1) trusty; urgency=low - - * Initial release. - - -- Alex Henning Wed, 06 June 2014 21:04:27 -0400 diff --git a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/compat b/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/compat deleted file mode 100644 index ec635144f6..0000000000 --- a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/control b/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/control deleted file mode 100644 index b930686dc6..0000000000 --- a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/control +++ /dev/null @@ -1,13 +0,0 @@ -Source: frcsim-libwpilibsim-cpp -Maintainer: Alex Henning -Section: misc -Priority: optional -Standards-Version: 3.9.4 -Build-Depends: debhelper (>= 9) - -Package: frcsim-libwpilibsim-cpp -Architecture: i386 amd64 -Depends: ${shlibs:Depends}, ${misc:Depends}, libboost-system-dev, libprotobuf-dev -Description: Installs `libWPILibSim.so`. - Install platform specific libWPILibSim library necessary to run C++ - frcsim programs. \ No newline at end of file diff --git a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/copyright b/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/copyright deleted file mode 100644 index d7484bdd8c..0000000000 --- a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/copyright +++ /dev/null @@ -1,25 +0,0 @@ -Copyright -Copyright (c) 2009 FIRST -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the FIRST nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/debianpackage/usr/lib/libWPILibSim.so b/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/debianpackage/usr/lib/libWPILibSim.so deleted file mode 100755 index 9109406255..0000000000 Binary files a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/debianpackage/usr/lib/libWPILibSim.so and /dev/null differ diff --git a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/rules b/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/rules deleted file mode 100755 index 16d52217b1..0000000000 --- a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/rules +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/make -f - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -export DH_OPTIONS - -export DESTDIR=$$(pwd)/debian/frcsim-libwpilibsim-cpp - -%: - dh $@ - -override_dh_strip: diff --git a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/source/format b/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/source/format deleted file mode 100644 index 46ebe02665..0000000000 --- a/simulation/debs/frcsim-libwpilibsim-cpp/frcsim-libwpilibsim-cpp/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (quilt) \ No newline at end of file diff --git a/simulation/debs/frcsim.key b/simulation/debs/frcsim.key deleted file mode 100644 index 96f7147227..0000000000 --- a/simulation/debs/frcsim.key +++ /dev/null @@ -1,97 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1.4.12 (GNU/Linux) - -mQGiBEsnpscRBACyclffkMVkXXdtY2qTT2+B6HN4hBoUxBwZBULyHFuSP9lsB7wK -16Hl5ZTu+oy+GegzzFRrHWxBLN9i67T0plNkqDJhWUrmXR7xvX+dFc+Qrl+uPR0i -CY1NMnWwnFh01YtYb9NAlb3bLn8RLBH8Zo60i7wfwdW9Wi1mgzmUT/UI9wCg7y6R -VmF4RjNWJ2WRdL/jVeAB8H0D/0xfePoYWrSGzOp7+Vl+xYo5TdSrzohUUnly6xla -UIKwlBCG/jpQqKH17803GpkFyh5FxG1Db7VWsciDv7flcBLPtn75gU2fPHXL+gnv -r1eJ+ugQwCl4/8d4iJ5TMXmHQOW2Pd0U47OmbZYNNgtA+lXhF8n8+6w3GRhqubLF -/9b/A/4wH37bv1shLhdLpP+9WYHc8z9+jmStVUFdAGoD/n6vOpBX+GQYaEY5Y8RS -Wf0DFhMF6CFYNZ2ngDyvPt53M2jU7hrxXIfs/b5bLMqG2et9M/avdEWGUKTsC7wu -0zeGtD07r9EA3WDIhxN9QEGZAq5Q3NSbedMHIVE4Ynq7VNCdsrQ0SFBMSVAgKEhQ -IExpbnV4IEltYWdpbmcgYW5kIFByaW50aW5nKSA8aHBsaXBAaHAuY29tPohgBBMR -AgAgBQJLJ6bHAhsDBgsJCAcDAgQVAggDBBYCAwECHgECF4AACgkQc9dwzaWQR7n4 -dQCghZgIpxuTC+GhiQIO0dK9wTlbMmoAoOB252fEOvf73v8Ya8qmN1GlmYiXiJwE -EAECAAYFAk7UORAACgkQnsV5kCcUcIjUuAP8D2rK0KZyA0uHyap2BkF5U4wm6qQ3 -p27K0hh50dZMIMSt3FH0TpW994jaoqBKqrHBk3U+/ZT4tD43hmaqc+XmnYNrNMRO -KBwkjEzKeKaOBXd1I5Tid0I2u1L6bl5IlQzujbWsn/5YbWypLlZhf3Hxg8uuHYu9 -kiQLYM4jqIi0YgSJARwEEAECAAYFAk3NP24ACgkQd7E6jROY7coc8Af8DYe87G2u -OSSPGkebecci11oTX9mudvDCQkuTFBcGPlMnPl6bn5QcMjBxuAm2TO0mYlR0QcPU -vQ+tNypw4AZGfsgnvG1EsxSfTgiR6tD2KdIZD8GJw/GudmtUgF3sZkw1txLkk57u -YufHc9u56oMvntAaU7nisosE1rdqON9fLf+tqvMcrX2+8tDHobfimltC+J+F5dyx -Cnef+zB9/+dzAAjiunicNZ35zv9tKBh83kECPUpScpHjrXxAqdSHrNlnjGZdmiFB -0luSbPCIF8sYyLYb5W+Sw1t7WsZ1XRgq67gTV8Vw2o9jw10a/vclwFHeVEtius6g -Cj0CwkJ1uRuiLokCHAQQAQgABgUCUyRUlQAKCRAiOiyqVhRgQO6aEACMI+JH0ZVW -WxbaV5aNC+64kMIXRdOZEoRFoTW2i0B0yoLLjQbHnnt+wxTa18PXVYG8KZPzcLiD -TsZrt75cA+6xE1iu9HpTdJD08aiJE7EKV4tVZGpg65SkpU3HQ8X4YfGaT7jgutyK -66AUBYDXhxO0sx/sSsth0k3veUIaSwBncmP/S+/rguWhiU2d8MOtNtnCcTe9q7+y -n2KyRrhPlLVpJDAKeHTaULiUyLFCjHLHm84o6hiaoR3C/d/d+kC5g/ntPwXGP8vV -7W/Y3A8ZjhNjgVen3w1EgR/aCjHCHo3sry9Cs7IVb7kLdWhomSnwmYYLdbIXJbXe -IQRMMcYYt1gsia8s1tyK8rAGHCTCWebG6Y1sbNolG2peaTNrC9YnPwweT0TwcPzV -Pyj5+aZAwnnMQDajbxLmzmgjyybF+OkqFvDHEycYiM1v6TwAuw+Ols7/faK6XBIU -9O/YWwhLOULpM2P7Z7hn9u/xGfdM6O0xZyPiiQKlaBH7r8utvNM2BpsDIvbVYCuJ -YOyt4r1jhqf/EAkck2mEg7b55lEpJPjO6JQG3+OUuJHBpWtZFGKFBBP+vKvDURs7 -cqk40m3laINIFyoUo0DaWdITdXD9rj90jNpYrVZKTqL9TsVuo2VcCBdYq1q8cNLy -GwRfhRlEfrL8wHHm5BF1bJ8lK3oWrU9yqLkCDQRLJ6bHEAgAhDv8Ifl/QKaJONb5 -/qm8uWC70rlzXLm9YlUpbAcr/tvCkG271wzT4Sz/cHTvQ5s3yBsGq49Li7Z9IfVF -k5xKV0mdGyiZwmHOxmaVL3DcoyLkrOvYStqy3d/DEm9YaAWiAi42REVIXvmRsJce -87wCIIY/rLNbncKXOj3HTzWopqfnJPf/nkqYqwWbFkQxMmGfK9E84dLwjGRtwCWb -5uN/YLM3uSJrwLfsRZbmEQhzAJF2mIplwIqR3R7naruQdfyjad5EXOvKQ8P5MxUi -eGxHUlv90LuYCcW+MvVw0zIqchbdWGaz+LGCTRDAIyJZZzB6kLCuHn3TWPyUpPds -BI5jfwAECwf+Nl+UUqw0HPZP9kXYG0VED1wFxWEckgzLeF32kDQGIlNp0NbYcSbi -8xS56fFbpszA+LZrJgTZmnFRUwDCclma7punj3b8nM0gRtHvuLentmAhnQPIX8SW -DRwhBNIujSOxQrtjjw6oFyrMlYqpe73IUAAINzeCCwZXKDvOiTgm7oI/mI6fJiNr -c8NqNxhGS4Bzw/rexAhZngekMqR9Nglxk7EzUOqrffc6/Orq1fE2t/UNAOqVVfNX -5F2hiINXi1+ywhOYOJVfQ/xuil2FmI7txAc/7XmUcqxNwayjOzBKlVHIAcIyLMAT -w3yRVvh+gezGvUbE9HnyYHq7nO9dmenM7YhJBBgRAgAJBQJLJ6bHAhsMAAoJEHPX -cM2lkEe5pLMAnA/kDShHCzfV5loZcyX8M41tzSYDAJ4jUTgQV69+3QpJmsE3GoCk -sIYlMZkCDQRTdNZlARAAoxFGU8l2Ab8byV4UOZE1uVR+euj2oMcTcnspO7cALEEs -xxNWYOoSmQLZtpv5eDAZp1EW9SPAuWkZ0RMj+mhiHxTqU1EYTCUzVYo+3qjfVzds -6SVw566fM4E0X2n29ABOOBWQ9Y5RJivB5s1yTaPNptUBeitbJOc8oDfa9raqkvm0 -1/MFLlmMNwEbsBgvgZnjbhNTJIVta/fHc2mGvSL/p1m8XZmIM+xh3XY7wo7aqhx8 -v9QuAWr7SgzwKmHH7JyT76qBo07DnM6bIvQHV+grgFAeU9qATawFob7qqqmDDttu -ajzd8/k+x07MswR30qNj0ufahuq5ttjuhVHGptwhjYmZVuJWrxsEWCWT/WkZp6AL -76094revWr3KRzuEbw2LJWLOEo4ePQpj4gBmNl3dPi9Hs936si7QIr/AJWyhgpi+ -Kc4Dz8qA6elJ1T0gdaPPppK8n+ErNoBVJn0D5m1iUS3u7aSoyaTtlTjDeZgZYXAh -AX4uVNJl/4CwgPBBlpwJ+KpCcaQfA5P8Zgmdmp8rZfjfHmMWs4+CVgyEHUPD3NEY -0wlbwBNUW+ruqkaB/k8HkXfJF5hCAjUjmHeYXjeUfNr3qzmmivzXe/9PwJ2ldBRc -LTSMt7RuBGuE0wyFoTNQgbnmIySIWI+t+huu/7fGIp2hb53OMukk20plkLKXyyUA -EQEAAbQnQWxleCBIZW5uaW5nIDxhbGV4QHRob3JpdW1yb2JvdGljcy5jb20+iQI4 -BBMBAgAiBQJTdNZlAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRDFiL18 -E/NeP2mTD/4w8iqmfxlEGlFA0MpcmYk3TKaUUR7iBNdxEIS/3ed35G8tlttrZoTm -AqDsyZGTzDgbcwYa9Brrz+SRx3JSCa0mkhnMuXkwjVRR+31UsYlK3sVEUW8OAMtZ -QMVTfoGke1SX7QrTUIIBQmWeARiIoarAuWfCeVVHMng2ytIDbrFBtaKNTRjz4i47 -an0Yh0V0GvZE/3lv2ZVdJyVR+bxTZp2ECPWQyY8838w7iqvGJTm0akBt43IcaseI -vlPDuhpzNYaK1yHeQ1yahMV8EYSBImUfJdhN5HGvNzM+NNpSGugqD7XB5edQEVKv -kCyd+QXEddmozzh3Ga2sIzK+Yj84WHFzBX9riAkwpY2GyEmAEShw2lAK4KZGhYFS -iUfeADy2rn7bpXIYp29fQA2xqGUQWgXi6Eii4eOOyFMJ6LxIeMtwMRhZ7tJmgD9y -6PnaczyiLyIk/zE32KkgSsKUvrlIYE+gFayleYPFmgl7UtmvnFcqLZUZsB3FfjyN -DdKT3g2qMSjsGh7B5jd5HbH+kEJV87opNyMtcnCZ1kcsA2p8a1FDpw847NDwg/o1 -q9JCEh7oA4lqUR5S/MhRkfUhGLlqXoi+FCgYJcG/jBejr04CKTI7dx6ndJisUuBU -PU9pdJz6KF8YM2AiCGvvFWecuWsaF+frEpYspsxS+O7tzr+3zMxJobkCDQRTdNZl -ARAA1j8K1g58SdeQpXY0NUJSMEGXE5Ct5cIsxTa+y/+7c4M832nU5NKmeBIH6RDu -nmtGHH7Sb9qQgCxgeFv+67DDquo8F5Ej9pSY0mTEh5s3buKm6KZ/4am3J9wIa6mZ -2SC4A4kk27YzVaTbX5pA3mXYzVlN5c9YnqFX0NgFbtIMd3dMyLqPcZab3SWMwLw/ -e7rGZx3W3VuGAi+JiwNNTo9Bw7GhEgo/GmXct5Ja7mCz+WYZs5nRZs28NSvTgg51 -2FfbgMmGn56m9/dmkB9Tw7gmxCoIYmYHP4MPJcERHWqRfjEHNlVmnOUgPenYxrX1 -kY9ckf6QujmuFKIDxElDIusq1e7c46iBsfxuaV4C7O1exxg3k5zKiX4CcSly3cwq -RgpdYvghFr5zwNkSF+hTHmS0IxT0TNf7W8VCw4kOd7JtNp+tUK86EGdPfiv741lE -Z+n+6ZT1p1NXWkmdBgyagnpMsZvRmIdCCRJe2L7XYUZiofhe5hsk4g4I9b9drLuq -qEqQTbVI3lHDbCGBnAlPdtM24Ex1dhzkhxy940J8lWUo9c7JHxHoOscgw5m+OjHu -oaIDlqByWLzaCgauu8O4nkhPoBEUP2cT2UrXfiq0eX8ruJunBNPk9Md1ThvhA37k -LD7vRWziSJnN5NiuH0QVVE8/CnVB9pKPM+aSgx2XoW26f5kAEQEAAYkCHwQYAQIA -CQUCU3TWZQIbDAAKCRDFiL18E/NeP2dTD/48LSf37o78JfbR0myAeHP1PcURzySq -Yl8C87k8au5CQ8L4vep+1u6p8DSrstBs3DrdP/FIv60mZkW4ZMC46b90aJ5UrFBu -cF9EzObISrPK5LsbHK+4U8aS5x4fyPtimOX7xEbIEiN/FBNkRpzRrLBzczFrkTvS -TA5Kq/254Bmlw0JwUtmP2jcg9Yw3azSx6k/lDj2E6Oj0z+lBYZune7xr2HsUutbD -FBfsPgjGqxJkUZNP5nl0KQrd46CWetCsTTyRiVKLNUHKrmCqOVG6W2YfXuJ4ShLZ -v+hJIxveSP1kyEOO0UrlZJQZv4eDAI+nK8aoARqso9+uWZsclsGkUPTmzU9ZjTZm -x7Jt2slEgWw3Mchqig12gBC6wdTBeF8gR1id+bHgP0qpyjF2E+Ze/ULEQuJGM6nC -KtXcplh3eKyywkCtZ/8x2xDf/jtVtvgbE7i/A54oGc3gLJBmI2K7NujtREMWhLZp -LvuKYiiopx66VbzJL9YyEeTwvFClj2vM2iK2WS7MGfN3w/imZVvTb6/EtbB/4fO7 -YkQrGND+afvIlCNNc3+MhJ+eCDFy4cp7cAZDlo62mLDEVDGLbfw8qM+2xeykZC4k -zw+otJrT+FR5O9y55RmX7mSWiyRC83mvL8fYEX2XUkkIH3IWxqM5OkZAi1EPqpo7 -XIx1Fz1wKp+hXQ== -=rBdy ------END PGP PUBLIC KEY BLOCK----- diff --git a/simulation/debs/frcsim/frcsim/Makefile b/simulation/debs/frcsim/frcsim/Makefile deleted file mode 100644 index 4603c884c7..0000000000 --- a/simulation/debs/frcsim/frcsim/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -prefix = /usr -bindir = $(prefix)/bin - -all: - echo Should download files - -clean: - echo Cleaning - -install: all - mkdir -p $(DESTDIR)$(bindir) - install frcsim $(DESTDIR)$(bindir)/frcsim diff --git a/simulation/debs/frcsim/frcsim/debian/changelog b/simulation/debs/frcsim/frcsim/debian/changelog deleted file mode 100644 index ac9293d94c..0000000000 --- a/simulation/debs/frcsim/frcsim/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -frcsim (0.1-1) trusty; urgency=low - - * Initial release. - - -- Alex Henning Wed, 14 May 2014 21:04:27 -0400 diff --git a/simulation/debs/frcsim/frcsim/debian/compat b/simulation/debs/frcsim/frcsim/debian/compat deleted file mode 100644 index ec635144f6..0000000000 --- a/simulation/debs/frcsim/frcsim/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/simulation/debs/frcsim/frcsim/debian/control b/simulation/debs/frcsim/frcsim/debian/control deleted file mode 100644 index 42dbabf89e..0000000000 --- a/simulation/debs/frcsim/frcsim/debian/control +++ /dev/null @@ -1,15 +0,0 @@ -Source: frcsim -Maintainer: Alex Henning -Section: misc -Priority: optional -Standards-Version: 3.9.4 -Build-Depends: debhelper (>= 9) - -Package: frcsim -Architecture: all -Depends: ${shlibs:Depends}, ${misc:Depends}, frcsim-gazebo-plugins, frcsim-gazebo-models, frcsim-eclipse-plugins -Description: Installs everything necessary for FRC simulation with Gazebo. - Package that installs everything necessary for FRC Simulation, including - the gazebo plugin, gazebo models, eclipse-plugins and a wrapper script - around Gazebo. This enables support for development of FRC robots with - simulation. \ No newline at end of file diff --git a/simulation/debs/frcsim/frcsim/debian/copyright b/simulation/debs/frcsim/frcsim/debian/copyright deleted file mode 100644 index d7484bdd8c..0000000000 --- a/simulation/debs/frcsim/frcsim/debian/copyright +++ /dev/null @@ -1,25 +0,0 @@ -Copyright -Copyright (c) 2009 FIRST -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the FIRST nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/simulation/debs/frcsim/frcsim/debian/rules b/simulation/debs/frcsim/frcsim/debian/rules deleted file mode 100755 index cbe925d758..0000000000 --- a/simulation/debs/frcsim/frcsim/debian/rules +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/make -f -%: - dh $@ diff --git a/simulation/debs/frcsim/frcsim/debian/source/format b/simulation/debs/frcsim/frcsim/debian/source/format deleted file mode 100644 index 46ebe02665..0000000000 --- a/simulation/debs/frcsim/frcsim/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (quilt) \ No newline at end of file diff --git a/simulation/debs/frcsim/frcsim/frcsim b/simulation/debs/frcsim/frcsim/frcsim deleted file mode 100755 index 72d1ef7ff2..0000000000 --- a/simulation/debs/frcsim/frcsim/frcsim +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -export GAZEBO_PLUGIN_PATH="${GAZEBO_PLUGIN_PATH}:/usr/lib/frcsim/plugins" -export GAZEBO_MODEL_PATH="${GAZEBO_MODEL_PATH}:/usr/share/frcsim/models" -export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/lib/frcsim/plugins" -gazebo $@ diff --git a/simulation/debs/install.sh b/simulation/debs/install.sh deleted file mode 100755 index 11abd31295..0000000000 --- a/simulation/debs/install.sh +++ /dev/null @@ -1,153 +0,0 @@ -#!/bin/bash - -function check-environment { - # Ensure root access - if [ "$(id -u)" != "0" ]; then - echo "*** This script must be run as root!" 1>&2 - echo "*** Make sure that you followed the instructions properly." 1>&2 - install-fail - fi - - # Make sure that we're on Ubuntu. - if [ "$(lsb_release -is)" != "Ubuntu" ]; then - if [ "$(lsb_release -is)" = "" ]; then - echo "*** Distributions other than Ubuntu (such as yours, probably) are not supported." 1>&2 - else - echo "*** Distributions other than Ubuntu (such as $(lsb_release -is)) are not supported." 1>&2 - fi - echo "*** This means that if the install fails, don't blame us." 1>&2 - echo "*** Continue anyway? (y/n)" 1>&2 - read CONT - if [ "$CONT" != "y" -a "$CONT" != "Y" ]; then - install-fail - fi - fi - - # Make sure that we have /etc/apt/sources.list.d available. - if [ ! -e /etc/apt/sources.list.d ]; then - echo "*** Cannot find /etc/apt/sources.list.d - is apt installed?" - install-fail - fi - - # Make sure that apt-key is installed. - if ! which apt-key >/dev/null; then - echo "*** You don't appear to have apt-key installed." 1>&2 - echo "*** Please install apt and run the script again." 1>&2 - install-fail - fi - - # Make sure that apt-get is installed. - if ! which apt-get >/dev/null; then - echo "*** You don't appear to have apt-get installed." 1>&2 - echo "*** Please install apt and run the script again." 1>&2 - install-fail - fi - - # Make sure that we have internet access. - if ! ping 8.8.8.8 -c 1 >/dev/null; then - echo "*** You don't appear to be able to access the internet! (Can't ping 8.8.8.8)" 1>&2 - install-fail - fi - - # Make sure that wget is installed. - if ! which wget >/dev/null; then - echo "*** You don't appear to have wget installed." 1>&2 - echo "*** Install? (y/n)" 1>&2 - read CONT - if [ "$CONT" != "y" -a "$CONT" != "Y" ]; then - install-fail - fi - apt-get install wget - fi -} - -function install-fail { - python -c "raw_input(\"Installation Failed (Hit enter to exit) \")" 1>&2 - exit 1 -} - -function remove-frcsim { - - check-environment - - echo "*** Remove Gazebo package entry too? (y/n)" 1>&2 - read CONT - if [ "$CONT" == "y" -o "$CONT" == "Y" ]; then - rm -f /etc/apt/sources.list.d/gazebo-latest.list - fi - rm -f /etc/apt/sources.list.d/frcsim-latest.list - - # TODO: Does not currently remove keys. Should it? - - apt-get update - - apt-get remove --auto-remove frcsim -} - -function install-frcsim { - - check-environment - - # Add Gazebo Repository and Key - if ! echo "deb http://packages.osrfoundation.org/gazebo/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-latest.list - then - echo "*** Cannot add Gazebo repository!" 1>&2 - install-fail - fi - if ! (wget http://packages.osrfoundation.org/gazebo.key -O - | apt-key add -) - then - echo "*** Cannot add Gazebo repository key!" 1>&2 - if ! ping packages.osrfoundation.org -c 1 >/dev/null; then - echo "*** The package host for Gazebo appears to be down. Try again later." 1>&2 - fi - install-fail - fi - - # Add FRCSim Repository and Key - if ! echo "deb http://first.wpi.edu/FRC/roborio/release/linux `lsb_release -cs` main" > /etc/apt/sources.list.d/frcsim-latest.list - then - echo "*** Cannot add FRCSim repository!" 1>&2 - install-fail - fi - if ! (wget first.wpi.edu/FRC/roborio/wpilib.gpg.key -O - | apt-key add -) - then - echo "*** Cannot add FRCSim repository key!" 1>&2 - if ! ping first.wpi.edu -c 1 >/dev/null; then - echo "*** The package host for FRCSim appears to be down. Try again later." 1>&2 - fi - install-fail - fi - - # Update and install frcsim and its dependencies - if ! apt-get update - then - echo "*** Could not resynchronize package index files." 1>&2 - echo "*** Are you running another update or install?" 1>&2 - install-fail - fi - if ! apt-get install -y frcsim - then - echo "*** Could not install frcsim packages. See above output for details." 1>&2 - echo "*** Are you running another update or install?" 1>&2 - install-fail - fi - - # Done - python -c "raw_input(\"Installation Finished (Hit enter to exit) \")" 1>&2 -} - -if [ "$1" == "ROOT" ] -then - install-frcsim -elif [ "$1" == "INSTALLER" ] -then - SUDO_ASKPASS=/usr/bin/ssh-askpass sudo bash -c "$0 ROOT" -elif [ "$1" == "REMOVE-ROOT" ] -then - remove-frcsim -elif [ "$1" == "REMOVE" ] -then - SUDO_ASKPASS=/usr/bin/ssh-askpass sudo bash -c "$0 REMOVE-ROOT" -else - gnome-terminal --window --hide-menubar --title "FRCSim Installer" -e "$0 INSTALLER" -fi diff --git a/simulation/debs/repository/conf/distributions b/simulation/debs/repository/conf/distributions deleted file mode 100644 index ad278e7a0d..0000000000 --- a/simulation/debs/repository/conf/distributions +++ /dev/null @@ -1,12 +0,0 @@ -Origin: users.wpi.edu -Label: FRCSim -Codename: trusty -Architectures: i386 amd64 source -Components: main -Description: Repository for simulating FRC robots using WPILibSim and the Gazebo simualtor. -SignWith: yes -DebOverride: override.trusty -DscOverride: override.trusty -DebIndices: Packages Release . .gz -UDebIndices: Packages . .gz -DscIndices: Sources Release . .gz diff --git a/simulation/debs/repository/conf/options b/simulation/debs/repository/conf/options deleted file mode 100644 index 7b49bf9e80..0000000000 --- a/simulation/debs/repository/conf/options +++ /dev/null @@ -1,3 +0,0 @@ -verbose -ask-passphrase -basedir . diff --git a/simulation/debs/repository/conf/override.trusty b/simulation/debs/repository/conf/override.trusty deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/simulation/frc_gazebo_plugins/.gitignore b/simulation/frc_gazebo_plugins/.gitignore index 2c46269432..45bb3aaf52 100644 --- a/simulation/frc_gazebo_plugins/.gitignore +++ b/simulation/frc_gazebo_plugins/.gitignore @@ -1,3 +1,5 @@ plugins/ build/ -docs/ \ No newline at end of file +docs/ +# don't commit the generated protobuff files +msgs/src/msgs diff --git a/simulation/frc_gazebo_plugins/CMakeLists.txt b/simulation/frc_gazebo_plugins/CMakeLists.txt new file mode 100644 index 0000000000..1d45789663 --- /dev/null +++ b/simulation/frc_gazebo_plugins/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 2.8.3) +project(frc_gazebo_plugins) + +set (PLUGINS + clock + dc_motor + encoder + gyro + limit_switch + pneumatic_piston + potentiometer + rangefinder + servo) + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/plugins) + +link_directories(${GAZEBO_LIBRARY_DIRS}) + +foreach(PLUGIN ${PLUGINS}) + + file(GLOB_RECURSE SRC_FILES ${PLUGIN}/src/*.cpp) + + include_directories(src ${Boost_INCLUDE_DIR} ${GZ_MSGS_INCLUDE_DIR} ${PROTOBUF_INCLUDE_DIRS} ${GAZEBO_INCLUDE_DIRS}) + + if (WIN32) + add_library(${PLUGIN} ${SRC_FILES}) + else() + add_library(${PLUGIN} SHARED ${SRC_FILES}) + endif() + + target_link_libraries(${PLUGIN} gz_msgs ${GAZEBO_LIBRARIES} ${Boost_LIBRARIES}) + + install(TARGETS ${PLUGIN} DESTINATION $ENV{HOME}/wpilib/simulation/plugins) + +endforeach() diff --git a/simulation/frc_gazebo_plugins/Makefile b/simulation/frc_gazebo_plugins/Makefile deleted file mode 100644 index 005a77c30e..0000000000 --- a/simulation/frc_gazebo_plugins/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -prefix = /usr -lib.dir = $(prefix)/lib -plugin.dir = $(lib.dir)/frcsim/plugins -build.dir = build - -ext = .so -ifeq ($(shell uname), Darwin) - ext = .dylib -endif - -.PHONY : all build copy-plugins clean docs clean-docs - -all: build copy-plugins - -build: - cd msgs && make - cd dc_motor && make - cd pneumatic_piston && make - cd potentiometer && make - cd rangefinder && make - cd encoder && make - cd gyro && make - cd limit_switch && make - cd clock && make - -copy-plugins: - mkdir -p plugins - cp msgs/build/libgz_msgs$(ext) plugins - cp dc_motor/build/libgz_dc_motor$(ext) plugins - cp pneumatic_piston/build/libgz_pneumatic_piston$(ext) plugins - cp potentiometer/build/libgz_potentiometer$(ext) plugins - cp rangefinder/build/libgz_rangefinder$(ext) plugins - cp encoder/build/libgz_encoder$(ext) plugins - cp gyro/build/libgz_gyro$(ext) plugins - cp limit_switch/build/libgz_limit_switch$(ext) plugins - cp clock/build/libgz_clock$(ext) plugins - -clean: clean-docs - cd msgs && make clean - cd dc_motor && make clean - cd pneumatic_piston && make clean - cd potentiometer && make clean - cd rangefinder && make clean - cd encoder && make clean - cd gyro && make clean - cd limit_switch && make clean - cd clock && make clean - -rm -r plugins - -install: all - mkdir -p $(DESTDIR)$(plugin.dir) - install plugins/* $(DESTDIR)$(plugin.dir) - -docs: - doxygen frc_gazebo_plugins.doxy - -clean-docs: - -rm -r docs diff --git a/simulation/frc_gazebo_plugins/README.md b/simulation/frc_gazebo_plugins/README.md new file mode 100644 index 0000000000..73e57e6dd0 --- /dev/null +++ b/simulation/frc_gazebo_plugins/README.md @@ -0,0 +1,9 @@ +Notes for building the gazebo plugins +===================================== + +the resulting plugins (shared libraries, `.so/.dll`) are delivered to students via the eclipse simulation plugins, and unzipped to `${HOME}/wpilib/simulation/plugins` + +## Building +these are built with cmake, because they use the gazebo libraries. +gazebo libraries provide cmake-config files, so cmake is easier to use here. +See top level building.md for how to build diff --git a/simulation/frc_gazebo_plugins/clock/CMakeLists.txt b/simulation/frc_gazebo_plugins/clock/CMakeLists.txt deleted file mode 100644 index e20c8345a3..0000000000 --- a/simulation/frc_gazebo_plugins/clock/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.3) -project(gz_clock) - -include (FindPkgConfig) -if (PKG_CONFIG_FOUND) - pkg_check_modules(GAZEBO gazebo) -endif() - -find_package(gazebo REQUIRED) -find_package(Boost COMPONENTS system REQUIRED) -find_library(GZ_MSGS NAMES gz_msgs PATHS ../msgs/build) - -file(GLOB_RECURSE SRC_FILES src/*.cpp) -include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src) -add_library(${PROJECT_NAME} SHARED ${SRC_FILES}) - -link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build/) -target_link_libraries(${PROJECT_NAME} ${GZ_MSGS} ${GAZEBO_LIBRARIES} ${Boost_LIBRARIES}) diff --git a/simulation/frc_gazebo_plugins/clock/Makefile b/simulation/frc_gazebo_plugins/clock/Makefile deleted file mode 100644 index b8f6f9bb4c..0000000000 --- a/simulation/frc_gazebo_plugins/clock/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -prefix = /usr -lib.dir = $(prefix)/lib -plugin.dir = $(lib.dir)/frcsim/plugins -build.dir = build - -ext = .so -ifeq ($(shell uname), Darwin) - ext = .dylib -endif - -all: - mkdir -p $(build.dir) - cd ${build.dir} && cmake .. && make - -clean: - rm -rf $(build.dir) - -install: all - mkdir -p $(DESTDIR)$(plugin.dir) - install $(build.dir)/libgz_clock$(ext) $(DESTDIR)$(plugin.dir) diff --git a/simulation/frc_gazebo_plugins/clock/src/clock.cpp b/simulation/frc_gazebo_plugins/clock/src/clock.cpp index ac10f95e3b..32cd3b7f1c 100644 --- a/simulation/frc_gazebo_plugins/clock/src/clock.cpp +++ b/simulation/frc_gazebo_plugins/clock/src/clock.cpp @@ -1,10 +1,5 @@ #include "clock.h" -#include -#include - -#include "msgs/msgs.h" - GZ_REGISTER_MODEL_PLUGIN(Clock) Clock::Clock() {} diff --git a/simulation/frc_gazebo_plugins/clock/src/clock.h b/simulation/frc_gazebo_plugins/clock/src/clock.h index be04260479..4590471fbb 100644 --- a/simulation/frc_gazebo_plugins/clock/src/clock.h +++ b/simulation/frc_gazebo_plugins/clock/src/clock.h @@ -1,7 +1,13 @@ #pragma once + +#include "simulation/gz_msgs/msgs.h" + +#include +#include #include + using namespace gazebo; /** @@ -16,25 +22,25 @@ using namespace gazebo; * * ~/my/topic * - * + * * - `topic`: Optional. Message will be published as a gazebo.msgs.Float64. * * \todo Make WorldPlugin? */ class Clock: public ModelPlugin { -public: +public: Clock(); ~Clock(); - + /// \brief Load the clock and configures it according to the sdf. void Load(physics::ModelPtr model, sdf::ElementPtr sdf); - + /// \brief Sends out time each timestep. void Update(const common::UpdateInfo &info); private: std::string topic; ///< \brief Publish the time on this topic. - physics::ModelPtr model; ///< \brief The model that this is attached to. + physics::ModelPtr model; ///< \brief The model that this is attached to. event::ConnectionPtr updateConn; ///< \brief Pointer to the world update function. transport::NodePtr node; ///< \brief The node we're advertising on. transport::PublisherPtr pub; ///< \brief Publisher handle. diff --git a/simulation/frc_gazebo_plugins/dc_motor/CMakeLists.txt b/simulation/frc_gazebo_plugins/dc_motor/CMakeLists.txt deleted file mode 100644 index e8054549e7..0000000000 --- a/simulation/frc_gazebo_plugins/dc_motor/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.3) -project(gz_dc_motor) - -include (FindPkgConfig) -if (PKG_CONFIG_FOUND) - pkg_check_modules(GAZEBO gazebo) -endif() - -find_package(gazebo REQUIRED) -find_package(Boost COMPONENTS system REQUIRED) -find_library(GZ_MSGS NAMES gz_msgs PATHS ../msgs/build) - -file(GLOB_RECURSE SRC_FILES src/*.cpp) -include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src) -add_library(${PROJECT_NAME} SHARED ${SRC_FILES}) - -link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build/) -target_link_libraries(${PROJECT_NAME} ${GZ_MSGS} ${GAZEBO_LIBRARIES} ${Boost_LIBRARIES}) diff --git a/simulation/frc_gazebo_plugins/dc_motor/Makefile b/simulation/frc_gazebo_plugins/dc_motor/Makefile deleted file mode 100644 index a45630ea33..0000000000 --- a/simulation/frc_gazebo_plugins/dc_motor/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -prefix = /usr -lib.dir = $(prefix)/lib -plugin.dir = $(lib.dir)/frcsim/plugins -build.dir = build - -ext = .so -ifeq ($(shell uname), Darwin) - ext = .dylib -endif - -all: - mkdir -p $(build.dir) - cd ${build.dir} && cmake .. && make - -clean: - rm -rf $(build.dir) - -install: all - mkdir -p $(DESTDIR)$(plugin.dir) - install $(build.dir)/libgz_dc_motor$(ext) $(DESTDIR)$(plugin.dir) diff --git a/simulation/frc_gazebo_plugins/dc_motor/src/dc_motor.cpp b/simulation/frc_gazebo_plugins/dc_motor/src/dc_motor.cpp index 80dc3227a5..0b4bbab84e 100644 --- a/simulation/frc_gazebo_plugins/dc_motor/src/dc_motor.cpp +++ b/simulation/frc_gazebo_plugins/dc_motor/src/dc_motor.cpp @@ -1,8 +1,5 @@ #include "dc_motor.h" -#include -#include - GZ_REGISTER_MODEL_PLUGIN(DCMotor) DCMotor::DCMotor() {} @@ -20,13 +17,13 @@ void DCMotor::Load(physics::ModelPtr model, sdf::ElementPtr sdf) { } else { topic = "~/"+sdf->GetAttribute("name")->GetAsString(); } - + if (sdf->HasElement("multiplier")) { multiplier = sdf->Get("multiplier"); } else { multiplier = 1; } - + gzmsg << "Initializing motor: " << topic << " joint=" << joint->GetName() << " multiplier=" << multiplier << std::endl; diff --git a/simulation/frc_gazebo_plugins/dc_motor/src/dc_motor.h b/simulation/frc_gazebo_plugins/dc_motor/src/dc_motor.h index 1f6ad0f677..22d70bead8 100644 --- a/simulation/frc_gazebo_plugins/dc_motor/src/dc_motor.h +++ b/simulation/frc_gazebo_plugins/dc_motor/src/dc_motor.h @@ -1,8 +1,13 @@ #pragma once +#include "simulation/gz_msgs/msgs.h" + +#include +#include #include -#include "msgs/msgs.h" + + using namespace gazebo; @@ -27,13 +32,13 @@ using namespace gazebo; * - `multiplier`: Optional. Defaults to 1. */ class DCMotor: public ModelPlugin { -public: +public: DCMotor(); ~DCMotor(); - + /// \brief Load the dc motor and configures it according to the sdf. void Load(physics::ModelPtr model, sdf::ElementPtr sdf); - + /// \brief Update the torque on the joint from the dc motor each timestep. void Update(const common::UpdateInfo &info); @@ -43,7 +48,7 @@ private: /// \brief The pwm signal limited to the range [-1,1]. double signal; - + /// \brief The magic torque multiplier. torque=multiplier*signal double multiplier; @@ -53,8 +58,8 @@ private: /// \brief Callback for receiving msgs and storing the signal. void Callback(const msgs::ConstFloat64Ptr &msg); - - physics::ModelPtr model; ///< \brief The model that this is attached to. + + physics::ModelPtr model; ///< \brief The model that this is attached to. event::ConnectionPtr updateConn; ///< \brief Pointer to the world update function. transport::NodePtr node; ///< \brief The node we're advertising on. transport::SubscriberPtr sub; ///< \brief Subscriber handle. diff --git a/simulation/frc_gazebo_plugins/encoder/CMakeLists.txt b/simulation/frc_gazebo_plugins/encoder/CMakeLists.txt deleted file mode 100644 index 3bb34b0888..0000000000 --- a/simulation/frc_gazebo_plugins/encoder/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.3) -project(gz_encoder) - -include (FindPkgConfig) -if (PKG_CONFIG_FOUND) - pkg_check_modules(GAZEBO gazebo) -endif() - -find_package(gazebo REQUIRED) -find_package(Boost COMPONENTS system REQUIRED) -find_library(GZ_MSGS NAMES gz_msgs PATHS ../msgs/build) - -file(GLOB_RECURSE SRC_FILES src/*.cpp) -include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src) -add_library(${PROJECT_NAME} SHARED ${SRC_FILES}) - -link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build/) -target_link_libraries(${PROJECT_NAME} ${GZ_MSGS} ${GAZEBO_LIBRARIES} ${Boost_LIBRARIES}) diff --git a/simulation/frc_gazebo_plugins/encoder/Makefile b/simulation/frc_gazebo_plugins/encoder/Makefile deleted file mode 100644 index 42f322fe56..0000000000 --- a/simulation/frc_gazebo_plugins/encoder/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -prefix = /usr -lib.dir = $(prefix)/lib -plugin.dir = $(lib.dir)/frcsim/plugins -build.dir = build - -ext = .so -ifeq ($(shell uname), Darwin) - ext = .dylib -endif - -all: - mkdir -p $(build.dir) - cd ${build.dir} && cmake .. && make - -clean: - rm -rf $(build.dir) - -install: all - mkdir -p $(DESTDIR)$(plugin.dir) - install $(build.dir)/libgz_encoder$(ext) $(DESTDIR)$(plugin.dir) diff --git a/simulation/frc_gazebo_plugins/encoder/src/encoder.cpp b/simulation/frc_gazebo_plugins/encoder/src/encoder.cpp index 51ca8746a6..aea246fcb0 100644 --- a/simulation/frc_gazebo_plugins/encoder/src/encoder.cpp +++ b/simulation/frc_gazebo_plugins/encoder/src/encoder.cpp @@ -1,8 +1,5 @@ #include "encoder.h" -#include -#include - GZ_REGISTER_MODEL_PLUGIN(Encoder) Encoder::Encoder() {} @@ -19,7 +16,7 @@ void Encoder::Load(physics::ModelPtr model, sdf::ElementPtr sdf) { } else { topic = "~/"+sdf->GetAttribute("name")->GetAsString(); } - + if (sdf->HasElement("units")) { radians = sdf->Get("units") != "degrees"; } else { @@ -28,7 +25,7 @@ void Encoder::Load(physics::ModelPtr model, sdf::ElementPtr sdf) { zero = GetAngle(); stopped = true; stop_value = 0; - + gzmsg << "Initializing encoder: " << topic << " joint=" << joint->GetName() << " radians=" << radians << std::endl; diff --git a/simulation/frc_gazebo_plugins/encoder/src/encoder.h b/simulation/frc_gazebo_plugins/encoder/src/encoder.h index fac3e2e0d3..728341de69 100644 --- a/simulation/frc_gazebo_plugins/encoder/src/encoder.h +++ b/simulation/frc_gazebo_plugins/encoder/src/encoder.h @@ -1,8 +1,11 @@ #pragma once +#include "simulation/gz_msgs/msgs.h" + +#include +#include #include -#include "msgs/msgs.h" using namespace gazebo; @@ -33,13 +36,13 @@ using namespace gazebo; * - `units`: Optional. Defaults to radians. */ class Encoder: public ModelPlugin { -public: +public: Encoder(); ~Encoder(); - + /// \brief Load the encoder and configures it according to the sdf. void Load(physics::ModelPtr model, sdf::ElementPtr sdf); - + /// \brief Sends out the encoder reading each timestep. void Update(const common::UpdateInfo &info); @@ -49,13 +52,13 @@ private: /// \brief Whether or not this encoder measures radians or degrees. bool radians; - + /// \brief Whether or not the encoder has been stopped. bool stopped; - + /// \brief The zero value of the encoder. double zero; - + /// \brief The value the encoder stopped counting at double stop_value; @@ -68,12 +71,12 @@ private: /// \brief Gets the current angle, taking into account whether to /// return radians or degrees. double GetAngle(); - + /// \brief Gets the current velocity, taking into account whether to /// return radians/second or degrees/second. double GetVelocity(); - physics::ModelPtr model; ///< \brief The model that this is attached to. + physics::ModelPtr model; ///< \brief The model that this is attached to. event::ConnectionPtr updateConn; ///< \brief Pointer to the world update function. transport::NodePtr node; ///< \brief The node we're advertising on. transport::SubscriberPtr command_sub; ///< \brief Subscriber handle. diff --git a/simulation/frc_gazebo_plugins/gyro/CMakeLists.txt b/simulation/frc_gazebo_plugins/gyro/CMakeLists.txt deleted file mode 100644 index 136509ba81..0000000000 --- a/simulation/frc_gazebo_plugins/gyro/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.3) -project(gz_gyro) - -include (FindPkgConfig) -if (PKG_CONFIG_FOUND) - pkg_check_modules(GAZEBO gazebo) -endif() - -find_package(gazebo REQUIRED) -find_package(Boost COMPONENTS system REQUIRED) -find_library(GZ_MSGS NAMES gz_msgs PATHS ../msgs/build) - -file(GLOB_RECURSE SRC_FILES src/*.cpp) -include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src) -add_library(${PROJECT_NAME} SHARED ${SRC_FILES}) - -link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build/) -target_link_libraries(${PROJECT_NAME} ${GZ_MSGS} ${GAZEBO_LIBRARIES} ${Boost_LIBRARIES}) diff --git a/simulation/frc_gazebo_plugins/gyro/Makefile b/simulation/frc_gazebo_plugins/gyro/Makefile deleted file mode 100644 index f70e5713be..0000000000 --- a/simulation/frc_gazebo_plugins/gyro/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -prefix = /usr -lib.dir = $(prefix)/lib -plugin.dir = $(lib.dir)/frcsim/plugins -build.dir = build - -ext = .so -ifeq ($(shell uname), Darwin) - ext = .dylib -endif - -all: - mkdir -p $(build.dir) - cd ${build.dir} && cmake .. && make - -clean: - rm -rf $(build.dir) - -install: all - mkdir -p $(DESTDIR)$(plugin.dir) - install $(build.dir)/libgz_gyro$(ext) $(DESTDIR)$(plugin.dir) diff --git a/simulation/frc_gazebo_plugins/gyro/src/gyro.cpp b/simulation/frc_gazebo_plugins/gyro/src/gyro.cpp index 197f117109..e918bbb4c9 100644 --- a/simulation/frc_gazebo_plugins/gyro/src/gyro.cpp +++ b/simulation/frc_gazebo_plugins/gyro/src/gyro.cpp @@ -1,7 +1,5 @@ #include "gyro.h" -#include -#include GZ_REGISTER_MODEL_PLUGIN(Gyro) @@ -24,14 +22,14 @@ void Gyro::Load(physics::ModelPtr model, sdf::ElementPtr sdf) { if (axisString == "roll") axis = Roll; if (axisString == "pitch") axis = Pitch; if (axisString == "yaw") axis = Yaw; - + if (sdf->HasElement("units")) { radians = sdf->Get("units") != "degrees"; } else { radians = true; } zero = GetAngle(); - + gzmsg << "Initializing gyro: " << topic << " link=" << link->GetName() << " axis=" << axis << " radians=" << radians << std::endl; diff --git a/simulation/frc_gazebo_plugins/gyro/src/gyro.h b/simulation/frc_gazebo_plugins/gyro/src/gyro.h index c4dcb7493a..fee48b37e3 100644 --- a/simulation/frc_gazebo_plugins/gyro/src/gyro.h +++ b/simulation/frc_gazebo_plugins/gyro/src/gyro.h @@ -1,8 +1,12 @@ #pragma once +#include "simulation/gz_msgs/msgs.h" + +#include +#include #include -#include "msgs/msgs.h" + using namespace gazebo; @@ -32,13 +36,13 @@ typedef enum {Roll /*X*/, Pitch /*Y*/, Yaw /*Z*/} ROTATION; * - `units`; Optional, defaults to radians. */ class Gyro: public ModelPlugin { -public: +public: Gyro(); ~Gyro(); - + /// \brief Load the gyro and configures it according to the sdf. void Load(physics::ModelPtr model, sdf::ElementPtr sdf); - + /// \brief Sends out the gyro reading each timestep. void Update(const common::UpdateInfo &info); @@ -49,22 +53,22 @@ private: /// \brief Whether or not this gyro measures radians or degrees. bool radians; - /// \brief The axis to measure rotation about. + /// \brief The axis to measure rotation about. ROTATION axis; - + /// \brief The zero value of the gyro. double zero; - + /// \brief The link that this gyro measures physics::LinkPtr link; - + /// \brief Callback for handling control data void Callback(const msgs::ConstStringPtr &msg); /// \brief Gets the current angle, taking into account whether to /// return radians or degrees. double GetAngle(); - + /// \brief Gets the current velocity, taking into account whether to /// return radians/second or degrees/second. double GetVelocity(); @@ -73,7 +77,7 @@ private: /// depending on whether or radians or degrees are being used. double Limit(double value); - physics::ModelPtr model; ///< \brief The model that this is attached to. + physics::ModelPtr model; ///< \brief The model that this is attached to. event::ConnectionPtr updateConn; ///< \brief Pointer to the world update function. transport::NodePtr node; ///< \brief The node we're advertising on. transport::SubscriberPtr command_sub; ///< \brief Subscriber handle. diff --git a/simulation/frc_gazebo_plugins/limit_switch/CMakeLists.txt b/simulation/frc_gazebo_plugins/limit_switch/CMakeLists.txt deleted file mode 100644 index ee72cfade6..0000000000 --- a/simulation/frc_gazebo_plugins/limit_switch/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.3) -project(gz_limit_switch) - -include (FindPkgConfig) -if (PKG_CONFIG_FOUND) - pkg_check_modules(GAZEBO gazebo) -endif() - -find_package(gazebo REQUIRED) -find_package(Boost COMPONENTS system REQUIRED) -find_library(GZ_MSGS NAMES gz_msgs PATHS ../msgs/build) - -file(GLOB_RECURSE SRC_FILES src/*.cpp) -include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src) -add_library(${PROJECT_NAME} SHARED ${SRC_FILES}) - -link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build/) -target_link_libraries(${PROJECT_NAME} ${GZ_MSGS} ${GAZEBO_LIBRARIES} ${Boost_LIBRARIES}) diff --git a/simulation/frc_gazebo_plugins/limit_switch/Makefile b/simulation/frc_gazebo_plugins/limit_switch/Makefile deleted file mode 100644 index 8656c9913f..0000000000 --- a/simulation/frc_gazebo_plugins/limit_switch/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -prefix = /usr -lib.dir = $(prefix)/lib -plugin.dir = $(lib.dir)/frcsim/plugins -build.dir = build - -ext = .so -ifeq ($(shell uname), Darwin) - ext = .dylib -endif - -all: - mkdir -p $(build.dir) - cd ${build.dir} && cmake .. && make - -clean: - rm -rf $(build.dir) - -install: all - mkdir -p $(DESTDIR)$(plugin.dir) - install $(build.dir)/libgz_limit_switch$(ext) $(DESTDIR)$(plugin.dir) diff --git a/simulation/frc_gazebo_plugins/limit_switch/src/external_limit_switch.cpp b/simulation/frc_gazebo_plugins/limit_switch/src/external_limit_switch.cpp index 486931b778..67c2c7abcb 100644 --- a/simulation/frc_gazebo_plugins/limit_switch/src/external_limit_switch.cpp +++ b/simulation/frc_gazebo_plugins/limit_switch/src/external_limit_switch.cpp @@ -1,7 +1,5 @@ #include "external_limit_switch.h" -#include -#include ExternalLimitSwitch::ExternalLimitSwitch(sdf::ElementPtr sdf) { sensor = boost::dynamic_pointer_cast( @@ -11,7 +9,7 @@ ExternalLimitSwitch::ExternalLimitSwitch(sdf::ElementPtr sdf) { } ExternalLimitSwitch::~ExternalLimitSwitch() {} - + bool ExternalLimitSwitch::Get() { return sensor->GetContacts().contact().size() > 0; } diff --git a/simulation/frc_gazebo_plugins/limit_switch/src/external_limit_switch.h b/simulation/frc_gazebo_plugins/limit_switch/src/external_limit_switch.h index 7785372697..573e93bd6b 100644 --- a/simulation/frc_gazebo_plugins/limit_switch/src/external_limit_switch.h +++ b/simulation/frc_gazebo_plugins/limit_switch/src/external_limit_switch.h @@ -1,16 +1,22 @@ #pragma once -#include - #include "switch.h" +#ifdef _WIN32 + #include +#endif + +#include +#include +#include + using namespace gazebo; class ExternalLimitSwitch : public Switch { -public: +public: ExternalLimitSwitch(sdf::ElementPtr sdf); ~ExternalLimitSwitch(); - + /// \brief Returns true when the switch is triggered. virtual bool Get(); diff --git a/simulation/frc_gazebo_plugins/limit_switch/src/internal_limit_switch.cpp b/simulation/frc_gazebo_plugins/limit_switch/src/internal_limit_switch.cpp index 2d34aa9f0a..3b6d7de13a 100644 --- a/simulation/frc_gazebo_plugins/limit_switch/src/internal_limit_switch.cpp +++ b/simulation/frc_gazebo_plugins/limit_switch/src/internal_limit_switch.cpp @@ -1,12 +1,10 @@ #include "internal_limit_switch.h" -#include - InternalLimitSwitch::InternalLimitSwitch(physics::ModelPtr model, sdf::ElementPtr sdf) { joint = model->GetJoint(sdf->Get("joint")); min = sdf->Get("min"); max = sdf->Get("max"); - + if (sdf->HasElement("units")) { radians = sdf->Get("units") != "degrees"; } else { @@ -18,7 +16,7 @@ InternalLimitSwitch::InternalLimitSwitch(physics::ModelPtr model, sdf::ElementPt } InternalLimitSwitch::~InternalLimitSwitch() {} - + bool InternalLimitSwitch::Get() { double value; joint->GetAngle(0).Normalize(); diff --git a/simulation/frc_gazebo_plugins/limit_switch/src/internal_limit_switch.h b/simulation/frc_gazebo_plugins/limit_switch/src/internal_limit_switch.h index ea43ceadde..bf08cbb155 100644 --- a/simulation/frc_gazebo_plugins/limit_switch/src/internal_limit_switch.h +++ b/simulation/frc_gazebo_plugins/limit_switch/src/internal_limit_switch.h @@ -1,16 +1,20 @@ #pragma once -#include - #include "switch.h" +#ifdef _WIN32 + #include +#endif +#include +#include + using namespace gazebo; class InternalLimitSwitch : public Switch { -public: +public: InternalLimitSwitch(physics::ModelPtr model, sdf::ElementPtr sdf); ~InternalLimitSwitch(); - + /// \brief Returns true when the switch is triggered. virtual bool Get(); diff --git a/simulation/frc_gazebo_plugins/limit_switch/src/limit_switch.cpp b/simulation/frc_gazebo_plugins/limit_switch/src/limit_switch.cpp index f06fd558e5..f32e65c819 100644 --- a/simulation/frc_gazebo_plugins/limit_switch/src/limit_switch.cpp +++ b/simulation/frc_gazebo_plugins/limit_switch/src/limit_switch.cpp @@ -1,11 +1,4 @@ #include "limit_switch.h" -#include "internal_limit_switch.h" -#include "external_limit_switch.h" - -#include -#include - -#include "msgs/msgs.h" GZ_REGISTER_MODEL_PLUGIN(LimitSwitch) diff --git a/simulation/frc_gazebo_plugins/limit_switch/src/limit_switch.h b/simulation/frc_gazebo_plugins/limit_switch/src/limit_switch.h index 6bd6fd847c..4d590d5ec5 100644 --- a/simulation/frc_gazebo_plugins/limit_switch/src/limit_switch.h +++ b/simulation/frc_gazebo_plugins/limit_switch/src/limit_switch.h @@ -1,9 +1,16 @@ #pragma once -#include +#include "simulation/gz_msgs/msgs.h" #include "switch.h" +#include "internal_limit_switch.h" +#include "external_limit_switch.h" + +#include +#include +#include + using namespace gazebo; /** @@ -53,13 +60,13 @@ using namespace gazebo; * - `sensor`: Name of the contact sensor that this limit switch uses. */ class LimitSwitch: public ModelPlugin { -public: +public: LimitSwitch(); ~LimitSwitch(); - + /// \brief Load the limit switch and configures it according to the sdf. void Load(physics::ModelPtr model, sdf::ElementPtr sdf); - + /// \brief Sends out the limit switch reading each timestep. void Update(const common::UpdateInfo &info); @@ -69,9 +76,9 @@ private: /// \brief LimitSwitch object, currently internal or external. Switch* ls; - - physics::ModelPtr model; ///< \brief The model that this is attached to. + + physics::ModelPtr model; ///< \brief The model that this is attached to. event::ConnectionPtr updateConn; ///< \brief Pointer to the world update function. transport::NodePtr node; ///< \brief The node we're advertising on. transport::PublisherPtr pub; ///< \brief Publisher handle. diff --git a/simulation/frc_gazebo_plugins/limit_switch/src/switch.h b/simulation/frc_gazebo_plugins/limit_switch/src/switch.h index 036ac10953..d7d5aaca9d 100644 --- a/simulation/frc_gazebo_plugins/limit_switch/src/switch.h +++ b/simulation/frc_gazebo_plugins/limit_switch/src/switch.h @@ -1,9 +1,9 @@ #pragma once class Switch { -public: +public: virtual ~Switch() {} - + /// \brief Returns true when the switch is triggered. virtual bool Get() = 0; }; diff --git a/simulation/frc_gazebo_plugins/msgs/CMakeLists.txt b/simulation/frc_gazebo_plugins/msgs/CMakeLists.txt deleted file mode 100644 index b03c4dca99..0000000000 --- a/simulation/frc_gazebo_plugins/msgs/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 2.8.3) -project(gz_msgs) - -include (FindPkgConfig) -if (PKG_CONFIG_FOUND) - pkg_check_modules(GAZEBO gazebo) -endif() - -find_package(gazebo REQUIRED) - -file(GLOB_RECURSE SRC_FILES src/*.cpp src/*.cc) -include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS}) -add_library(${PROJECT_NAME} SHARED ${SRC_FILES}) - -link_directories(${GAZEBO_LIBRARY_DIRS}) -target_link_libraries(${PROJECT_NAME} ${GAZEBO_LIBRARIES}) diff --git a/simulation/frc_gazebo_plugins/msgs/Makefile b/simulation/frc_gazebo_plugins/msgs/Makefile deleted file mode 100644 index 4ec4bd5e0c..0000000000 --- a/simulation/frc_gazebo_plugins/msgs/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -prefix = /usr -lib.dir = $(prefix)/lib -plugin.dir = $(lib.dir)/frcsim/plugins -build.dir = build - -ext = .so -ifeq ($(shell uname), Darwin) - ext = .dylib -endif - -all: - mkdir -p $(build.dir) - cd ${build.dir} && cmake .. && make - -clean: - rm -rf $(build.dir) - -install: all - mkdir -p $(DESTDIR)$(plugin.dir) - install $(build.dir)/libgz_msgs$(ext) $(DESTDIR)$(plugin.dir) diff --git a/simulation/frc_gazebo_plugins/msgs/src/msgs/bool.pb.cc b/simulation/frc_gazebo_plugins/msgs/src/msgs/bool.pb.cc deleted file mode 100644 index 2cbb5e4590..0000000000 --- a/simulation/frc_gazebo_plugins/msgs/src/msgs/bool.pb.cc +++ /dev/null @@ -1,310 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: msgs/bool.proto - -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "msgs/bool.pb.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace gazebo { -namespace msgs { - -namespace { - -const ::google::protobuf::Descriptor* Bool_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Bool_reflection_ = NULL; - -} // namespace - - -void protobuf_AssignDesc_msgs_2fbool_2eproto() { - protobuf_AddDesc_msgs_2fbool_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "msgs/bool.proto"); - GOOGLE_CHECK(file != NULL); - Bool_descriptor_ = file->message_type(0); - static const int Bool_offsets_[1] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Bool, data_), - }; - Bool_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - Bool_descriptor_, - Bool::default_instance_, - Bool_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Bool, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Bool, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(Bool)); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_msgs_2fbool_2eproto); -} - -void protobuf_RegisterTypes(const ::std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Bool_descriptor_, &Bool::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_msgs_2fbool_2eproto() { - delete Bool::default_instance_; - delete Bool_reflection_; -} - -void protobuf_AddDesc_msgs_2fbool_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\017msgs/bool.proto\022\013gazebo.msgs\"\024\n\004Bool\022\014" - "\n\004data\030\001 \002(\010B\010B\006GzBool", 62); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "msgs/bool.proto", &protobuf_RegisterTypes); - Bool::default_instance_ = new Bool(); - Bool::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_msgs_2fbool_2eproto); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_msgs_2fbool_2eproto { - StaticDescriptorInitializer_msgs_2fbool_2eproto() { - protobuf_AddDesc_msgs_2fbool_2eproto(); - } -} static_descriptor_initializer_msgs_2fbool_2eproto_; - -// =================================================================== - -#ifndef _MSC_VER -const int Bool::kDataFieldNumber; -#endif // !_MSC_VER - -Bool::Bool() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void Bool::InitAsDefaultInstance() { -} - -Bool::Bool(const Bool& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void Bool::SharedCtor() { - _cached_size_ = 0; - data_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -Bool::~Bool() { - SharedDtor(); -} - -void Bool::SharedDtor() { - if (this != default_instance_) { - } -} - -void Bool::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* Bool::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Bool_descriptor_; -} - -const Bool& Bool::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_msgs_2fbool_2eproto(); - return *default_instance_; -} - -Bool* Bool::default_instance_ = NULL; - -Bool* Bool::New() const { - return new Bool; -} - -void Bool::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - data_ = false; - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool Bool::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // required bool data = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &data_))); - set_has_data(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void Bool::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // required bool data = 1; - if (has_data()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->data(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* Bool::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // required bool data = 1; - if (has_data()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->data(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int Bool::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // required bool data = 1; - if (has_data()) { - total_size += 1 + 1; - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void Bool::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const Bool* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void Bool::MergeFrom(const Bool& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_data()) { - set_data(from.data()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void Bool::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void Bool::CopyFrom(const Bool& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Bool::IsInitialized() const { - if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false; - - return true; -} - -void Bool::Swap(Bool* other) { - if (other != this) { - std::swap(data_, other->data_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata Bool::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Bool_descriptor_; - metadata.reflection = Bool_reflection_; - return metadata; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace msgs -} // namespace gazebo - -// @@protoc_insertion_point(global_scope) diff --git a/simulation/frc_gazebo_plugins/msgs/src/msgs/bool.pb.h b/simulation/frc_gazebo_plugins/msgs/src/msgs/bool.pb.h deleted file mode 100644 index 47428ad205..0000000000 --- a/simulation/frc_gazebo_plugins/msgs/src/msgs/bool.pb.h +++ /dev/null @@ -1,167 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: msgs/bool.proto - -#ifndef PROTOBUF_msgs_2fbool_2eproto__INCLUDED -#define PROTOBUF_msgs_2fbool_2eproto__INCLUDED - -#include - -#include - -#if GOOGLE_PROTOBUF_VERSION < 2005000 -#error This file was generated by a newer version of protoc which is -#error incompatible with your Protocol Buffer headers. Please update -#error your headers. -#endif -#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION -#error This file was generated by an older version of protoc which is -#error incompatible with your Protocol Buffer headers. Please -#error regenerate this file with a newer version of protoc. -#endif - -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace gazebo { -namespace msgs { - -// Internal implementation detail -- do not call these. -void protobuf_AddDesc_msgs_2fbool_2eproto(); -void protobuf_AssignDesc_msgs_2fbool_2eproto(); -void protobuf_ShutdownFile_msgs_2fbool_2eproto(); - -class Bool; - -// =================================================================== - -class Bool : public ::google::protobuf::Message { - public: - Bool(); - virtual ~Bool(); - - Bool(const Bool& from); - - inline Bool& operator=(const Bool& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const Bool& default_instance(); - - void Swap(Bool* other); - - // implements Message ---------------------------------------------- - - Bool* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const Bool& from); - void MergeFrom(const Bool& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // required bool data = 1; - inline bool has_data() const; - inline void clear_data(); - static const int kDataFieldNumber = 1; - inline bool data() const; - inline void set_data(bool value); - - // @@protoc_insertion_point(class_scope:gazebo.msgs.Bool) - private: - inline void set_has_data(); - inline void clear_has_data(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - bool data_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void protobuf_AddDesc_msgs_2fbool_2eproto(); - friend void protobuf_AssignDesc_msgs_2fbool_2eproto(); - friend void protobuf_ShutdownFile_msgs_2fbool_2eproto(); - - void InitAsDefaultInstance(); - static Bool* default_instance_; -}; -// =================================================================== - - -// =================================================================== - -// Bool - -// required bool data = 1; -inline bool Bool::has_data() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void Bool::set_has_data() { - _has_bits_[0] |= 0x00000001u; -} -inline void Bool::clear_has_data() { - _has_bits_[0] &= ~0x00000001u; -} -inline void Bool::clear_data() { - data_ = false; - clear_has_data(); -} -inline bool Bool::data() const { - return data_; -} -inline void Bool::set_data(bool value) { - set_has_data(); - data_ = value; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace msgs -} // namespace gazebo - -#ifndef SWIG -namespace google { -namespace protobuf { - - -} // namespace google -} // namespace protobuf -#endif // SWIG - -// @@protoc_insertion_point(global_scope) - -#endif // PROTOBUF_msgs_2fbool_2eproto__INCLUDED diff --git a/simulation/frc_gazebo_plugins/msgs/src/msgs/driver-station.pb.cc b/simulation/frc_gazebo_plugins/msgs/src/msgs/driver-station.pb.cc deleted file mode 100644 index 6629d408ed..0000000000 --- a/simulation/frc_gazebo_plugins/msgs/src/msgs/driver-station.pb.cc +++ /dev/null @@ -1,385 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: msgs/driver-station.proto - -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "msgs/driver-station.pb.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace gazebo { -namespace msgs { - -namespace { - -const ::google::protobuf::Descriptor* DriverStation_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - DriverStation_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* DriverStation_State_descriptor_ = NULL; - -} // namespace - - -void protobuf_AssignDesc_msgs_2fdriver_2dstation_2eproto() { - protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "msgs/driver-station.proto"); - GOOGLE_CHECK(file != NULL); - DriverStation_descriptor_ = file->message_type(0); - static const int DriverStation_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DriverStation, enabled_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DriverStation, state_), - }; - DriverStation_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - DriverStation_descriptor_, - DriverStation::default_instance_, - DriverStation_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DriverStation, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DriverStation, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(DriverStation)); - DriverStation_State_descriptor_ = DriverStation_descriptor_->enum_type(0); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_msgs_2fdriver_2dstation_2eproto); -} - -void protobuf_RegisterTypes(const ::std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DriverStation_descriptor_, &DriverStation::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_msgs_2fdriver_2dstation_2eproto() { - delete DriverStation::default_instance_; - delete DriverStation_reflection_; -} - -void protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\031msgs/driver-station.proto\022\013gazebo.msgs" - "\"z\n\rDriverStation\022\017\n\007enabled\030\001 \002(\010\022/\n\005st" - "ate\030\002 \002(\0162 .gazebo.msgs.DriverStation.St" - "ate\"\'\n\005State\022\010\n\004AUTO\020\000\022\n\n\006TELEOP\020\001\022\010\n\004TE" - "ST\020\002B\021B\017GzDriverStation", 183); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "msgs/driver-station.proto", &protobuf_RegisterTypes); - DriverStation::default_instance_ = new DriverStation(); - DriverStation::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_msgs_2fdriver_2dstation_2eproto); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_msgs_2fdriver_2dstation_2eproto { - StaticDescriptorInitializer_msgs_2fdriver_2dstation_2eproto() { - protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto(); - } -} static_descriptor_initializer_msgs_2fdriver_2dstation_2eproto_; - -// =================================================================== - -const ::google::protobuf::EnumDescriptor* DriverStation_State_descriptor() { - protobuf_AssignDescriptorsOnce(); - return DriverStation_State_descriptor_; -} -bool DriverStation_State_IsValid(int value) { - switch(value) { - case 0: - case 1: - case 2: - return true; - default: - return false; - } -} - -#ifndef _MSC_VER -const DriverStation_State DriverStation::AUTO; -const DriverStation_State DriverStation::TELEOP; -const DriverStation_State DriverStation::TEST; -const DriverStation_State DriverStation::State_MIN; -const DriverStation_State DriverStation::State_MAX; -const int DriverStation::State_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER -const int DriverStation::kEnabledFieldNumber; -const int DriverStation::kStateFieldNumber; -#endif // !_MSC_VER - -DriverStation::DriverStation() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void DriverStation::InitAsDefaultInstance() { -} - -DriverStation::DriverStation(const DriverStation& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void DriverStation::SharedCtor() { - _cached_size_ = 0; - enabled_ = false; - state_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -DriverStation::~DriverStation() { - SharedDtor(); -} - -void DriverStation::SharedDtor() { - if (this != default_instance_) { - } -} - -void DriverStation::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* DriverStation::descriptor() { - protobuf_AssignDescriptorsOnce(); - return DriverStation_descriptor_; -} - -const DriverStation& DriverStation::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto(); - return *default_instance_; -} - -DriverStation* DriverStation::default_instance_ = NULL; - -DriverStation* DriverStation::New() const { - return new DriverStation; -} - -void DriverStation::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - enabled_ = false; - state_ = 0; - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool DriverStation::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // required bool enabled = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &enabled_))); - set_has_enabled(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(16)) goto parse_state; - break; - } - - // required .gazebo.msgs.DriverStation.State state = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_state: - int value; - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( - input, &value))); - if (::gazebo::msgs::DriverStation_State_IsValid(value)) { - set_state(static_cast< ::gazebo::msgs::DriverStation_State >(value)); - } else { - mutable_unknown_fields()->AddVarint(2, value); - } - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void DriverStation::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // required bool enabled = 1; - if (has_enabled()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->enabled(), output); - } - - // required .gazebo.msgs.DriverStation.State state = 2; - if (has_state()) { - ::google::protobuf::internal::WireFormatLite::WriteEnum( - 2, this->state(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* DriverStation::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // required bool enabled = 1; - if (has_enabled()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->enabled(), target); - } - - // required .gazebo.msgs.DriverStation.State state = 2; - if (has_state()) { - target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 2, this->state(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int DriverStation::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // required bool enabled = 1; - if (has_enabled()) { - total_size += 1 + 1; - } - - // required .gazebo.msgs.DriverStation.State state = 2; - if (has_state()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->state()); - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void DriverStation::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const DriverStation* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void DriverStation::MergeFrom(const DriverStation& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_enabled()) { - set_enabled(from.enabled()); - } - if (from.has_state()) { - set_state(from.state()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void DriverStation::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void DriverStation::CopyFrom(const DriverStation& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool DriverStation::IsInitialized() const { - if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false; - - return true; -} - -void DriverStation::Swap(DriverStation* other) { - if (other != this) { - std::swap(enabled_, other->enabled_); - std::swap(state_, other->state_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata DriverStation::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = DriverStation_descriptor_; - metadata.reflection = DriverStation_reflection_; - return metadata; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace msgs -} // namespace gazebo - -// @@protoc_insertion_point(global_scope) diff --git a/simulation/frc_gazebo_plugins/msgs/src/msgs/driver-station.pb.h b/simulation/frc_gazebo_plugins/msgs/src/msgs/driver-station.pb.h deleted file mode 100644 index ce3709810a..0000000000 --- a/simulation/frc_gazebo_plugins/msgs/src/msgs/driver-station.pb.h +++ /dev/null @@ -1,250 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: msgs/driver-station.proto - -#ifndef PROTOBUF_msgs_2fdriver_2dstation_2eproto__INCLUDED -#define PROTOBUF_msgs_2fdriver_2dstation_2eproto__INCLUDED - -#include - -#include - -#if GOOGLE_PROTOBUF_VERSION < 2005000 -#error This file was generated by a newer version of protoc which is -#error incompatible with your Protocol Buffer headers. Please update -#error your headers. -#endif -#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION -#error This file was generated by an older version of protoc which is -#error incompatible with your Protocol Buffer headers. Please -#error regenerate this file with a newer version of protoc. -#endif - -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace gazebo { -namespace msgs { - -// Internal implementation detail -- do not call these. -void protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto(); -void protobuf_AssignDesc_msgs_2fdriver_2dstation_2eproto(); -void protobuf_ShutdownFile_msgs_2fdriver_2dstation_2eproto(); - -class DriverStation; - -enum DriverStation_State { - DriverStation_State_AUTO = 0, - DriverStation_State_TELEOP = 1, - DriverStation_State_TEST = 2 -}; -bool DriverStation_State_IsValid(int value); -const DriverStation_State DriverStation_State_State_MIN = DriverStation_State_AUTO; -const DriverStation_State DriverStation_State_State_MAX = DriverStation_State_TEST; -const int DriverStation_State_State_ARRAYSIZE = DriverStation_State_State_MAX + 1; - -const ::google::protobuf::EnumDescriptor* DriverStation_State_descriptor(); -inline const ::std::string& DriverStation_State_Name(DriverStation_State value) { - return ::google::protobuf::internal::NameOfEnum( - DriverStation_State_descriptor(), value); -} -inline bool DriverStation_State_Parse( - const ::std::string& name, DriverStation_State* value) { - return ::google::protobuf::internal::ParseNamedEnum( - DriverStation_State_descriptor(), name, value); -} -// =================================================================== - -class DriverStation : public ::google::protobuf::Message { - public: - DriverStation(); - virtual ~DriverStation(); - - DriverStation(const DriverStation& from); - - inline DriverStation& operator=(const DriverStation& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const DriverStation& default_instance(); - - void Swap(DriverStation* other); - - // implements Message ---------------------------------------------- - - DriverStation* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const DriverStation& from); - void MergeFrom(const DriverStation& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - typedef DriverStation_State State; - static const State AUTO = DriverStation_State_AUTO; - static const State TELEOP = DriverStation_State_TELEOP; - static const State TEST = DriverStation_State_TEST; - static inline bool State_IsValid(int value) { - return DriverStation_State_IsValid(value); - } - static const State State_MIN = - DriverStation_State_State_MIN; - static const State State_MAX = - DriverStation_State_State_MAX; - static const int State_ARRAYSIZE = - DriverStation_State_State_ARRAYSIZE; - static inline const ::google::protobuf::EnumDescriptor* - State_descriptor() { - return DriverStation_State_descriptor(); - } - static inline const ::std::string& State_Name(State value) { - return DriverStation_State_Name(value); - } - static inline bool State_Parse(const ::std::string& name, - State* value) { - return DriverStation_State_Parse(name, value); - } - - // accessors ------------------------------------------------------- - - // required bool enabled = 1; - inline bool has_enabled() const; - inline void clear_enabled(); - static const int kEnabledFieldNumber = 1; - inline bool enabled() const; - inline void set_enabled(bool value); - - // required .gazebo.msgs.DriverStation.State state = 2; - inline bool has_state() const; - inline void clear_state(); - static const int kStateFieldNumber = 2; - inline ::gazebo::msgs::DriverStation_State state() const; - inline void set_state(::gazebo::msgs::DriverStation_State value); - - // @@protoc_insertion_point(class_scope:gazebo.msgs.DriverStation) - private: - inline void set_has_enabled(); - inline void clear_has_enabled(); - inline void set_has_state(); - inline void clear_has_state(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - bool enabled_; - int state_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto(); - friend void protobuf_AssignDesc_msgs_2fdriver_2dstation_2eproto(); - friend void protobuf_ShutdownFile_msgs_2fdriver_2dstation_2eproto(); - - void InitAsDefaultInstance(); - static DriverStation* default_instance_; -}; -// =================================================================== - - -// =================================================================== - -// DriverStation - -// required bool enabled = 1; -inline bool DriverStation::has_enabled() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void DriverStation::set_has_enabled() { - _has_bits_[0] |= 0x00000001u; -} -inline void DriverStation::clear_has_enabled() { - _has_bits_[0] &= ~0x00000001u; -} -inline void DriverStation::clear_enabled() { - enabled_ = false; - clear_has_enabled(); -} -inline bool DriverStation::enabled() const { - return enabled_; -} -inline void DriverStation::set_enabled(bool value) { - set_has_enabled(); - enabled_ = value; -} - -// required .gazebo.msgs.DriverStation.State state = 2; -inline bool DriverStation::has_state() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void DriverStation::set_has_state() { - _has_bits_[0] |= 0x00000002u; -} -inline void DriverStation::clear_has_state() { - _has_bits_[0] &= ~0x00000002u; -} -inline void DriverStation::clear_state() { - state_ = 0; - clear_has_state(); -} -inline ::gazebo::msgs::DriverStation_State DriverStation::state() const { - return static_cast< ::gazebo::msgs::DriverStation_State >(state_); -} -inline void DriverStation::set_state(::gazebo::msgs::DriverStation_State value) { - assert(::gazebo::msgs::DriverStation_State_IsValid(value)); - set_has_state(); - state_ = value; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace msgs -} // namespace gazebo - -#ifndef SWIG -namespace google { -namespace protobuf { - -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::gazebo::msgs::DriverStation_State>() { - return ::gazebo::msgs::DriverStation_State_descriptor(); -} - -} // namespace google -} // namespace protobuf -#endif // SWIG - -// @@protoc_insertion_point(global_scope) - -#endif // PROTOBUF_msgs_2fdriver_2dstation_2eproto__INCLUDED diff --git a/simulation/frc_gazebo_plugins/msgs/src/msgs/float64.pb.cc b/simulation/frc_gazebo_plugins/msgs/src/msgs/float64.pb.cc deleted file mode 100644 index 49e23a8470..0000000000 --- a/simulation/frc_gazebo_plugins/msgs/src/msgs/float64.pb.cc +++ /dev/null @@ -1,310 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: msgs/float64.proto - -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "msgs/float64.pb.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace gazebo { -namespace msgs { - -namespace { - -const ::google::protobuf::Descriptor* Float64_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Float64_reflection_ = NULL; - -} // namespace - - -void protobuf_AssignDesc_msgs_2ffloat64_2eproto() { - protobuf_AddDesc_msgs_2ffloat64_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "msgs/float64.proto"); - GOOGLE_CHECK(file != NULL); - Float64_descriptor_ = file->message_type(0); - static const int Float64_offsets_[1] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Float64, data_), - }; - Float64_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - Float64_descriptor_, - Float64::default_instance_, - Float64_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Float64, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Float64, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(Float64)); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_msgs_2ffloat64_2eproto); -} - -void protobuf_RegisterTypes(const ::std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Float64_descriptor_, &Float64::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_msgs_2ffloat64_2eproto() { - delete Float64::default_instance_; - delete Float64_reflection_; -} - -void protobuf_AddDesc_msgs_2ffloat64_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\022msgs/float64.proto\022\013gazebo.msgs\"\027\n\007Flo" - "at64\022\014\n\004data\030\001 \002(\001B\013B\tGzFloat64", 71); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "msgs/float64.proto", &protobuf_RegisterTypes); - Float64::default_instance_ = new Float64(); - Float64::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_msgs_2ffloat64_2eproto); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_msgs_2ffloat64_2eproto { - StaticDescriptorInitializer_msgs_2ffloat64_2eproto() { - protobuf_AddDesc_msgs_2ffloat64_2eproto(); - } -} static_descriptor_initializer_msgs_2ffloat64_2eproto_; - -// =================================================================== - -#ifndef _MSC_VER -const int Float64::kDataFieldNumber; -#endif // !_MSC_VER - -Float64::Float64() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void Float64::InitAsDefaultInstance() { -} - -Float64::Float64(const Float64& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void Float64::SharedCtor() { - _cached_size_ = 0; - data_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -Float64::~Float64() { - SharedDtor(); -} - -void Float64::SharedDtor() { - if (this != default_instance_) { - } -} - -void Float64::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* Float64::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Float64_descriptor_; -} - -const Float64& Float64::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_msgs_2ffloat64_2eproto(); - return *default_instance_; -} - -Float64* Float64::default_instance_ = NULL; - -Float64* Float64::New() const { - return new Float64; -} - -void Float64::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - data_ = 0; - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool Float64::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // required double data = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED64) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( - input, &data_))); - set_has_data(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void Float64::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // required double data = 1; - if (has_data()) { - ::google::protobuf::internal::WireFormatLite::WriteDouble(1, this->data(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* Float64::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // required double data = 1; - if (has_data()) { - target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(1, this->data(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int Float64::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // required double data = 1; - if (has_data()) { - total_size += 1 + 8; - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void Float64::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const Float64* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void Float64::MergeFrom(const Float64& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_data()) { - set_data(from.data()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void Float64::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void Float64::CopyFrom(const Float64& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Float64::IsInitialized() const { - if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false; - - return true; -} - -void Float64::Swap(Float64* other) { - if (other != this) { - std::swap(data_, other->data_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata Float64::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Float64_descriptor_; - metadata.reflection = Float64_reflection_; - return metadata; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace msgs -} // namespace gazebo - -// @@protoc_insertion_point(global_scope) diff --git a/simulation/frc_gazebo_plugins/msgs/src/msgs/float64.pb.h b/simulation/frc_gazebo_plugins/msgs/src/msgs/float64.pb.h deleted file mode 100644 index d1e5c33d7a..0000000000 --- a/simulation/frc_gazebo_plugins/msgs/src/msgs/float64.pb.h +++ /dev/null @@ -1,167 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: msgs/float64.proto - -#ifndef PROTOBUF_msgs_2ffloat64_2eproto__INCLUDED -#define PROTOBUF_msgs_2ffloat64_2eproto__INCLUDED - -#include - -#include - -#if GOOGLE_PROTOBUF_VERSION < 2005000 -#error This file was generated by a newer version of protoc which is -#error incompatible with your Protocol Buffer headers. Please update -#error your headers. -#endif -#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION -#error This file was generated by an older version of protoc which is -#error incompatible with your Protocol Buffer headers. Please -#error regenerate this file with a newer version of protoc. -#endif - -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace gazebo { -namespace msgs { - -// Internal implementation detail -- do not call these. -void protobuf_AddDesc_msgs_2ffloat64_2eproto(); -void protobuf_AssignDesc_msgs_2ffloat64_2eproto(); -void protobuf_ShutdownFile_msgs_2ffloat64_2eproto(); - -class Float64; - -// =================================================================== - -class Float64 : public ::google::protobuf::Message { - public: - Float64(); - virtual ~Float64(); - - Float64(const Float64& from); - - inline Float64& operator=(const Float64& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const Float64& default_instance(); - - void Swap(Float64* other); - - // implements Message ---------------------------------------------- - - Float64* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const Float64& from); - void MergeFrom(const Float64& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // required double data = 1; - inline bool has_data() const; - inline void clear_data(); - static const int kDataFieldNumber = 1; - inline double data() const; - inline void set_data(double value); - - // @@protoc_insertion_point(class_scope:gazebo.msgs.Float64) - private: - inline void set_has_data(); - inline void clear_has_data(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - double data_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void protobuf_AddDesc_msgs_2ffloat64_2eproto(); - friend void protobuf_AssignDesc_msgs_2ffloat64_2eproto(); - friend void protobuf_ShutdownFile_msgs_2ffloat64_2eproto(); - - void InitAsDefaultInstance(); - static Float64* default_instance_; -}; -// =================================================================== - - -// =================================================================== - -// Float64 - -// required double data = 1; -inline bool Float64::has_data() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void Float64::set_has_data() { - _has_bits_[0] |= 0x00000001u; -} -inline void Float64::clear_has_data() { - _has_bits_[0] &= ~0x00000001u; -} -inline void Float64::clear_data() { - data_ = 0; - clear_has_data(); -} -inline double Float64::data() const { - return data_; -} -inline void Float64::set_data(double value) { - set_has_data(); - data_ = value; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace msgs -} // namespace gazebo - -#ifndef SWIG -namespace google { -namespace protobuf { - - -} // namespace google -} // namespace protobuf -#endif // SWIG - -// @@protoc_insertion_point(global_scope) - -#endif // PROTOBUF_msgs_2ffloat64_2eproto__INCLUDED diff --git a/simulation/frc_gazebo_plugins/msgs/src/msgs/msgs.h b/simulation/frc_gazebo_plugins/msgs/src/msgs/msgs.h deleted file mode 100644 index f9f91a6c02..0000000000 --- a/simulation/frc_gazebo_plugins/msgs/src/msgs/msgs.h +++ /dev/null @@ -1,30 +0,0 @@ - -#include "msgs/float64.pb.h" -#include "msgs/bool.pb.h" -#include "msgs/driver-station.pb.h" - -#include -#include - -#ifndef _FRC_MSGS_H_ -#define _FRC_MSGS_H_ - -namespace gazebo { - namespace msgs { - - typedef GzString String; - typedef boost::shared_ptr< gazebo::msgs::String > StringPtr; - typedef const boost::shared_ptr< const gazebo::msgs::String > ConstStringPtr; - - typedef boost::shared_ptr< msgs::Float64 > Float64Ptr; - typedef const boost::shared_ptr< const msgs::Float64 > ConstFloat64Ptr; - - typedef boost::shared_ptr< msgs::Bool > BoolPtr; - typedef const boost::shared_ptr< const msgs::Bool > ConstBoolPtr; - - typedef boost::shared_ptr< msgs::DriverStation > DriverStationPtr; - typedef const boost::shared_ptr< const msgs::DriverStation > ConstDriverStationPtr; - } -} - -#endif /* _FRC_MSGS_H_ */ diff --git a/simulation/frc_gazebo_plugins/pneumatic_piston/CMakeLists.txt b/simulation/frc_gazebo_plugins/pneumatic_piston/CMakeLists.txt deleted file mode 100644 index 8b9a050319..0000000000 --- a/simulation/frc_gazebo_plugins/pneumatic_piston/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.3) -project(gz_pneumatic_piston) - -include (FindPkgConfig) -if (PKG_CONFIG_FOUND) - pkg_check_modules(GAZEBO gazebo) -endif() - -find_package(gazebo REQUIRED) -find_package(Boost COMPONENTS system REQUIRED) -find_library(GZ_MSGS NAMES gz_msgs PATHS ../msgs/build) - -file(GLOB_RECURSE SRC_FILES src/*.cpp) -include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src) -add_library(${PROJECT_NAME} SHARED ${SRC_FILES}) - -link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build/) -target_link_libraries(${PROJECT_NAME} ${GZ_MSGS} ${GAZEBO_LIBRARIES} ${Boost_LIBRARIES}) diff --git a/simulation/frc_gazebo_plugins/pneumatic_piston/Makefile b/simulation/frc_gazebo_plugins/pneumatic_piston/Makefile deleted file mode 100644 index f87ca630be..0000000000 --- a/simulation/frc_gazebo_plugins/pneumatic_piston/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -prefix = /usr -lib.dir = $(prefix)/lib -plugin.dir = $(lib.dir)/frcsim/plugins -build.dir = build - -ext = .so -ifeq ($(shell uname), Darwin) - ext = .dylib -endif - -all: - mkdir -p $(build.dir) - cd ${build.dir} && cmake .. && make - -clean: - rm -rf $(build.dir) - -install: all - mkdir -p $(DESTDIR)$(plugin.dir) - install $(build.dir)/libgz_pneumatic_piston$(ext) $(DESTDIR)$(plugin.dir) diff --git a/simulation/frc_gazebo_plugins/pneumatic_piston/src/pneumatic_piston.cpp b/simulation/frc_gazebo_plugins/pneumatic_piston/src/pneumatic_piston.cpp index b865d26901..11cf43247f 100644 --- a/simulation/frc_gazebo_plugins/pneumatic_piston/src/pneumatic_piston.cpp +++ b/simulation/frc_gazebo_plugins/pneumatic_piston/src/pneumatic_piston.cpp @@ -1,3 +1,9 @@ +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + #include "pneumatic_piston.h" #include @@ -28,7 +34,7 @@ void PneumaticPiston::Load(physics::ModelPtr model, sdf::ElementPtr sdf) { forward_force = -forward_force; reverse_force = -reverse_force; } - + gzmsg << "Initializing piston: " << topic << " joint=" << joint->GetName() << " forward_force=" << forward_force << " reverse_force=" << reverse_force<< std::endl; diff --git a/simulation/frc_gazebo_plugins/pneumatic_piston/src/pneumatic_piston.h b/simulation/frc_gazebo_plugins/pneumatic_piston/src/pneumatic_piston.h index 144c3d181d..8bfb7b107d 100644 --- a/simulation/frc_gazebo_plugins/pneumatic_piston/src/pneumatic_piston.h +++ b/simulation/frc_gazebo_plugins/pneumatic_piston/src/pneumatic_piston.h @@ -1,8 +1,8 @@ #pragma once -#include +#include "simulation/gz_msgs/msgs.h" -#include "msgs/msgs.h" +#include using namespace gazebo; @@ -41,13 +41,13 @@ using namespace gazebo; * \todo Signal should probably be made a tri-state message. */ class PneumaticPiston: public ModelPlugin { -public: +public: PneumaticPiston(); ~PneumaticPiston(); - + /// \brief Load the pneumatic piston and configures it according to the sdf. void Load(physics::ModelPtr model, sdf::ElementPtr sdf); - + /// \brief Updat the force the piston applies on the joint. void Update(const common::UpdateInfo &info); @@ -57,7 +57,7 @@ private: /// \brief The signal is one of: {-1,0,1}. double signal; - + /// \brief The magic force multipliers for each direction. double forward_force, reverse_force; @@ -67,8 +67,8 @@ private: /// \brief Callback for receiving msgs and updating the torque. void Callback(const msgs::ConstFloat64Ptr &msg); - - physics::ModelPtr model; ///< \brief The model that this is attached to. + + physics::ModelPtr model; ///< \brief The model that this is attached to. event::ConnectionPtr updateConn; ///< \brief Pointer to the world update function. transport::NodePtr node; ///< \brief The node we're advertising on. transport::SubscriberPtr sub; ///< \brief Subscriber handle. diff --git a/simulation/frc_gazebo_plugins/potentiometer/CMakeLists.txt b/simulation/frc_gazebo_plugins/potentiometer/CMakeLists.txt deleted file mode 100644 index 0d15c62c76..0000000000 --- a/simulation/frc_gazebo_plugins/potentiometer/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.3) -project(gz_potentiometer) - -include (FindPkgConfig) -if (PKG_CONFIG_FOUND) - pkg_check_modules(GAZEBO gazebo) -endif() - -find_package(gazebo REQUIRED) -find_package(Boost COMPONENTS system REQUIRED) -find_library(GZ_MSGS NAMES gz_msgs PATHS ../msgs/build) - -file(GLOB_RECURSE SRC_FILES src/*.cpp) -include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src) -add_library(${PROJECT_NAME} SHARED ${SRC_FILES}) - -link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build/) -target_link_libraries(${PROJECT_NAME} ${GZ_MSGS} ${GAZEBO_LIBRARIES} ${Boost_LIBRARIES}) diff --git a/simulation/frc_gazebo_plugins/potentiometer/Makefile b/simulation/frc_gazebo_plugins/potentiometer/Makefile deleted file mode 100644 index 54fb9ac7df..0000000000 --- a/simulation/frc_gazebo_plugins/potentiometer/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -prefix = /usr -lib.dir = $(prefix)/lib -plugin.dir = $(lib.dir)/frcsim/plugins -build.dir = build - -ext = .so -ifeq ($(shell uname), Darwin) - ext = .dylib -endif - -all: - mkdir -p $(build.dir) - cd ${build.dir} && cmake .. && make - -clean: - rm -rf $(build.dir) - -install: all - mkdir -p $(DESTDIR)$(plugin.dir) - install $(build.dir)/libgz_potentiometer$(ext) $(DESTDIR)$(plugin.dir) diff --git a/simulation/frc_gazebo_plugins/potentiometer/src/potentiometer.cpp b/simulation/frc_gazebo_plugins/potentiometer/src/potentiometer.cpp index e600907082..f7f4251f21 100644 --- a/simulation/frc_gazebo_plugins/potentiometer/src/potentiometer.cpp +++ b/simulation/frc_gazebo_plugins/potentiometer/src/potentiometer.cpp @@ -1,10 +1,15 @@ +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + #include "potentiometer.h" #include #include #include -#include "msgs/msgs.h" GZ_REGISTER_MODEL_PLUGIN(Potentiometer) @@ -22,7 +27,7 @@ void Potentiometer::Load(physics::ModelPtr model, sdf::ElementPtr sdf) { } else { topic = "~/"+sdf->GetAttribute("name")->GetAsString(); } - + if (sdf->HasElement("units")) { radians = sdf->Get("units") != "degrees"; } else { diff --git a/simulation/frc_gazebo_plugins/potentiometer/src/potentiometer.h b/simulation/frc_gazebo_plugins/potentiometer/src/potentiometer.h index fd03ad97ec..422ff20b6e 100644 --- a/simulation/frc_gazebo_plugins/potentiometer/src/potentiometer.h +++ b/simulation/frc_gazebo_plugins/potentiometer/src/potentiometer.h @@ -1,5 +1,7 @@ #pragma once +#include + #include using namespace gazebo; @@ -24,13 +26,13 @@ using namespace gazebo; * - `units`: Optional. Defaults to radians. */ class Potentiometer: public ModelPlugin { -public: +public: Potentiometer(); ~Potentiometer(); - + /// \brief Load the potentiometer and configures it according to the sdf. void Load(physics::ModelPtr model, sdf::ElementPtr sdf); - + /// \brief Sends out the potentiometer reading each timestep. void Update(const common::UpdateInfo &info); @@ -45,7 +47,7 @@ private: physics::JointPtr joint; - physics::ModelPtr model; ///< \brief The model that this is attached to. + physics::ModelPtr model; ///< \brief The model that this is attached to. event::ConnectionPtr updateConn; ///< \brief Pointer to the world update function. transport::NodePtr node; ///< \brief The node we're advertising on. transport::PublisherPtr pub; ///< \brief Publisher handle. diff --git a/simulation/frc_gazebo_plugins/rangefinder/CMakeLists.txt b/simulation/frc_gazebo_plugins/rangefinder/CMakeLists.txt deleted file mode 100644 index f198303589..0000000000 --- a/simulation/frc_gazebo_plugins/rangefinder/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.3) -project(gz_rangefinder) - -include (FindPkgConfig) -if (PKG_CONFIG_FOUND) - pkg_check_modules(GAZEBO gazebo) -endif() - -find_package(gazebo REQUIRED) -find_package(Boost COMPONENTS system REQUIRED) -find_library(GZ_MSGS NAMES gz_msgs PATHS ../msgs/build) - -file(GLOB_RECURSE SRC_FILES src/*.cpp) -include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src) -add_library(${PROJECT_NAME} SHARED ${SRC_FILES}) - -link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build/) -target_link_libraries(${PROJECT_NAME} ${GZ_MSGS} ${GAZEBO_LIBRARIES} ${Boost_LIBRARIES}) diff --git a/simulation/frc_gazebo_plugins/rangefinder/Makefile b/simulation/frc_gazebo_plugins/rangefinder/Makefile deleted file mode 100644 index 21c3732b3e..0000000000 --- a/simulation/frc_gazebo_plugins/rangefinder/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -prefix = /usr -lib.dir = $(prefix)/lib -plugin.dir = $(lib.dir)/frcsim/plugins -build.dir = build - -ext = .so -ifeq ($(shell uname), Darwin) - ext = .dylib -endif - -all: - mkdir -p $(build.dir) - cd ${build.dir} && cmake .. && make - -clean: - rm -rf $(build.dir) - -install: all - mkdir -p $(DESTDIR)$(plugin.dir) - install $(build.dir)/libgz_rangefinder$(ext) $(DESTDIR)$(plugin.dir) diff --git a/simulation/frc_gazebo_plugins/rangefinder/src/rangefinder.cpp b/simulation/frc_gazebo_plugins/rangefinder/src/rangefinder.cpp index d3408ea599..c91cfb22ea 100644 --- a/simulation/frc_gazebo_plugins/rangefinder/src/rangefinder.cpp +++ b/simulation/frc_gazebo_plugins/rangefinder/src/rangefinder.cpp @@ -1,3 +1,9 @@ +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + #include "rangefinder.h" #include @@ -6,8 +12,6 @@ #include -#include "msgs/msgs.h" - GZ_REGISTER_MODEL_PLUGIN(Rangefinder) Rangefinder::Rangefinder() {} diff --git a/simulation/frc_gazebo_plugins/rangefinder/src/rangefinder.h b/simulation/frc_gazebo_plugins/rangefinder/src/rangefinder.h index a0d9823cce..f9a7ef4c8a 100644 --- a/simulation/frc_gazebo_plugins/rangefinder/src/rangefinder.h +++ b/simulation/frc_gazebo_plugins/rangefinder/src/rangefinder.h @@ -1,5 +1,7 @@ #pragma once +#include + #include using namespace gazebo; @@ -22,13 +24,13 @@ using namespace gazebo; * - `topic`: Optional. Message will be published as a gazebo.msgs.Float64. */ class Rangefinder: public ModelPlugin { -public: +public: Rangefinder(); ~Rangefinder(); - + /// \brief Load the rangefinder and configures it according to the sdf. void Load(physics::ModelPtr model, sdf::ElementPtr sdf); - + /// \brief Sends out the rangefinder reading each timestep. void Update(const common::UpdateInfo &info); @@ -38,8 +40,8 @@ private: /// \brief The sonar sensor that this rangefinder uses sensors::SonarSensorPtr sensor; - - physics::ModelPtr model; ///< \brief The model that this is attached to. + + physics::ModelPtr model; ///< \brief The model that this is attached to. event::ConnectionPtr updateConn; ///< \brief Pointer to the world update function. transport::NodePtr node; ///< \brief The node we're advertising on. transport::PublisherPtr pub; ///< \brief Publisher handle. diff --git a/simulation/frc_gazebo_plugins/servo/src/servo.cpp b/simulation/frc_gazebo_plugins/servo/src/servo.cpp new file mode 100644 index 0000000000..8298280a28 --- /dev/null +++ b/simulation/frc_gazebo_plugins/servo/src/servo.cpp @@ -0,0 +1,70 @@ +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + +#include "servo.h" + +#include +#include + +GZ_REGISTER_MODEL_PLUGIN(Servo) + +Servo::Servo() {} + +Servo::~Servo() {} + +void Servo::Load(physics::ModelPtr model, sdf::ElementPtr sdf){ + this->model = model; + signal = 0; + + //parse SDF Properries + joint = model->GetJoint(sdf->Get("joint")); + if (sdf->HasElement("topic")) { + topic = sdf->Get("topic"); + } + else { + topic = "~/"+sdf->GetAttribute("name")->GetAsString(); + } + + if (sdf->HasElement("torque")) { + torque = sdf->Get("torque"); + } + else { + torque = 5; + } + + gzmsg << "initializing awesome servo: " << topic + << " joint=" << joint->GetName() + << " torque=" << torque << std::endl; + + //Connect to Gazebo transport for messaging + std::string scoped_name = model->GetWorld()->GetName()+"::"+model->GetScopedName(); + boost::replace_all(scoped_name, "::","/"); + node = transport::NodePtr(new transport::Node()); + node->Init(scoped_name); + sub = node->Subscribe(topic, &Servo::Callback, this); + + //connect to the world update event + //this will call update every iteration + updateConn = event::Events::ConnectWorldUpdateBegin(boost::bind(&Servo::Update, this, _1)); +} + +void Servo::Update(const common::UpdateInfo &info){ + //torque is in kg*cm + //joint->SetAngle(0,signal*180); + if (joint->GetAngle(0) < signal){ + joint->SetForce(0,torque); + } + else if (joint->GetAngle(0) > signal){ + joint->SetForce(0,torque); + } + joint->SetForce(0,0); +} + +void Servo::Callback(const msgs::ConstFloat64Ptr &msg){ + signal = msg->data(); + if (signal < -1) { signal = -1; } + else if (signal > 1) { signal = 1; } +} diff --git a/simulation/frc_gazebo_plugins/servo/src/servo.h b/simulation/frc_gazebo_plugins/servo/src/servo.h new file mode 100644 index 0000000000..a998761725 --- /dev/null +++ b/simulation/frc_gazebo_plugins/servo/src/servo.h @@ -0,0 +1,59 @@ +#pragma once + +#include "simulation/gz_msgs/msgs.h" + +#include + +using namespace gazebo; + +/** + * \brief Plugin for controlling a servo. + * + * This plugin subscribes to a topic to get a signal in the range + * [-1,1]. Every physics update the joint's torque is set as + * multiplier*signal. + * + * To add a servo to your robot, add the following XML to your robot + * model: + * + * + * Joint Name + * /gzebo/frc/simulator/pwm/1 + * + * + * - `link`: Name of the link the servo is attached to. + * - `topic`: Optional. Message type should be gazebo.msgs.Float64. + */ +class Servo: public ModelPlugin { +public: + Servo(); + ~Servo(); + + /// \brief load the servo and configure it according to the sdf + void Load(physics::ModelPtr model, sdf::ElementPtr sdf); + + /// \brief Update the torque on the joint from the dc motor each timestep. + void Update(const common::UpdateInfo &info); + +private: + /// \brief Topic to read control signal from. + std::string topic; + + /// \brief the pwm signal limited to the range [-1,1] + double signal; + + /// \brief the torque of the motor in kg/cm + double torque; + + /// \brief the joint that this servo moves + physics::JointPtr joint; + + /// \brief Callback for receiving msgs and storing the signal + void Callback(const msgs::ConstFloat64Ptr &msg); + + physics::ModelPtr model; ///< \brief The model that this is attached to + event::ConnectionPtr updateConn; ///< \brief The Pointer to the world update function + transport::NodePtr node; ///< \brief The node we're advertising torque on + transport::SubscriberPtr sub; ///< \brief the Subscriber for the pwm signal + +}; diff --git a/simulation/frcsim.bat b/simulation/frcsim.bat new file mode 100644 index 0000000000..f270c47c12 --- /dev/null +++ b/simulation/frcsim.bat @@ -0,0 +1,11 @@ +#THIS IS VERY TEMPORARY, AND VERY SHITTY +#this was written to work on my virtual machine before there was any installer for gazebo, so if you see this, yell at me +#@Author Peter Mitrano + +cd C:\Users\peter\gz-ws\gazebo\build +call ..\win_addpath.bat Debug +cd gazebo +SET GAZEBO_PLUGINS_PATH=%GAZEBO_PLUGINS_PATH%;"C:\Users\peter\wpilib\plugins" +START "gzserver" ".\gzserver.exe" --verbose "%*" +cd gui +START "gzclient" ".\gzclient.exe" --verbose diff --git a/simulation/frcsim.sh b/simulation/frcsim.sh new file mode 100755 index 0000000000..a923f53ccd --- /dev/null +++ b/simulation/frcsim.sh @@ -0,0 +1,5 @@ +#!/bin/bash +export GAZEBO_PLUGIN_PATH="${GAZEBO_PLUGIN_PATH}:${HOME}/wpilib/simulation/plugins" +export GAZEBO_MODEL_PATH="${GAZEBO_MODEL_PATH}:${HOME}/wpilib/simulation/models" +export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${HOME}/wpilib/simulation/plugins" +gazebo $@ diff --git a/simulation/gz_msgs/CMakeLists.txt b/simulation/gz_msgs/CMakeLists.txt new file mode 100644 index 0000000000..17ecf5cf8b --- /dev/null +++ b/simulation/gz_msgs/CMakeLists.txt @@ -0,0 +1,64 @@ +cmake_minimum_required(VERSION 2.8) +project(gz_msgs) + +#list all proto files used +get_filename_component(PROTO_DIR src/main/proto ABSOLUTE) +set(msgs + "${PROTO_DIR}/bool.proto" + "${PROTO_DIR}/driver-station.proto" + "${PROTO_DIR}/float64.proto" + "${PROTO_DIR}/frc_joystick.proto" +) + +set (GZ_MSGS_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated" CACHE FILEPATH "gz_msgs include directory") +set (GZ_MSGS_INCLUDE_SUBDIR "${GZ_MSGS_INCLUDE_DIR}/simulation/gz_msgs") +file(MAKE_DIRECTORY ${GZ_MSGS_INCLUDE_SUBDIR}) + +set(PROTO_SRCS) +set(PROTO_HDRS) +set(MSGS_HEADER "${GZ_MSGS_INCLUDE_SUBDIR}/msgs.h") +foreach(FIL ${msgs}) + get_filename_component(ABS_FIL ${FIL} ABSOLUTE) + get_filename_component(FIL_WE ${FIL} NAME_WE) + + list(APPEND PROTO_SRCS "${GZ_MSGS_INCLUDE_SUBDIR}/${FIL_WE}.pb.cc") + list(APPEND PROTO_HDRS "${GZ_MSGS_INCLUDE_SUBDIR}/${FIL_WE}.pb.h") + + add_custom_command( + OUTPUT + "${GZ_MSGS_INCLUDE_SUBDIR}/${FIL_WE}.pb.cc" + "${GZ_MSGS_INCLUDE_SUBDIR}/${FIL_WE}.pb.h" + + COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} + ARGS --cpp_out=${GZ_MSGS_INCLUDE_SUBDIR} --proto_path=${PROTO_DIR} ${ABS_FIL} + COMMENT "compiling ${ABS_FIL}" + VERBATIM) +endforeach() + +set_source_files_properties(${PROTO_SRCS} ${PROTO_HDRS} PROPERTIES GENERATED TRUE) + + +############################################### +#Generating msgs.h + +#create the message_headers and keep it in cache +set (message_headers "" CACHE INTERNAL "Include dirs description") + +#add includes to the msgs.h file +foreach (hdr ${PROTO_HDRS}) + string (REPLACE "${CMAKE_CURRENT_BINARY_DIR}/generated/" "" hdr ${hdr}) + APPEND_TO_CACHED_STRING(message_headers + "Message Types" "#include \"${hdr}\"\n") +endforeach() + +configure_file(msgs.h.in ${MSGS_HEADER}) + +file(GLOB_RECURSE COM_SRC_FILES msgs/*.cc) +include_directories(msgs ${PROTOBUF_INCLUDE_DIR}) +if (WIN32) + add_library(${PROJECT_NAME} ${PROTO_SRCS} ${SRC_FILES}) +else() + add_library(${PROJECT_NAME} SHARED ${PROTO_SRCS} ${SRC_FILES}) +endif() + +target_link_libraries(${PROJECT_NAME} ${PROTOBUF_LIBRARIES}) diff --git a/simulation/gz_msgs/README.md b/simulation/gz_msgs/README.md new file mode 100644 index 0000000000..203457d1cc --- /dev/null +++ b/simulation/gz_msgs/README.md @@ -0,0 +1,6 @@ +Building gz_msgs +================ + +Currently uses cmake. +This is build as a part of the whole cmake project. +see top level building.md for detail diff --git a/wpilibc/wpilibC++Sim/include/simulation/msgs/msgs.h b/simulation/gz_msgs/msgs.h.in similarity index 66% rename from wpilibc/wpilibC++Sim/include/simulation/msgs/msgs.h rename to simulation/gz_msgs/msgs.h.in index 2d8a5f0c1a..42cccc7927 100644 --- a/wpilibc/wpilibC++Sim/include/simulation/msgs/msgs.h +++ b/simulation/gz_msgs/msgs.h.in @@ -1,19 +1,25 @@ +//Auto Generated +//@author Peter Mitrano +#ifndef _FRC_MSGS_H_ +#define _FRC_MSGS_H_ -#include "simulation/msgs/float64.pb.h" -#include "simulation/msgs/bool.pb.h" -#include "simulation/msgs/joystick.pb.h" -#include "simulation/msgs/driver-station.pb.h" +#ifdef _WIN32 + //include this before anything else includes windows.h + //putting this here saves putting it in more files + #include +#endif + + +${message_headers} #include #include -#ifndef _FRC_MSGS_H_ -#define _FRC_MSGS_H_ - namespace gazebo { namespace msgs { typedef GzString String; + typedef boost::shared_ptr< gazebo::msgs::String > StringPtr; typedef const boost::shared_ptr< const gazebo::msgs::String > ConstStringPtr; @@ -22,9 +28,9 @@ namespace gazebo { typedef boost::shared_ptr< msgs::Bool > BoolPtr; typedef const boost::shared_ptr< const msgs::Bool > ConstBoolPtr; - - typedef boost::shared_ptr< msgs::Joystick > JoystickPtr; - typedef const boost::shared_ptr< const msgs::Joystick > ConstJoystickPtr; + + typedef boost::shared_ptr< msgs::FRCJoystick > FRCJoystickPtr; + typedef const boost::shared_ptr< const msgs::FRCJoystick > ConstFRCJoystickPtr; typedef boost::shared_ptr< msgs::DriverStation > DriverStationPtr; typedef const boost::shared_ptr< const msgs::DriverStation > ConstDriverStationPtr; diff --git a/simulation/frc_gazebo_plugins/msgs/proto/bool.proto b/simulation/gz_msgs/src/main/proto/bool.proto similarity index 100% rename from simulation/frc_gazebo_plugins/msgs/proto/bool.proto rename to simulation/gz_msgs/src/main/proto/bool.proto diff --git a/simulation/frc_gazebo_plugins/msgs/proto/driver-station.proto b/simulation/gz_msgs/src/main/proto/driver-station.proto similarity index 100% rename from simulation/frc_gazebo_plugins/msgs/proto/driver-station.proto rename to simulation/gz_msgs/src/main/proto/driver-station.proto diff --git a/simulation/frc_gazebo_plugins/msgs/proto/float64.proto b/simulation/gz_msgs/src/main/proto/float64.proto similarity index 100% rename from simulation/frc_gazebo_plugins/msgs/proto/float64.proto rename to simulation/gz_msgs/src/main/proto/float64.proto diff --git a/simulation/frc_gazebo_plugins/msgs/proto/joystick.proto b/simulation/gz_msgs/src/main/proto/frc_joystick.proto similarity index 75% rename from simulation/frc_gazebo_plugins/msgs/proto/joystick.proto rename to simulation/gz_msgs/src/main/proto/frc_joystick.proto index 2a24c5dec6..ec98abae1c 100644 --- a/simulation/frc_gazebo_plugins/msgs/proto/joystick.proto +++ b/simulation/gz_msgs/src/main/proto/frc_joystick.proto @@ -5,9 +5,9 @@ package gazebo.msgs; /// \brief A message for joystick data /// \verbatim -option java_outer_classname = "GzJoystick"; +option java_outer_classname = "GzFRCJoystick"; -message Joystick +message FRCJoystick { repeated double axes = 1; repeated bool buttons = 2; diff --git a/simulation/pom.xml b/simulation/pom.xml deleted file mode 100644 index 94eab50b57..0000000000 --- a/simulation/pom.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - 4.0.0 - edu.wpi.first.simulation - simulation - pom - 0.1.0-SNAPSHOT - - - JavaGazebo - SimDS - - diff --git a/wpilibc/CMakeLists.txt b/wpilibc/CMakeLists.txt deleted file mode 100644 index e772705abf..0000000000 --- a/wpilibc/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -project(WPILibC) - -add_subdirectory(wpilibC++) -add_subdirectory(wpilibC++Devices) -add_subdirectory(wpilibC++IntegrationTests) diff --git a/wpilibc/build.gradle b/wpilibc/build.gradle index 44f1bf9d2d..cb5881e76e 100644 --- a/wpilibc/build.gradle +++ b/wpilibc/build.gradle @@ -189,6 +189,7 @@ task wpilibcSimZip(type: Zip) { into 'sim/include' from "${sim}/include" from "${shared}/include" + from "../build/simulation/gz_msgs/generated" from '../networktables/cpp/include' from '../hal/include' } diff --git a/wpilibc/wpilibC++/include/Base.h b/wpilibc/wpilibC++/include/Base.h index 7a7cc1266c..826536817f 100644 --- a/wpilibc/wpilibC++/include/Base.h +++ b/wpilibc/wpilibC++/include/Base.h @@ -15,12 +15,29 @@ ClassName(ClassName &&) = default #define DEFAULT_MOVE_CONSTRUCTOR(ClassName) #endif +#if (__cplusplus < 201103L) + #if !defined(_MSC_VER) + #define nullptr NULL + #endif + #define constexpr const +#endif + +#if defined(_MSC_VER) + #define noexcept throw() +#endif + // A struct to use as a deleter when a std::shared_ptr must wrap a raw pointer // that is being deleted by someone else. // This should only be called in deprecated functions; using it anywhere else // will throw warnings. template -struct [[deprecated]] NullDeleter { +struct +#if !defined(_MSC_VER) + [[deprecated]] +#else + __declspec(deprecated) +#endif +NullDeleter { void operator()(T *) const noexcept {}; }; diff --git a/wpilibc/wpilibC++/include/Error.h b/wpilibc/wpilibC++/include/Error.h index 8c1cc2f120..a3688563d0 100644 --- a/wpilibc/wpilibC++/include/Error.h +++ b/wpilibc/wpilibC++/include/Error.h @@ -7,6 +7,13 @@ #pragma once #include "Base.h" + +#ifdef _WIN32 + #include + //Windows.h defines #define GetMessage GetMessageW, which is stupid and we don't want it. + #undef GetMessage +#endif + #include #include diff --git a/wpilibc/wpilibC++/include/LiveWindow/LiveWindow.h b/wpilibc/wpilibC++/include/LiveWindow/LiveWindow.h index e6904aba7d..ba7381f697 100644 --- a/wpilibc/wpilibC++/include/LiveWindow/LiveWindow.h +++ b/wpilibc/wpilibC++/include/LiveWindow/LiveWindow.h @@ -32,24 +32,35 @@ class LiveWindow { public: static LiveWindow &GetInstance(); void Run(); +#if !defined(_MSC_VER) [[deprecated( "Raw pointers are deprecated; pass the component using shared_ptr " "instead.")]] +#else + __declspec(deprecated("**Raw pointers are deprecated; pass the component using shared_ptr instead**")) +#endif void AddSensor(const std::string &subsystem, const std::string &name, LiveWindowSendable *component); void AddSensor(const std::string &subsystem, const std::string &name, LiveWindowSendable &component); void AddSensor(const std::string &subsystem, const std::string &name, std::shared_ptr component); +#if !defined(_MSC_VER) [[deprecated( "Raw pointers are deprecated; pass the component using shared_ptr " "instead.")]] +#else + __declspec(deprecated("**Raw pointers are deprecated; pass the component using shared_ptr instead**")) +#endif void AddActuator(const std::string &subsystem, const std::string &name, LiveWindowSendable *component); void AddActuator(const std::string &subsystem, const std::string &name, LiveWindowSendable &component); void AddActuator(const std::string &subsystem, const std::string &name, std::shared_ptr component); +#if !defined(_MSC_VER) +[[deprecated]] +#endif void AddSensor(std::string type, int channel, LiveWindowSendable *component); void AddActuator(std::string type, int channel, LiveWindowSendable *component); diff --git a/wpilibc/wpilibC++/include/Timer.h b/wpilibc/wpilibC++/include/Timer.h index d00e5004f0..60b9604961 100644 --- a/wpilibc/wpilibC++/include/Timer.h +++ b/wpilibc/wpilibC++/include/Timer.h @@ -44,7 +44,7 @@ class Timer { static double GetMatchTime(); // The time, in seconds, at which the 32-bit FPGA timestamp rolls over to 0 - static constexpr double kRolloverTime = (1ll << 32) / 1e6; + static const double kRolloverTime; private: double m_startTime = 0.0; diff --git a/wpilibc/wpilibC++/src/Error.cpp b/wpilibc/wpilibC++/src/Error.cpp index 1613c7f77a..03aa2a5761 100644 --- a/wpilibc/wpilibC++/src/Error.cpp +++ b/wpilibc/wpilibC++/src/Error.cpp @@ -69,9 +69,17 @@ void Error::Report() { std::stringstream errorStream; errorStream << "Error on line " << m_lineNumber << " "; - errorStream << "of " << basename(m_filename.c_str()) << ": "; - errorStream << m_message << std::endl; - errorStream << GetStackTrace(4); +#if defined(_UNIX) + errorStream << "of " << basename(m_filename.c_str()) << ": "; +#elif defined(_WIN32) + const int MAX_DIR = 100; + char basename[MAX_DIR]; + _splitpath_s(m_filename.c_str(), NULL, 0, basename, MAX_DIR, NULL, 0, NULL, 0); + errorStream << "of " << basename << ": "; +#endif + + errorStream << m_message << std::endl; + errorStream << GetStackTrace(4); std::string error = errorStream.str(); diff --git a/wpilibc/wpilibC++/src/LiveWindow/LiveWindow.cpp b/wpilibc/wpilibC++/src/LiveWindow/LiveWindow.cpp index 9c60db8356..6355aa6833 100644 --- a/wpilibc/wpilibC++/src/LiveWindow/LiveWindow.cpp +++ b/wpilibc/wpilibC++/src/LiveWindow/LiveWindow.cpp @@ -81,9 +81,6 @@ void LiveWindow::AddSensor(const std::string &subsystem, * @brief Use a raw pointer to the LiveWindow. * @deprecated Prefer smart pointers or references. */ -[[deprecated( - "Raw pointers are deprecated; pass the component using shared_ptr " - "instead.")]] void LiveWindow::AddSensor(const std::string &subsystem, const std::string &name, LiveWindowSendable *component) { @@ -135,7 +132,6 @@ void LiveWindow::AddActuator(const std::string &subsystem, const std::string &na /** * Meant for internal use in other WPILib classes. */ -[[deprecated]] void LiveWindow::AddSensor(std::string type, int channel, LiveWindowSendable *component) { std::ostringstream oss; diff --git a/wpilibc/wpilibC++Devices/src/Timer.cpp b/wpilibc/wpilibC++Devices/src/Timer.cpp index ea11d26bbe..9486db1328 100644 --- a/wpilibc/wpilibC++Devices/src/Timer.cpp +++ b/wpilibc/wpilibC++Devices/src/Timer.cpp @@ -51,6 +51,8 @@ double GetTime() { return (realTime); } +//for compatibility with msvc12--see C2864 +const double Timer::kRolloverTime = (1ll << 32) / 1e6; /** * Create a new timer object. * diff --git a/wpilibc/wpilibC++Sim/.gitignore b/wpilibc/wpilibC++Sim/.gitignore new file mode 100644 index 0000000000..e83089b075 --- /dev/null +++ b/wpilibc/wpilibC++Sim/.gitignore @@ -0,0 +1,3 @@ +#don't track the generate protobuf files +include/simulation/msgs/ +src/simulation/msgs diff --git a/wpilibc/wpilibC++Sim/CMakeLists.txt b/wpilibc/wpilibC++Sim/CMakeLists.txt index b2163ac59b..7be2cec34b 100644 --- a/wpilibc/wpilibC++Sim/CMakeLists.txt +++ b/wpilibc/wpilibC++Sim/CMakeLists.txt @@ -1,31 +1,70 @@ cmake_minimum_required(VERSION 2.8) project(WPILibSim) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat=2 -Wall -Wextra -Wno-unused-parameter -fPIC -std=c++1y -DFRC_SIMULATOR") +if (WIN32) + #temporary until we build dlls + add_definitions(-DBUILDING_STATIC_LIBS) + + # XXX: should be set via CMake variables in configure.bat + set(PTHREAD_INCLUDE_DIR "C:/Users/peter/gz-ws/pthread-w32/include") + set(PTHREAD_LIBRARY "C:/Users/peter/gz-ws/pthread-w32/libs/x64/pthreadVC2.lib") +endif() get_filename_component(HAL_API_INCLUDES ../../hal/include REALPATH) get_filename_component(NWT_API_INCLUDES ../../networktables/cpp/include REALPATH) -add_subdirectory(../wpilibC++ wpilibC++) -include (FindPkgConfig) -if (PKG_CONFIG_FOUND) - pkg_check_modules(GAZEBO gazebo) + +# also on windows use sprintf_s instead of snprintf +# TODO: find a more permenenant solution +if (WIN32) + add_definitions(-Dsnprintf=sprintf_s) endif() -find_package(gazebo REQUIRED) - -file(GLOB_RECURSE SRC_FILES src/*.cpp ../../networktables/cpp/lib/share/*.cpp - ../../networktables/cpp/lib/Athena/*.cpp) +if (WIN32) + file(GLOB_RECURSE SRC_FILES src/*.cpp + ../../networktables/cpp/lib/share/*.cpp + ../../networktables/cpp/lib/WIN32/*.cpp) +else() + file(GLOB_RECURSE SRC_FILES src/*.cpp + ../../networktables/cpp/lib/share/*.cpp + ../../networktables/cpp/lib/Athena/*.cpp) +endif() file(GLOB_RECURSE COM_SRC_FILES ../wpilibC++/src/*.cpp) -include_directories(include/ ../../wpilibc/wpilibC++/include - ../../networktables/cpp/include - ../../hal/include - ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS}) # ${NWT_API_INCLUDES} -add_library(WPILibSim SHARED ${SRC_FILES} ${COM_SRC_FILES}) -target_link_libraries(WPILibSim ${GAZEBO_LIBRARIES} -fPIC) # NetworkTables -INSTALL(TARGETS WPILibSim LIBRARY DESTINATION src COMPONENT src) -INSTALL(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT headers) -# ni_emb -# HAL NWT + +set (INCLUDE_FOLDERS include + ../wpilibC++/include + ../../networktables/cpp/include + ../../hal/include + ${GZ_MSGS_INCLUDE_DIR} + ${Boost_INCLUDE_DIR} + ${GAZEBO_INCLUDE_DIRS}) + +if (WIN32) + #these paths will be fixed when a more permenant windows development solution is found + set(INCLUDE_FOLDERS ${INCLUDE_FOLDERS} + C:/Users/peter/gz-ws/protobuf-2.6.0-win64-vc12/src + C:/Users/peter/gz-ws/sdformat/src/win/tinyxml + C:/Users/peter/gz-ws/FreeImage-vc12-x64-release-debug/Source + C:/Users/peter/gz-ws/tbb43_20141023oss/include + ${PTHREAD_INCLUDE_DIR}) +endif() + +include_directories(${INCLUDE_FOLDERS}) + +link_directories(${GAZEBO_LIBRARY_DIRS}) + +if (WIN32) + add_library(WPILibSim ${SRC_FILES} ${COM_SRC_FILES}) +else() + add_library(WPILibSim SHARED ${SRC_FILES} ${COM_SRC_FILES}) +endif() + +target_link_libraries(WPILibSim gz_msgs ${PTHREAD_LIBRARY} ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -fPIC) # NetworkTables + +if (WIN32) + set_target_properties(${project} PROPERTIES LINK_FLAGS "/DEBUG") +endif() + +#copy to eclipse plugin diff --git a/wpilibc/wpilibC++Sim/Makefile b/wpilibc/wpilibC++Sim/Makefile deleted file mode 100644 index 47bf75f1c2..0000000000 --- a/wpilibc/wpilibC++Sim/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -prefix = /usr -lib.dir = $(prefix)/lib -build.dir = build - -all: - mkdir -p $(build.dir) - cd ${build.dir} && cmake .. && make - -clean: - rm -rf $(build.dir) - -install: all - mkdir -p $(DESTDIR)$(lib.dir) - install $(build.dir)/libWPILibSim.so $(DESTDIR)$(lib.dir) - install $(build.dir)/build/wpilibC++/libWPILib.a $(DESTDIR)$(lib.dir) diff --git a/wpilibc/wpilibC++Sim/README.md b/wpilibc/wpilibC++Sim/README.md new file mode 100644 index 0000000000..7abfeda64c --- /dev/null +++ b/wpilibc/wpilibC++Sim/README.md @@ -0,0 +1,2 @@ +# Building WPILib C++ Sim +see top level building.md for details diff --git a/wpilibc/wpilibC++Sim/include/DriverStation.h b/wpilibc/wpilibC++Sim/include/DriverStation.h index 4055ed7fda..ba3261aa45 100644 --- a/wpilibc/wpilibC++Sim/include/DriverStation.h +++ b/wpilibc/wpilibC++Sim/include/DriverStation.h @@ -5,7 +5,14 @@ /*----------------------------------------------------------------------------*/ #pragma once -#include "simulation/msgs/msgs.h" +#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 +#endif + #include #include "SensorBase.h" #include "RobotState.h" @@ -106,16 +113,16 @@ private: static DriverStation *m_instance; static uint8_t m_updateNumber; ///< TODO: Get rid of this and use the semaphore signaling - static constexpr float kUpdatePeriod = 0.02; + static const float kUpdatePeriod; void stateCallback(const msgs::ConstDriverStationPtr &msg); - void joystickCallback(const msgs::ConstJoystickPtr &msg, int i); - void joystickCallback0(const msgs::ConstJoystickPtr &msg); - void joystickCallback1(const msgs::ConstJoystickPtr &msg); - void joystickCallback2(const msgs::ConstJoystickPtr &msg); - void joystickCallback3(const msgs::ConstJoystickPtr &msg); - void joystickCallback4(const msgs::ConstJoystickPtr &msg); - void joystickCallback5(const msgs::ConstJoystickPtr &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; @@ -131,5 +138,5 @@ private: transport::SubscriberPtr stateSub; transport::SubscriberPtr joysticksSub[6]; msgs::DriverStationPtr state; - msgs::JoystickPtr joysticks[6]; + msgs::FRCJoystickPtr joysticks[6]; }; diff --git a/wpilibc/wpilibC++Sim/include/Gyro.h b/wpilibc/wpilibC++Sim/include/Gyro.h index 598a313244..3eae6e8bc6 100644 --- a/wpilibc/wpilibC++Sim/include/Gyro.h +++ b/wpilibc/wpilibC++Sim/include/Gyro.h @@ -28,11 +28,11 @@ class AnalogModule; class Gyro : public SensorBase, public PIDSource, public LiveWindowSendable { public: - static const uint32_t kOversampleBits = 10; - static const uint32_t kAverageBits = 0; - static constexpr float kSamplesPerSecond = 50.0; - static constexpr float kCalibrationSampleTime = 5.0; - static constexpr float kDefaultVoltsPerDegreePerSecond = 0.007; + 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; diff --git a/wpilibc/wpilibC++Sim/include/IterativeRobot.h b/wpilibc/wpilibC++Sim/include/IterativeRobot.h index f0acaef618..7c9104d34f 100644 --- a/wpilibc/wpilibC++Sim/include/IterativeRobot.h +++ b/wpilibc/wpilibC++Sim/include/IterativeRobot.h @@ -10,21 +10,21 @@ /** * IterativeRobot implements a specific type of Robot Program framework, extending the RobotBase class. - * + * * The IterativeRobot class is intended to be subclassed by a user creating a robot program. - * + * * This class is intended to implement the "old style" default code, by providing * the following functions which are called by the main loop, StartCompetition(), at the appropriate times: - * + * * RobotInit() -- provide for initialization at robot power-on - * + * * Init() functions -- each of the following functions is called once when the * appropriate mode is entered: * - DisabledInit() -- called only when first disabled * - AutonomousInit() -- called each and every time autonomous is entered from another mode * - TeleopInit() -- called each and every time teleop is entered from another mode * - TestInit() -- called each and every time test is entered from another mode - * + * * Periodic() functions -- each of these functions is called iteratively at the * appropriate periodic rate (aka the "slow loop"). The default period of * the iterative robot is synced to the driver station control packets, @@ -33,7 +33,7 @@ * - AutonomousPeriodic() * - TeleopPeriodic() * - TestPeriodic() - * + * */ class IterativeRobot : public RobotBase @@ -44,7 +44,7 @@ public: * Setting the period to 0.0 will cause the periodic functions to follow * the Driver Station packet rate of about 50Hz. */ - static constexpr double kDefaultPeriod = 0.0; + static const double kDefaultPeriod; virtual void StartCompetition(); diff --git a/wpilibc/wpilibC++Sim/include/MotorSafetyHelper.h b/wpilibc/wpilibC++Sim/include/MotorSafetyHelper.h index 81377ab87b..bbe76580a4 100644 --- a/wpilibc/wpilibC++Sim/include/MotorSafetyHelper.h +++ b/wpilibc/wpilibC++Sim/include/MotorSafetyHelper.h @@ -1,34 +1,40 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* 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 "ErrorBase.h" +#include "HAL/cpp/priority_mutex.h" + +#include class MotorSafety; -class MotorSafetyHelper : public ErrorBase -{ -public: - MotorSafetyHelper(MotorSafety *safeObject); - ~MotorSafetyHelper(); - void Feed(); - void SetExpiration(float expirationTime); - float GetExpiration() const; - bool IsAlive() const; - void Check(); - void SetSafetyEnabled(bool enabled); - bool IsSafetyEnabled() const; - static void CheckMotors(); -private: - double m_expiration; // the expiration time for this object - bool m_enabled; // true if motor safety is enabled for this motor - double m_stopTime; // the FPGA clock value when this motor has expired - mutable priority_recursive_mutex m_syncMutex; // protect accesses to the state for this object - MotorSafety *m_safeObject; // the object that is using the helper - MotorSafetyHelper *m_nextHelper; // next object in the list of MotorSafetyHelpers - static MotorSafetyHelper *m_headHelper; // the head of the list of MotorSafetyHelper objects - static priority_recursive_mutex m_listMutex; // protect accesses to the list of helpers +class MotorSafetyHelper : public ErrorBase { + public: + MotorSafetyHelper(MotorSafety *safeObject); + ~MotorSafetyHelper(); + void Feed(); + void SetExpiration(float expirationTime); + float GetExpiration() const; + bool IsAlive() const; + void Check(); + void SetSafetyEnabled(bool enabled); + bool IsSafetyEnabled() const; + static void CheckMotors(); + + private: + double m_expiration; // the expiration time for this object + bool m_enabled; // true if motor safety is enabled for this motor + double m_stopTime; // the FPGA clock value when this motor has expired + mutable priority_recursive_mutex + m_syncMutex; // protect accesses to the state for this object + MotorSafety *m_safeObject; // the object that is using the helper + // List of all existing MotorSafetyHelper objects. + static std::set m_helperList; + static priority_recursive_mutex + m_listMutex; // protect accesses to the list of helpers }; diff --git a/wpilibc/wpilibC++Sim/include/PWM.h b/wpilibc/wpilibC++Sim/include/PWM.h index 4a35bc9650..aec0d77592 100644 --- a/wpilibc/wpilibC++Sim/include/PWM.h +++ b/wpilibc/wpilibC++Sim/include/PWM.h @@ -68,16 +68,16 @@ protected: * kDefaultPwmPeriod is the 1x period (5.05 ms). In hardware, the period scaling is implemented as an * output squelch to get longer periods for old devices. */ - static constexpr float kDefaultPwmPeriod = 5.05; + static const float kDefaultPwmPeriod; /** * kDefaultPwmCenter is the PWM range center in ms */ - static constexpr float kDefaultPwmCenter = 1.5; + static const float kDefaultPwmCenter; /** * kDefaultPWMStepsDown is the number of PWM steps below the centerpoint */ - static const int32_t kDefaultPwmStepsDown = 1000; - static const int32_t kPwmDisabled = 0; + static const int32_t kDefaultPwmStepsDown; + static const int32_t kPwmDisabled; virtual void SetPosition(float pos); virtual float GetPosition() const; diff --git a/wpilibc/wpilibC++Sim/include/RobotBase.h b/wpilibc/wpilibC++Sim/include/RobotBase.h index ded8b0efab..984b019ac1 100644 --- a/wpilibc/wpilibC++Sim/include/RobotBase.h +++ b/wpilibc/wpilibC++Sim/include/RobotBase.h @@ -7,6 +7,8 @@ #include "Base.h" #include "DriverStation.h" +#include "simulation/simTime.h" +#include "simulation/MainNode.h" #define START_ROBOT_CLASS(_ClassName_) \ int main() \ diff --git a/wpilibc/wpilibC++Sim/include/simulation/MainNode.h b/wpilibc/wpilibC++Sim/include/simulation/MainNode.h index 87a68d3d82..a76ef50632 100644 --- a/wpilibc/wpilibC++Sim/include/simulation/MainNode.h +++ b/wpilibc/wpilibC++Sim/include/simulation/MainNode.h @@ -2,8 +2,9 @@ #ifndef _SIM_MAIN_NODE_H #define _SIM_MAIN_NODE_H +#include "simulation/gz_msgs/msgs.h" #include -#include "simulation/msgs/msgs.h" +#include using namespace gazebo; @@ -34,11 +35,11 @@ public: bool _latching = false) { return GetInstance()->main->Subscribe(topic, fp, _latching); } - + transport::NodePtr main; private: MainNode() { - gazebo::transport::init(); + gazebo::client::setup(); main = transport::NodePtr(new transport::Node()); main->Init("frc"); gazebo::transport::run(); diff --git a/wpilibc/wpilibC++Sim/include/simulation/SimContinuousOutput.h b/wpilibc/wpilibC++Sim/include/simulation/SimContinuousOutput.h index bf879c533f..06a28e9250 100644 --- a/wpilibc/wpilibC++Sim/include/simulation/SimContinuousOutput.h +++ b/wpilibc/wpilibC++Sim/include/simulation/SimContinuousOutput.h @@ -3,6 +3,12 @@ #ifndef _SIM_SPEED_CONTROLLER_H #define _SIM_SPEED_CONTROLLER_H +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + #include #include "SpeedController.h" diff --git a/wpilibc/wpilibC++Sim/include/simulation/SimDigitalInput.h b/wpilibc/wpilibC++Sim/include/simulation/SimDigitalInput.h index 3f19a48f95..c85c19fb21 100644 --- a/wpilibc/wpilibC++Sim/include/simulation/SimDigitalInput.h +++ b/wpilibc/wpilibC++Sim/include/simulation/SimDigitalInput.h @@ -3,7 +3,7 @@ #ifndef _SIM_DIGITAL_INPUT_H #define _SIM_DIGITAL_INPUT_H -#include "simulation/msgs/msgs.h" +#include "simulation/gz_msgs/msgs.h" #include using namespace gazebo; @@ -16,7 +16,7 @@ public: * @return The value of the potentiometer. */ bool Get(); - + private: bool value; transport::SubscriberPtr sub; diff --git a/wpilibc/wpilibC++Sim/include/simulation/SimEncoder.h b/wpilibc/wpilibC++Sim/include/simulation/SimEncoder.h index 6f551d27be..9f37723221 100644 --- a/wpilibc/wpilibC++Sim/include/simulation/SimEncoder.h +++ b/wpilibc/wpilibC++Sim/include/simulation/SimEncoder.h @@ -3,7 +3,7 @@ #ifndef _SIM_ENCODER_H #define _SIM_ENCODER_H -#include "simulation/msgs/msgs.h" +#include "simulation/gz_msgs/msgs.h" #include #include diff --git a/wpilibc/wpilibC++Sim/include/simulation/SimFloatInput.h b/wpilibc/wpilibC++Sim/include/simulation/SimFloatInput.h index 8a23ece127..6271b9669e 100644 --- a/wpilibc/wpilibC++Sim/include/simulation/SimFloatInput.h +++ b/wpilibc/wpilibC++Sim/include/simulation/SimFloatInput.h @@ -3,7 +3,7 @@ #ifndef _SIM_FLOAT_INPUT_H #define _SIM_FLOAT_INPUT_H -#include "simulation/msgs/msgs.h" +#include "simulation/gz_msgs/msgs.h" #include using namespace gazebo; @@ -16,7 +16,7 @@ public: * @return The value of the potentiometer. */ double Get(); - + private: double value; transport::SubscriberPtr sub; diff --git a/wpilibc/wpilibC++Sim/include/simulation/SimGyro.h b/wpilibc/wpilibC++Sim/include/simulation/SimGyro.h index e4f999233f..fcb81f6d2b 100644 --- a/wpilibc/wpilibC++Sim/include/simulation/SimGyro.h +++ b/wpilibc/wpilibC++Sim/include/simulation/SimGyro.h @@ -3,7 +3,7 @@ #ifndef _SIM_GYRO_H #define _SIM_GYRO_H -#include "simulation/msgs/msgs.h" +#include "simulation/gz_msgs/msgs.h" #include using namespace gazebo; @@ -15,10 +15,10 @@ public: void Reset(); double GetAngle(); double GetVelocity(); - + private: void sendCommand(std::string cmd); - + double position, velocity; transport::SubscriberPtr posSub, velSub; transport::PublisherPtr commandPub; diff --git a/wpilibc/wpilibC++Sim/include/simulation/msgs/bool.pb.h b/wpilibc/wpilibC++Sim/include/simulation/msgs/bool.pb.h deleted file mode 100644 index 47428ad205..0000000000 --- a/wpilibc/wpilibC++Sim/include/simulation/msgs/bool.pb.h +++ /dev/null @@ -1,167 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: msgs/bool.proto - -#ifndef PROTOBUF_msgs_2fbool_2eproto__INCLUDED -#define PROTOBUF_msgs_2fbool_2eproto__INCLUDED - -#include - -#include - -#if GOOGLE_PROTOBUF_VERSION < 2005000 -#error This file was generated by a newer version of protoc which is -#error incompatible with your Protocol Buffer headers. Please update -#error your headers. -#endif -#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION -#error This file was generated by an older version of protoc which is -#error incompatible with your Protocol Buffer headers. Please -#error regenerate this file with a newer version of protoc. -#endif - -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace gazebo { -namespace msgs { - -// Internal implementation detail -- do not call these. -void protobuf_AddDesc_msgs_2fbool_2eproto(); -void protobuf_AssignDesc_msgs_2fbool_2eproto(); -void protobuf_ShutdownFile_msgs_2fbool_2eproto(); - -class Bool; - -// =================================================================== - -class Bool : public ::google::protobuf::Message { - public: - Bool(); - virtual ~Bool(); - - Bool(const Bool& from); - - inline Bool& operator=(const Bool& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const Bool& default_instance(); - - void Swap(Bool* other); - - // implements Message ---------------------------------------------- - - Bool* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const Bool& from); - void MergeFrom(const Bool& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // required bool data = 1; - inline bool has_data() const; - inline void clear_data(); - static const int kDataFieldNumber = 1; - inline bool data() const; - inline void set_data(bool value); - - // @@protoc_insertion_point(class_scope:gazebo.msgs.Bool) - private: - inline void set_has_data(); - inline void clear_has_data(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - bool data_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void protobuf_AddDesc_msgs_2fbool_2eproto(); - friend void protobuf_AssignDesc_msgs_2fbool_2eproto(); - friend void protobuf_ShutdownFile_msgs_2fbool_2eproto(); - - void InitAsDefaultInstance(); - static Bool* default_instance_; -}; -// =================================================================== - - -// =================================================================== - -// Bool - -// required bool data = 1; -inline bool Bool::has_data() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void Bool::set_has_data() { - _has_bits_[0] |= 0x00000001u; -} -inline void Bool::clear_has_data() { - _has_bits_[0] &= ~0x00000001u; -} -inline void Bool::clear_data() { - data_ = false; - clear_has_data(); -} -inline bool Bool::data() const { - return data_; -} -inline void Bool::set_data(bool value) { - set_has_data(); - data_ = value; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace msgs -} // namespace gazebo - -#ifndef SWIG -namespace google { -namespace protobuf { - - -} // namespace google -} // namespace protobuf -#endif // SWIG - -// @@protoc_insertion_point(global_scope) - -#endif // PROTOBUF_msgs_2fbool_2eproto__INCLUDED diff --git a/wpilibc/wpilibC++Sim/include/simulation/msgs/driver-station.pb.h b/wpilibc/wpilibC++Sim/include/simulation/msgs/driver-station.pb.h deleted file mode 100644 index e268ceba82..0000000000 --- a/wpilibc/wpilibC++Sim/include/simulation/msgs/driver-station.pb.h +++ /dev/null @@ -1,250 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: msgs/driver-station.proto - -#ifndef PROTOBUF_msgs_2fdriver_2dstation_2eproto__INCLUDED -#define PROTOBUF_msgs_2fdriver_2dstation_2eproto__INCLUDED - -#include - -#include - -#if GOOGLE_PROTOBUF_VERSION < 2005000 -#error This file was generated by a newer version of protoc which is -#error incompatible with your Protocol Buffer headers. Please update -#error your headers. -#endif -#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION -#error This file was generated by an older version of protoc which is -#error incompatible with your Protocol Buffer headers. Please -#error regenerate this file with a newer version of protoc. -#endif - -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace gazebo { -namespace msgs { - -// Internal implementation detail -- do not call these. -void protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto(); -void protobuf_AssignDesc_msgs_2fdriver_2dstation_2eproto(); -void protobuf_ShutdownFile_msgs_2fdriver_2dstation_2eproto(); - -class DriverStation; - -enum DriverStation_State { - DriverStation_State_AUTO = 0, - DriverStation_State_TELEOP = 1, - DriverStation_State_TEST = 2 -}; -bool DriverStation_State_IsValid(int value); -const DriverStation_State DriverStation_State_State_MIN = DriverStation_State_AUTO; -const DriverStation_State DriverStation_State_State_MAX = DriverStation_State_TEST; -const int DriverStation_State_State_ARRAYSIZE = DriverStation_State_State_MAX + 1; - -const ::google::protobuf::EnumDescriptor* DriverStation_State_descriptor(); -inline const std::string& DriverStation_State_Name(DriverStation_State value) { - return ::google::protobuf::internal::NameOfEnum( - DriverStation_State_descriptor(), value); -} -inline bool DriverStation_State_Parse( - const std::string& name, DriverStation_State* value) { - return ::google::protobuf::internal::ParseNamedEnum( - DriverStation_State_descriptor(), name, value); -} -// =================================================================== - -class DriverStation : public ::google::protobuf::Message { - public: - DriverStation(); - virtual ~DriverStation(); - - DriverStation(const DriverStation& from); - - inline DriverStation& operator=(const DriverStation& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const DriverStation& default_instance(); - - void Swap(DriverStation* other); - - // implements Message ---------------------------------------------- - - DriverStation* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const DriverStation& from); - void MergeFrom(const DriverStation& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - typedef DriverStation_State State; - static const State AUTO = DriverStation_State_AUTO; - static const State TELEOP = DriverStation_State_TELEOP; - static const State TEST = DriverStation_State_TEST; - static inline bool State_IsValid(int value) { - return DriverStation_State_IsValid(value); - } - static const State State_MIN = - DriverStation_State_State_MIN; - static const State State_MAX = - DriverStation_State_State_MAX; - static const int State_ARRAYSIZE = - DriverStation_State_State_ARRAYSIZE; - static inline const ::google::protobuf::EnumDescriptor* - State_descriptor() { - return DriverStation_State_descriptor(); - } - static inline const std::string& State_Name(State value) { - return DriverStation_State_Name(value); - } - static inline bool State_Parse(const std::string& name, - State* value) { - return DriverStation_State_Parse(name, value); - } - - // accessors ------------------------------------------------------- - - // required bool enabled = 1; - inline bool has_enabled() const; - inline void clear_enabled(); - static const int kEnabledFieldNumber = 1; - inline bool enabled() const; - inline void set_enabled(bool value); - - // required .gazebo.msgs.DriverStation.State state = 2; - inline bool has_state() const; - inline void clear_state(); - static const int kStateFieldNumber = 2; - inline ::gazebo::msgs::DriverStation_State state() const; - inline void set_state(::gazebo::msgs::DriverStation_State value); - - // @@protoc_insertion_point(class_scope:gazebo.msgs.DriverStation) - private: - inline void set_has_enabled(); - inline void clear_has_enabled(); - inline void set_has_state(); - inline void clear_has_state(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - bool enabled_; - int state_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto(); - friend void protobuf_AssignDesc_msgs_2fdriver_2dstation_2eproto(); - friend void protobuf_ShutdownFile_msgs_2fdriver_2dstation_2eproto(); - - void InitAsDefaultInstance(); - static DriverStation* default_instance_; -}; -// =================================================================== - - -// =================================================================== - -// DriverStation - -// required bool enabled = 1; -inline bool DriverStation::has_enabled() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void DriverStation::set_has_enabled() { - _has_bits_[0] |= 0x00000001u; -} -inline void DriverStation::clear_has_enabled() { - _has_bits_[0] &= ~0x00000001u; -} -inline void DriverStation::clear_enabled() { - enabled_ = false; - clear_has_enabled(); -} -inline bool DriverStation::enabled() const { - return enabled_; -} -inline void DriverStation::set_enabled(bool value) { - set_has_enabled(); - enabled_ = value; -} - -// required .gazebo.msgs.DriverStation.State state = 2; -inline bool DriverStation::has_state() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void DriverStation::set_has_state() { - _has_bits_[0] |= 0x00000002u; -} -inline void DriverStation::clear_has_state() { - _has_bits_[0] &= ~0x00000002u; -} -inline void DriverStation::clear_state() { - state_ = 0; - clear_has_state(); -} -inline ::gazebo::msgs::DriverStation_State DriverStation::state() const { - return static_cast< ::gazebo::msgs::DriverStation_State >(state_); -} -inline void DriverStation::set_state(::gazebo::msgs::DriverStation_State value) { - assert(::gazebo::msgs::DriverStation_State_IsValid(value)); - set_has_state(); - state_ = value; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace msgs -} // namespace gazebo - -#ifndef SWIG -namespace google { -namespace protobuf { - -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::gazebo::msgs::DriverStation_State>() { - return ::gazebo::msgs::DriverStation_State_descriptor(); -} - -} // namespace google -} // namespace protobuf -#endif // SWIG - -// @@protoc_insertion_point(global_scope) - -#endif // PROTOBUF_msgs_2fdriver_2dstation_2eproto__INCLUDED diff --git a/wpilibc/wpilibC++Sim/include/simulation/msgs/float64.pb.h b/wpilibc/wpilibC++Sim/include/simulation/msgs/float64.pb.h deleted file mode 100644 index d1e5c33d7a..0000000000 --- a/wpilibc/wpilibC++Sim/include/simulation/msgs/float64.pb.h +++ /dev/null @@ -1,167 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: msgs/float64.proto - -#ifndef PROTOBUF_msgs_2ffloat64_2eproto__INCLUDED -#define PROTOBUF_msgs_2ffloat64_2eproto__INCLUDED - -#include - -#include - -#if GOOGLE_PROTOBUF_VERSION < 2005000 -#error This file was generated by a newer version of protoc which is -#error incompatible with your Protocol Buffer headers. Please update -#error your headers. -#endif -#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION -#error This file was generated by an older version of protoc which is -#error incompatible with your Protocol Buffer headers. Please -#error regenerate this file with a newer version of protoc. -#endif - -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace gazebo { -namespace msgs { - -// Internal implementation detail -- do not call these. -void protobuf_AddDesc_msgs_2ffloat64_2eproto(); -void protobuf_AssignDesc_msgs_2ffloat64_2eproto(); -void protobuf_ShutdownFile_msgs_2ffloat64_2eproto(); - -class Float64; - -// =================================================================== - -class Float64 : public ::google::protobuf::Message { - public: - Float64(); - virtual ~Float64(); - - Float64(const Float64& from); - - inline Float64& operator=(const Float64& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const Float64& default_instance(); - - void Swap(Float64* other); - - // implements Message ---------------------------------------------- - - Float64* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const Float64& from); - void MergeFrom(const Float64& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // required double data = 1; - inline bool has_data() const; - inline void clear_data(); - static const int kDataFieldNumber = 1; - inline double data() const; - inline void set_data(double value); - - // @@protoc_insertion_point(class_scope:gazebo.msgs.Float64) - private: - inline void set_has_data(); - inline void clear_has_data(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - double data_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void protobuf_AddDesc_msgs_2ffloat64_2eproto(); - friend void protobuf_AssignDesc_msgs_2ffloat64_2eproto(); - friend void protobuf_ShutdownFile_msgs_2ffloat64_2eproto(); - - void InitAsDefaultInstance(); - static Float64* default_instance_; -}; -// =================================================================== - - -// =================================================================== - -// Float64 - -// required double data = 1; -inline bool Float64::has_data() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void Float64::set_has_data() { - _has_bits_[0] |= 0x00000001u; -} -inline void Float64::clear_has_data() { - _has_bits_[0] &= ~0x00000001u; -} -inline void Float64::clear_data() { - data_ = 0; - clear_has_data(); -} -inline double Float64::data() const { - return data_; -} -inline void Float64::set_data(double value) { - set_has_data(); - data_ = value; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace msgs -} // namespace gazebo - -#ifndef SWIG -namespace google { -namespace protobuf { - - -} // namespace google -} // namespace protobuf -#endif // SWIG - -// @@protoc_insertion_point(global_scope) - -#endif // PROTOBUF_msgs_2ffloat64_2eproto__INCLUDED diff --git a/wpilibc/wpilibC++Sim/include/simulation/msgs/joystick.pb.h b/wpilibc/wpilibC++Sim/include/simulation/msgs/joystick.pb.h deleted file mode 100644 index a85c8070ba..0000000000 --- a/wpilibc/wpilibC++Sim/include/simulation/msgs/joystick.pb.h +++ /dev/null @@ -1,211 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: msgs/joystick.proto - -#ifndef PROTOBUF_msgs_2fjoystick_2eproto__INCLUDED -#define PROTOBUF_msgs_2fjoystick_2eproto__INCLUDED - -#include - -#include - -#if GOOGLE_PROTOBUF_VERSION < 2005000 -#error This file was generated by a newer version of protoc which is -#error incompatible with your Protocol Buffer headers. Please update -#error your headers. -#endif -#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION -#error This file was generated by an older version of protoc which is -#error incompatible with your Protocol Buffer headers. Please -#error regenerate this file with a newer version of protoc. -#endif - -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace gazebo { -namespace msgs { - -// Internal implementation detail -- do not call these. -void protobuf_AddDesc_msgs_2fjoystick_2eproto(); -void protobuf_AssignDesc_msgs_2fjoystick_2eproto(); -void protobuf_ShutdownFile_msgs_2fjoystick_2eproto(); - -class Joystick; - -// =================================================================== - -class Joystick : public ::google::protobuf::Message { - public: - Joystick(); - virtual ~Joystick(); - - Joystick(const Joystick& from); - - inline Joystick& operator=(const Joystick& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const Joystick& default_instance(); - - void Swap(Joystick* other); - - // implements Message ---------------------------------------------- - - Joystick* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const Joystick& from); - void MergeFrom(const Joystick& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // repeated double axes = 1; - inline int axes_size() const; - inline void clear_axes(); - static const int kAxesFieldNumber = 1; - inline double axes(int index) const; - inline void set_axes(int index, double value); - inline void add_axes(double value); - inline const ::google::protobuf::RepeatedField< double >& - axes() const; - inline ::google::protobuf::RepeatedField< double >* - mutable_axes(); - - // repeated bool buttons = 2; - inline int buttons_size() const; - inline void clear_buttons(); - static const int kButtonsFieldNumber = 2; - inline bool buttons(int index) const; - inline void set_buttons(int index, bool value); - inline void add_buttons(bool value); - inline const ::google::protobuf::RepeatedField< bool >& - buttons() const; - inline ::google::protobuf::RepeatedField< bool >* - mutable_buttons(); - - // @@protoc_insertion_point(class_scope:gazebo.msgs.Joystick) - private: - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::RepeatedField< double > axes_; - ::google::protobuf::RepeatedField< bool > buttons_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_msgs_2fjoystick_2eproto(); - friend void protobuf_AssignDesc_msgs_2fjoystick_2eproto(); - friend void protobuf_ShutdownFile_msgs_2fjoystick_2eproto(); - - void InitAsDefaultInstance(); - static Joystick* default_instance_; -}; -// =================================================================== - - -// =================================================================== - -// Joystick - -// repeated double axes = 1; -inline int Joystick::axes_size() const { - return axes_.size(); -} -inline void Joystick::clear_axes() { - axes_.Clear(); -} -inline double Joystick::axes(int index) const { - return axes_.Get(index); -} -inline void Joystick::set_axes(int index, double value) { - axes_.Set(index, value); -} -inline void Joystick::add_axes(double value) { - axes_.Add(value); -} -inline const ::google::protobuf::RepeatedField< double >& -Joystick::axes() const { - return axes_; -} -inline ::google::protobuf::RepeatedField< double >* -Joystick::mutable_axes() { - return &axes_; -} - -// repeated bool buttons = 2; -inline int Joystick::buttons_size() const { - return buttons_.size(); -} -inline void Joystick::clear_buttons() { - buttons_.Clear(); -} -inline bool Joystick::buttons(int index) const { - return buttons_.Get(index); -} -inline void Joystick::set_buttons(int index, bool value) { - buttons_.Set(index, value); -} -inline void Joystick::add_buttons(bool value) { - buttons_.Add(value); -} -inline const ::google::protobuf::RepeatedField< bool >& -Joystick::buttons() const { - return buttons_; -} -inline ::google::protobuf::RepeatedField< bool >* -Joystick::mutable_buttons() { - return &buttons_; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace msgs -} // namespace gazebo - -#ifndef SWIG -namespace google { -namespace protobuf { - - -} // namespace google -} // namespace protobuf -#endif // SWIG - -// @@protoc_insertion_point(global_scope) - -#endif // PROTOBUF_msgs_2fjoystick_2eproto__INCLUDED diff --git a/wpilibc/wpilibC++Sim/include/simulation/simTime.h b/wpilibc/wpilibC++Sim/include/simulation/simTime.h index b92d3011b6..20fe0c56c7 100644 --- a/wpilibc/wpilibC++Sim/include/simulation/simTime.h +++ b/wpilibc/wpilibC++Sim/include/simulation/simTime.h @@ -1,11 +1,18 @@ #pragma once + +#ifdef _WIN32 + // Ensure that Winsock2.h is included before Windows.h, which can get + // pulled in by anybody (e.g., Boost). + #include +#endif + +#include "simulation/SimFloatInput.h" + #include #include namespace wpilib { namespace internal { extern double simTime; - extern std::condition_variable time_wait; - extern std::mutex time_wait_mutex; - // transport::SubscriberPtr time_sub; + extern void time_callback(const msgs::ConstFloat64Ptr &msg); }} diff --git a/wpilibc/wpilibC++Sim/src/DriverStation.cpp b/wpilibc/wpilibC++Sim/src/DriverStation.cpp index 63bb99c72f..9a0bf2034d 100644 --- a/wpilibc/wpilibC++Sim/src/DriverStation.cpp +++ b/wpilibc/wpilibC++Sim/src/DriverStation.cpp @@ -24,7 +24,7 @@ TLogLevel dsLogLevel = logDEBUG; const uint32_t DriverStation::kBatteryChannel; const uint32_t DriverStation::kJoystickPorts; const uint32_t DriverStation::kJoystickAxes; -constexpr float DriverStation::kUpdatePeriod; +const float DriverStation::kUpdatePeriod = 0.02; uint8_t DriverStation::m_updateNumber = 0; /** @@ -37,22 +37,22 @@ DriverStation::DriverStation() { stateSub = MainNode::Subscribe("~/ds/state", &DriverStation::stateCallback, this); // TODO: for loop + boost bind - joysticks[0] = msgs::JoystickPtr(new msgs::Joystick()); + joysticks[0] = msgs::FRCJoystickPtr(new msgs::FRCJoystick()); joysticksSub[0] = MainNode::Subscribe("~/ds/joysticks/0", &DriverStation::joystickCallback0, this); - joysticks[1] = msgs::JoystickPtr(new msgs::Joystick()); + joysticks[1] = msgs::FRCJoystickPtr(new msgs::FRCJoystick()); joysticksSub[1] = MainNode::Subscribe("~/ds/joysticks/1", &DriverStation::joystickCallback1, this); - joysticks[2] = msgs::JoystickPtr(new msgs::Joystick()); + joysticks[2] = msgs::FRCJoystickPtr(new msgs::FRCJoystick()); joysticksSub[2] = MainNode::Subscribe("~/ds/joysticks/2", &DriverStation::joystickCallback2, this); - joysticks[3] = msgs::JoystickPtr(new msgs::Joystick()); + joysticks[3] = msgs::FRCJoystickPtr(new msgs::FRCJoystick()); joysticksSub[3] = MainNode::Subscribe("~/ds/joysticks/5", &DriverStation::joystickCallback3, this); - joysticks[4] = msgs::JoystickPtr(new msgs::Joystick()); + joysticks[4] = msgs::FRCJoystickPtr(new msgs::FRCJoystick()); joysticksSub[4] = MainNode::Subscribe("~/ds/joysticks/4", &DriverStation::joystickCallback4, this); - joysticks[5] = msgs::JoystickPtr(new msgs::Joystick()); + joysticks[5] = msgs::FRCJoystickPtr(new msgs::FRCJoystick()); joysticksSub[5] = MainNode::Subscribe("~/ds/joysticks/5", &DriverStation::joystickCallback5, this); @@ -148,7 +148,7 @@ short DriverStation::GetStickButtons(uint32_t stick) short btns = 0, btnid; std::unique_lock lock(m_joystickMutex); - msgs::JoystickPtr joy = joysticks[stick]; + msgs::FRCJoystickPtr joy = joysticks[stick]; for (btnid = 0; btnid < joy->buttons().size() && btnid < 12; btnid++) { if (joysticks[stick]->buttons(btnid)) @@ -210,7 +210,8 @@ void DriverStation::SetDigitalOut(uint32_t channel, bool value) */ bool DriverStation::GetDigitalOut(uint32_t channel) { - wpi_setWPIErrorWithContext(UnsupportedInSimulation, "GetDigitalOut"); + wpi_setWPIErrorWithContext(UnsupportedInSimulation, "GetDigitalOut"); + return false; } bool DriverStation::IsEnabled() const @@ -331,39 +332,39 @@ void DriverStation::stateCallback(const msgs::ConstDriverStationPtr &msg) m_waitForDataCond.notify_all(); } -void DriverStation::joystickCallback(const msgs::ConstJoystickPtr &msg, +void DriverStation::joystickCallback(const msgs::ConstFRCJoystickPtr &msg, int i) { std::unique_lock lock(m_joystickMutex); *(joysticks[i]) = *msg; } -void DriverStation::joystickCallback0(const msgs::ConstJoystickPtr &msg) +void DriverStation::joystickCallback0(const msgs::ConstFRCJoystickPtr &msg) { joystickCallback(msg, 0); } -void DriverStation::joystickCallback1(const msgs::ConstJoystickPtr &msg) +void DriverStation::joystickCallback1(const msgs::ConstFRCJoystickPtr &msg) { joystickCallback(msg, 1); } -void DriverStation::joystickCallback2(const msgs::ConstJoystickPtr &msg) +void DriverStation::joystickCallback2(const msgs::ConstFRCJoystickPtr &msg) { joystickCallback(msg, 2); } -void DriverStation::joystickCallback3(const msgs::ConstJoystickPtr &msg) +void DriverStation::joystickCallback3(const msgs::ConstFRCJoystickPtr &msg) { joystickCallback(msg, 3); } -void DriverStation::joystickCallback4(const msgs::ConstJoystickPtr &msg) +void DriverStation::joystickCallback4(const msgs::ConstFRCJoystickPtr &msg) { joystickCallback(msg, 4); } -void DriverStation::joystickCallback5(const msgs::ConstJoystickPtr &msg) +void DriverStation::joystickCallback5(const msgs::ConstFRCJoystickPtr &msg) { joystickCallback(msg, 5); } diff --git a/wpilibc/wpilibC++Sim/src/Gyro.cpp b/wpilibc/wpilibC++Sim/src/Gyro.cpp index bd4bba6ede..09571b76a6 100644 --- a/wpilibc/wpilibC++Sim/src/Gyro.cpp +++ b/wpilibc/wpilibC++Sim/src/Gyro.cpp @@ -9,11 +9,11 @@ #include "WPIErrors.h" #include "LiveWindow/LiveWindow.h" -const uint32_t Gyro::kOversampleBits; -const uint32_t Gyro::kAverageBits; -constexpr float Gyro::kSamplesPerSecond; -constexpr float Gyro::kCalibrationSampleTime; -constexpr float Gyro::kDefaultVoltsPerDegreePerSecond; +const uint32_t Gyro::kOversampleBits = 10; +const uint32_t Gyro::kAverageBits = 0; +const float Gyro::kSamplesPerSecond = 50.0; +const float Gyro::kCalibrationSampleTime = 5.0; +const float Gyro::kDefaultVoltsPerDegreePerSecond = 0.007; /** * Initialize the gyro. @@ -30,7 +30,7 @@ void Gyro::InitGyro(int channel) char buffer[50]; int n = sprintf(buffer, "analog/%d", channel); impl = new SimGyro(buffer); - + LiveWindow::GetInstance().AddSensor("Gyro", channel, this); } @@ -56,12 +56,12 @@ void Gyro::Reset() /** * Return the actual angle in degrees that the robot is currently facing. - * + * * The angle is based on the current accumulator value corrected by the oversampling rate, the * gyro type and the A/D calibration values. * The angle is continuous, that is can go beyond 360 degrees. This make algorithms that wouldn't * want to see a discontinuity in the gyro output as it sweeps past 0 on the second time around. - * + * * @return the current heading of the robot in degrees. This heading is based on integration * of the returned rate from the gyro. */ diff --git a/wpilibc/wpilibC++Sim/src/IterativeRobot.cpp b/wpilibc/wpilibC++Sim/src/IterativeRobot.cpp index a1d25a8843..4c3863bca7 100644 --- a/wpilibc/wpilibC++Sim/src/IterativeRobot.cpp +++ b/wpilibc/wpilibC++Sim/src/IterativeRobot.cpp @@ -3,16 +3,19 @@ /* 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 "IterativeRobot.h" #include "DriverStation.h" #include "SmartDashboard/SmartDashboard.h" #include "LiveWindow/LiveWindow.h" #include "networktables/NetworkTable.h" -#include -constexpr double IterativeRobot::kDefaultPeriod; +//not sure what this is used for yet. +#ifdef _UNIX + #include +#endif + +const double IterativeRobot::kDefaultPeriod = 0; /** * Set the period for the periodic functions. diff --git a/wpilibc/wpilibC++Sim/src/MotorSafetyHelper.cpp b/wpilibc/wpilibC++Sim/src/MotorSafetyHelper.cpp index 15747f2652..e0aab7d551 100644 --- a/wpilibc/wpilibC++Sim/src/MotorSafetyHelper.cpp +++ b/wpilibc/wpilibC++Sim/src/MotorSafetyHelper.cpp @@ -1,5 +1,6 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* 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. */ /*----------------------------------------------------------------------------*/ @@ -12,109 +13,96 @@ #include "WPIErrors.h" #include +#include +std::set MotorSafetyHelper::m_helperList; priority_recursive_mutex MotorSafetyHelper::m_listMutex; /** * The constructor for a MotorSafetyHelper object. - * The helper object is constructed for every object that wants to implement the Motor - * Safety protocol. The helper object has the code to actually do the timing and call the - * motors Stop() method when the timeout expires. The motor object is expected to call the + * The helper object is constructed for every object that wants to implement the + * Motor + * Safety protocol. The helper object has the code to actually do the timing and + * call the + * motors Stop() method when the timeout expires. The motor object is expected + * to call the * Feed() method whenever the motors value is updated. - * @param safeObject a pointer to the motor object implementing MotorSafety. This is used + * @param safeObject a pointer to the motor object implementing MotorSafety. + * This is used * to call the Stop() method on the motor. */ MotorSafetyHelper::MotorSafetyHelper(MotorSafety *safeObject) -{ - m_safeObject = safeObject; - m_enabled = false; - m_expiration = DEFAULT_SAFETY_EXPIRATION; - m_stopTime = Timer::GetFPGATimestamp(); + : m_safeObject(safeObject) { + m_enabled = false; + m_expiration = DEFAULT_SAFETY_EXPIRATION; + m_stopTime = Timer::GetFPGATimestamp(); - std::unique_lock sync(m_listMutex); - m_nextHelper = m_headHelper; - m_headHelper = this; + std::unique_lock sync(m_listMutex); + m_helperList.insert(this); } - -MotorSafetyHelper::~MotorSafetyHelper() -{ - std::unique_lock sync(m_listMutex); - if (m_headHelper == this) - { - m_headHelper = m_nextHelper; - } - else - { - MotorSafetyHelper *prev = nullptr; - MotorSafetyHelper *cur = m_headHelper; - while (cur != this && cur != nullptr) - prev = cur, cur = cur->m_nextHelper; - if (cur == this) - prev->m_nextHelper = cur->m_nextHelper; - } +MotorSafetyHelper::~MotorSafetyHelper() { + std::unique_lock sync(m_listMutex); + m_helperList.erase(this); } -/* +/** * Feed the motor safety object. * Resets the timer on this object that is used to do the timeouts. */ -void MotorSafetyHelper::Feed() -{ - std::unique_lock sync(m_syncMutex); - m_stopTime = Timer::GetFPGATimestamp() + m_expiration; +void MotorSafetyHelper::Feed() { + std::unique_lock sync(m_syncMutex); + m_stopTime = Timer::GetFPGATimestamp() + m_expiration; } -/* +/** * Set the expiration time for the corresponding motor safety object. * @param expirationTime The timeout value in seconds. */ -void MotorSafetyHelper::SetExpiration(float expirationTime) -{ - std::unique_lock sync(m_syncMutex); - m_expiration = expirationTime; +void MotorSafetyHelper::SetExpiration(float expirationTime) { + std::unique_lock sync(m_syncMutex); + m_expiration = expirationTime; } /** * Retrieve the timeout value for the corresponding motor safety object. - * @returns the timeout value in seconds. + * @return the timeout value in seconds. */ -float MotorSafetyHelper::GetExpiration() const -{ - std::unique_lock sync(m_syncMutex); - return m_expiration; +float MotorSafetyHelper::GetExpiration() const { + std::unique_lock sync(m_syncMutex); + return m_expiration; } /** * Determine if the motor is still operating or has timed out. - * @returns a true value if the motor is still operating normally and hasn't timed out. + * @return a true value if the motor is still operating normally and hasn't + * timed out. */ -bool MotorSafetyHelper::IsAlive() const -{ - std::unique_lock sync(m_syncMutex); - return !m_enabled || m_stopTime > Timer::GetFPGATimestamp(); +bool MotorSafetyHelper::IsAlive() const { + std::unique_lock sync(m_syncMutex); + return !m_enabled || m_stopTime > Timer::GetFPGATimestamp(); } /** * Check if this motor has exceeded its timeout. - * This method is called periodically to determine if this motor has exceeded its timeout - * value. If it has, the stop method is called, and the motor is shut down until its value is + * This method is called periodically to determine if this motor has exceeded + * its timeout + * value. If it has, the stop method is called, and the motor is shut down until + * its value is * updated again. */ -void MotorSafetyHelper::Check() -{ - DriverStation *ds = DriverStation::GetInstance(); - if (!m_enabled || ds->IsDisabled() || ds->IsTest()) return; +void MotorSafetyHelper::Check() { + DriverStation* ds = DriverStation::GetInstance(); + if (!m_enabled || ds->IsDisabled() || ds->IsTest()) return; - std::unique_lock sync(m_syncMutex); - if (m_stopTime < Timer::GetFPGATimestamp()) - { + std::unique_lock sync(m_syncMutex); + if (m_stopTime < Timer::GetFPGATimestamp()) { std::ostringstream desc; m_safeObject->GetDescription(desc); desc << "... Output not updated often enough."; - wpi_setWPIErrorWithContext(Timeout, desc.str().c_str()); - m_safeObject->StopMotor(); - } + wpi_setWPIErrorWithContext(Timeout, desc.str().c_str()); + m_safeObject->StopMotor(); + } } /** @@ -122,33 +110,30 @@ void MotorSafetyHelper::Check() * Turn on and off the motor safety option for this PWM object. * @param enabled True if motor safety is enforced for this object */ -void MotorSafetyHelper::SetSafetyEnabled(bool enabled) -{ - std::unique_lock sync(m_syncMutex); - m_enabled = enabled; +void MotorSafetyHelper::SetSafetyEnabled(bool enabled) { + std::unique_lock sync(m_syncMutex); + m_enabled = enabled; } /** * Return the state of the motor safety enabled flag * Return if the motor safety is currently enabled for this devicce. - * @returns True if motor safety is enforced for this device + * @return True if motor safety is enforced for this device */ -bool MotorSafetyHelper::IsSafetyEnabled() const -{ - std::unique_lock sync(m_syncMutex); - return m_enabled; +bool MotorSafetyHelper::IsSafetyEnabled() const { + std::unique_lock sync(m_syncMutex); + return m_enabled; } /** * Check the motors to see if any have timed out. - * This static method is called periodically to poll all the motors and stop any that have + * This static method is called periodically to poll all the motors and stop + * any that have * timed out. */ -void MotorSafetyHelper::CheckMotors() -{ - std::unique_lock sync(m_listMutex); - for (MotorSafetyHelper *msh = m_headHelper; msh != nullptr; msh = msh->m_nextHelper) - { - msh->Check(); - } +void MotorSafetyHelper::CheckMotors() { + std::unique_lock sync(m_listMutex); + for (auto elem : m_helperList) { + elem->Check(); + } } diff --git a/wpilibc/wpilibC++Sim/src/Notifier.cpp b/wpilibc/wpilibC++Sim/src/Notifier.cpp index e92e77c905..00856fe275 100644 --- a/wpilibc/wpilibC++Sim/src/Notifier.cpp +++ b/wpilibc/wpilibC++Sim/src/Notifier.cpp @@ -12,6 +12,7 @@ Notifier *Notifier::timerQueueHead = nullptr; priority_recursive_mutex Notifier::queueMutex; int Notifier::refcount = 0; +std::thread Notifier::m_task; std::atomic Notifier::m_stopped(false); /** diff --git a/wpilibc/wpilibC++Sim/src/PIDController.cpp b/wpilibc/wpilibC++Sim/src/PIDController.cpp index 1b1f6d198c..c6abdcac60 100644 --- a/wpilibc/wpilibC++Sim/src/PIDController.cpp +++ b/wpilibc/wpilibC++Sim/src/PIDController.cpp @@ -392,6 +392,37 @@ float PIDController::GetError() const return GetSetpoint() - pidInput; } +/** + * Sets what type of input the PID controller will use + */ +void PIDController::SetPIDSourceType(PIDSourceType pidSource) { + m_pidInput->SetPIDSourceType(pidSource); +} + +/** + * Returns the type of input the PID controller is using + * @return the PID controller input type + */ +PIDSourceType PIDController::GetPIDSourceType() const { + return m_pidInput->GetPIDSourceType(); +} + +/** + * Returns the current average of the error over the past few iterations. + * You can specify the number of iterations to average with SetToleranceBuffer() + * (defaults to 1). This is the same value that is used for OnTarget(). + * @return the average error + */ +float PIDController::GetAvgError() const { + float avgError = 0; + { + std::unique_lock sync(m_mutex); + // Don't divide by zero. + if (m_buf.size()) avgError = m_bufTotal / m_buf.size(); + } + return avgError; +} + /* * Set the percentage error which is considered tolerable for use with * OnTarget. @@ -428,6 +459,25 @@ void PIDController::SetAbsoluteTolerance(float absTolerance) m_tolerance = absTolerance; } +/* + * Set the number of previous error samples to average for tolerancing. When + * determining whether a mechanism is on target, the user may want to use a + * rolling average of previous measurements instead of a precise position or + * velocity. This is useful for noisy sensors which return a few erroneous + * measurements when the mechanism is on target. However, the mechanism will + * not register as on target for at least the specified bufLength cycles. + * @param bufLength Number of previous cycles to average. Defaults to 1. + */ +void PIDController::SetToleranceBuffer(unsigned bufLength) { + m_bufLength = bufLength; + + // Cut the buffer down to size if needed. + while (m_buf.size() > bufLength) { + m_bufTotal -= m_buf.front(); + m_buf.pop(); + } +} + /* * Return true if the error is within the percentage of the total input range, * determined by SetTolerance. This asssumes that the maximum and minimum input diff --git a/wpilibc/wpilibC++Sim/src/PWM.cpp b/wpilibc/wpilibC++Sim/src/PWM.cpp index 3632fd480f..1b1a6dfc6a 100644 --- a/wpilibc/wpilibC++Sim/src/PWM.cpp +++ b/wpilibc/wpilibC++Sim/src/PWM.cpp @@ -10,10 +10,10 @@ #include "Utility.h" #include "WPIErrors.h" -constexpr float PWM::kDefaultPwmPeriod; -constexpr float PWM::kDefaultPwmCenter; -const int32_t PWM::kDefaultPwmStepsDown; -const int32_t PWM::kPwmDisabled; +const float PWM::kDefaultPwmPeriod = 5.05; +const float PWM::kDefaultPwmCenter = 1.5; +const int32_t PWM::kDefaultPwmStepsDown = 1000; +const int32_t PWM::kPwmDisabled = 0; /** * Allocate a PWM given a channel number. diff --git a/wpilibc/wpilibC++Sim/src/RobotBase.cpp b/wpilibc/wpilibC++Sim/src/RobotBase.cpp index e641891cf5..3e0b8f88be 100644 --- a/wpilibc/wpilibC++Sim/src/RobotBase.cpp +++ b/wpilibc/wpilibC++Sim/src/RobotBase.cpp @@ -35,6 +35,7 @@ RobotBase::RobotBase() { m_ds = DriverStation::GetInstance(); RobotState::SetImplementation(*DriverStation::GetInstance()); + transport::SubscriberPtr time_pub = MainNode::Subscribe("time", &wpilib::internal::time_callback); } /** diff --git a/wpilibc/wpilibC++Sim/src/SampleRobot.cpp b/wpilibc/wpilibC++Sim/src/SampleRobot.cpp index 4903a3107b..366045cfe6 100644 --- a/wpilibc/wpilibC++Sim/src/SampleRobot.cpp +++ b/wpilibc/wpilibC++Sim/src/SampleRobot.cpp @@ -7,12 +7,22 @@ #include "SampleRobot.h" #include -#include #include "Timer.h" #include "SmartDashboard/SmartDashboard.h" #include "LiveWindow/LiveWindow.h" #include "networktables/NetworkTable.h" +#if defined(_UNIX) + #include +#elif defined(_WIN32) + #include + void sleep(unsigned milliseconds) + { + Sleep(milliseconds); + } +#endif + + SampleRobot::SampleRobot() : m_robotMainOverridden (true) { diff --git a/wpilibc/wpilibC++Sim/src/Task.cpp b/wpilibc/wpilibC++Sim/src/Task.cpp deleted file mode 100644 index 7cfecdd650..0000000000 --- a/wpilibc/wpilibC++Sim/src/Task.cpp +++ /dev/null @@ -1,108 +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. */ -/*----------------------------------------------------------------------------*/ - -#include "Task.h" - -//#include "NetworkCommunication/UsageReporting.h" -#include "WPIErrors.h" -#include -#include -#include - -#ifndef OK -#define OK 0 -#endif /* OK */ -#ifndef ERROR -#define ERROR (-1) -#endif /* ERROR */ - -const uint32_t Task::kDefaultPriority; - -Task& Task::operator=(Task&& task) { - m_thread.swap(task.m_thread); - m_taskName = std::move(task.m_taskName.c_str()); - - return *this; -} - -Task::~Task() { - std::cout << "[HAL] Exited task " << m_taskName << std::endl; -} - -bool Task::joinable() const noexcept { - return m_thread.joinable(); -} - -void Task::join() { - m_thread.join(); -} - -void Task::detach() { - m_thread.detach(); -} - -std::thread::id Task::get_id() const noexcept { - return m_thread.get_id(); -} - -std::thread::native_handle_type Task::native_handle() { - return m_thread.native_handle(); -} - -/** - * Verifies a task still exists. - * @returns true on success. - */ -bool Task::Verify() { - auto id = m_thread.native_handle(); - return verifyTaskID(&id) == OK; } - -/** - * Gets the priority of a task. - * @returns task priority or 0 if an error occured - */ -int32_t Task::GetPriority() { - int priority; - auto id = m_thread.native_handle(); - if (HandleError(getTaskPriority(&id, &priority))) - return priority; - else - return 0; -} - -/** - * This routine changes a task's priority to a specified priority. - * Priorities range from 0, the highest priority, to 255, the lowest priority. - * Default task priority is 100. - * @param priority The priority the task should run at. - * @returns true on success. - */ -bool Task::SetPriority(int32_t priority) { - auto id = m_thread.native_handle(); - return HandleError(setTaskPriority(&id, priority)); -} - -/** - * Returns the name of the task. - * @returns Pointer to the name of the task or nullptr if not allocated - */ -std::string Task::GetName() const { return m_taskName; } - -/** - * Handles errors generated by task related code. - */ -bool Task::HandleError(STATUS results) { - if (results != ERROR) return true; - int errsv = errno; - if (errsv == HAL_taskLib_ILLEGAL_PRIORITY) { - wpi_setWPIErrorWithContext(TaskPriorityError, m_taskName.c_str()); - } else { - printf("ERROR: errno=%i", errsv); - wpi_setWPIErrorWithContext(TaskError, m_taskName.c_str()); - } - return false; -} diff --git a/wpilibc/wpilibC++Sim/src/Timer.cpp b/wpilibc/wpilibC++Sim/src/Timer.cpp index 954f3f295e..bf0e7b83cb 100644 --- a/wpilibc/wpilibC++Sim/src/Timer.cpp +++ b/wpilibc/wpilibC++Sim/src/Timer.cpp @@ -11,6 +11,21 @@ #include "simulation/simTime.h" #include "Utility.h" + +// Internal stuff +#include "simulation/SimFloatInput.h" +#include "simulation/MainNode.h" +namespace wpilib { namespace internal { + double simTime = 0; + std::condition_variable time_wait; + std::mutex time_wait_mutex; + + void time_callback(const msgs::ConstFloat64Ptr &msg) { + simTime = msg->data(); + time_wait.notify_all(); + } +}} + /** * Pause the task for a specified time. * @@ -26,8 +41,8 @@ void Wait(double seconds) double start = wpilib::internal::simTime; + std::unique_lock lock(wpilib::internal::time_wait_mutex); while ((wpilib::internal::simTime - start) < seconds) { - std::unique_lock lock(wpilib::internal::time_wait_mutex); wpilib::internal::time_wait.wait(lock); } } @@ -51,6 +66,8 @@ double GetTime() return Timer::GetFPGATimestamp(); // The epoch starts when Gazebo starts } +//for compatibility with msvc12--see C2864 +const double Timer::kRolloverTime = (1ll << 32) / 1e6; /** * Create a new timer object. * @@ -189,17 +206,3 @@ extern "C" uint32_t niTimestamp32(void); uint64_t niTimestamp64(void); } - -// Internal stuff -#include "simulation/SimFloatInput.h" -#include "simulation/MainNode.h" -namespace wpilib { namespace internal { - double simTime = 0; - - void time_callback(const msgs::ConstFloat64Ptr &msg) { - simTime = msg->data(); - time_wait.notify_all(); - } - - transport::SubscriberPtr time_pub = MainNode::Subscribe("~/time", &time_callback); -}} diff --git a/wpilibc/wpilibC++Sim/src/Utility.cpp b/wpilibc/wpilibC++Sim/src/Utility.cpp index dfd332ca83..b0710f14c2 100644 --- a/wpilibc/wpilibC++Sim/src/Utility.cpp +++ b/wpilibc/wpilibC++Sim/src/Utility.cpp @@ -1,4 +1,4 @@ -/*----------------------------------------------------------------------------*/ + /* 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. */ @@ -16,8 +16,10 @@ #include #include #include -#include -#include +#if defined(UNIX) + #include + #include +#endif static bool stackTraceEnabled = false; static bool suspendOnAssertEnabled = false; @@ -75,7 +77,7 @@ bool wpi_assert_impl(bool conditionValue, const std::string &conditionText, } // Print to console and send to remote dashboard - std::cout << "\n\n>>>>" << error; + std::cout << "\n\n>>>>" << error.str(); wpi_handleTracing(); } @@ -109,7 +111,7 @@ void wpi_assertEqual_common_impl(int valueA, int valueB, } // Print to console and send to remote dashboard - std::cout << "\n\n>>>>" << error; + std::cout << "\n\n>>>>" << error.str(); wpi_handleTracing(); } @@ -164,6 +166,8 @@ uint32_t GetFPGATime() return wpilib::internal::simTime * 1e6; } +//TODO: implement symbol demangling and backtrace on windows +#if defined(UNIX) /** * Demangle a C++ symbol, used for printing stack traces. @@ -190,6 +194,7 @@ static std::string demangle(char const *mangledSymbol) } } + // If everything else failed, just return the mangled symbol return mangledSymbol; } @@ -218,3 +223,13 @@ std::string GetStackTrace(uint32_t offset) return trace.str(); } +#else +static std::string demangle(char const *mangledSymbol) +{ + return "no demangling on windows"; +} +std::string GetStackTrace(uint32_t offset) +{ + return "no stack trace on windows"; +} +#endif diff --git a/wpilibc/wpilibC++Sim/src/simulation/msgs/bool.pb.cpp b/wpilibc/wpilibC++Sim/src/simulation/msgs/bool.pb.cpp deleted file mode 100644 index e61ae1a02d..0000000000 --- a/wpilibc/wpilibC++Sim/src/simulation/msgs/bool.pb.cpp +++ /dev/null @@ -1,310 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: msgs/bool.proto - -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "simulation/msgs/bool.pb.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace gazebo { -namespace msgs { - -namespace { - -const ::google::protobuf::Descriptor* Bool_descriptor_ = nullptr; -const ::google::protobuf::internal::GeneratedMessageReflection* - Bool_reflection_ = nullptr; - -} // namespace - - -void protobuf_AssignDesc_msgs_2fbool_2eproto() { - protobuf_AddDesc_msgs_2fbool_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "msgs/bool.proto"); - GOOGLE_CHECK(file != nullptr); - Bool_descriptor_ = file->message_type(0); - static const int Bool_offsets_[1] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Bool, data_), - }; - Bool_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - Bool_descriptor_, - Bool::default_instance_, - Bool_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Bool, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Bool, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(Bool)); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_msgs_2fbool_2eproto); -} - -void protobuf_RegisterTypes(const std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Bool_descriptor_, &Bool::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_msgs_2fbool_2eproto() { - delete Bool::default_instance_; - delete Bool_reflection_; -} - -void protobuf_AddDesc_msgs_2fbool_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\017msgs/bool.proto\022\013gazebo.msgs\"\024\n\004Bool\022\014" - "\n\004data\030\001 \002(\010B\010B\006GzBool", 62); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "msgs/bool.proto", &protobuf_RegisterTypes); - Bool::default_instance_ = new Bool(); - Bool::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_msgs_2fbool_2eproto); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_msgs_2fbool_2eproto { - StaticDescriptorInitializer_msgs_2fbool_2eproto() { - protobuf_AddDesc_msgs_2fbool_2eproto(); - } -} static_descriptor_initializer_msgs_2fbool_2eproto_; - -// =================================================================== - -#ifndef _MSC_VER -const int Bool::kDataFieldNumber; -#endif // !_MSC_VER - -Bool::Bool() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void Bool::InitAsDefaultInstance() { -} - -Bool::Bool(const Bool& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void Bool::SharedCtor() { - _cached_size_ = 0; - data_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -Bool::~Bool() { - SharedDtor(); -} - -void Bool::SharedDtor() { - if (this != default_instance_) { - } -} - -void Bool::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* Bool::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Bool_descriptor_; -} - -const Bool& Bool::default_instance() { - if (default_instance_ == nullptr) protobuf_AddDesc_msgs_2fbool_2eproto(); - return *default_instance_; -} - -Bool* Bool::default_instance_ = nullptr; - -Bool* Bool::New() const { - return new Bool; -} - -void Bool::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - data_ = false; - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool Bool::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // required bool data = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &data_))); - set_has_data(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void Bool::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // required bool data = 1; - if (has_data()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->data(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* Bool::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // required bool data = 1; - if (has_data()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->data(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int Bool::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // required bool data = 1; - if (has_data()) { - total_size += 1 + 1; - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void Bool::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const Bool* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == nullptr) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void Bool::MergeFrom(const Bool& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_data()) { - set_data(from.data()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void Bool::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void Bool::CopyFrom(const Bool& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Bool::IsInitialized() const { - if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false; - - return true; -} - -void Bool::Swap(Bool* other) { - if (other != this) { - std::swap(data_, other->data_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata Bool::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Bool_descriptor_; - metadata.reflection = Bool_reflection_; - return metadata; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace msgs -} // namespace gazebo - -// @@protoc_insertion_point(global_scope) diff --git a/wpilibc/wpilibC++Sim/src/simulation/msgs/driver-station.pb.cpp b/wpilibc/wpilibC++Sim/src/simulation/msgs/driver-station.pb.cpp deleted file mode 100644 index 3b9f1389d5..0000000000 --- a/wpilibc/wpilibC++Sim/src/simulation/msgs/driver-station.pb.cpp +++ /dev/null @@ -1,385 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: msgs/driver-station.proto - -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "simulation/msgs/driver-station.pb.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace gazebo { -namespace msgs { - -namespace { - -const ::google::protobuf::Descriptor* DriverStation_descriptor_ = nullptr; -const ::google::protobuf::internal::GeneratedMessageReflection* - DriverStation_reflection_ = nullptr; -const ::google::protobuf::EnumDescriptor* DriverStation_State_descriptor_ = nullptr; - -} // namespace - - -void protobuf_AssignDesc_msgs_2fdriver_2dstation_2eproto() { - protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "msgs/driver-station.proto"); - GOOGLE_CHECK(file != nullptr); - DriverStation_descriptor_ = file->message_type(0); - static const int DriverStation_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DriverStation, enabled_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DriverStation, state_), - }; - DriverStation_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - DriverStation_descriptor_, - DriverStation::default_instance_, - DriverStation_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DriverStation, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DriverStation, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(DriverStation)); - DriverStation_State_descriptor_ = DriverStation_descriptor_->enum_type(0); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_msgs_2fdriver_2dstation_2eproto); -} - -void protobuf_RegisterTypes(const std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DriverStation_descriptor_, &DriverStation::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_msgs_2fdriver_2dstation_2eproto() { - delete DriverStation::default_instance_; - delete DriverStation_reflection_; -} - -void protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\031msgs/driver-station.proto\022\013gazebo.msgs" - "\"z\n\rDriverStation\022\017\n\007enabled\030\001 \002(\010\022/\n\005st" - "ate\030\002 \002(\0162 .gazebo.msgs.DriverStation.St" - "ate\"\'\n\005State\022\010\n\004AUTO\020\000\022\n\n\006TELEOP\020\001\022\010\n\004TE" - "ST\020\002B\021B\017GzDriverStation", 183); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "msgs/driver-station.proto", &protobuf_RegisterTypes); - DriverStation::default_instance_ = new DriverStation(); - DriverStation::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_msgs_2fdriver_2dstation_2eproto); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_msgs_2fdriver_2dstation_2eproto { - StaticDescriptorInitializer_msgs_2fdriver_2dstation_2eproto() { - protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto(); - } -} static_descriptor_initializer_msgs_2fdriver_2dstation_2eproto_; - -// =================================================================== - -const ::google::protobuf::EnumDescriptor* DriverStation_State_descriptor() { - protobuf_AssignDescriptorsOnce(); - return DriverStation_State_descriptor_; -} -bool DriverStation_State_IsValid(int value) { - switch(value) { - case 0: - case 1: - case 2: - return true; - default: - return false; - } -} - -#ifndef _MSC_VER -const DriverStation_State DriverStation::AUTO; -const DriverStation_State DriverStation::TELEOP; -const DriverStation_State DriverStation::TEST; -const DriverStation_State DriverStation::State_MIN; -const DriverStation_State DriverStation::State_MAX; -const int DriverStation::State_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER -const int DriverStation::kEnabledFieldNumber; -const int DriverStation::kStateFieldNumber; -#endif // !_MSC_VER - -DriverStation::DriverStation() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void DriverStation::InitAsDefaultInstance() { -} - -DriverStation::DriverStation(const DriverStation& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void DriverStation::SharedCtor() { - _cached_size_ = 0; - enabled_ = false; - state_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -DriverStation::~DriverStation() { - SharedDtor(); -} - -void DriverStation::SharedDtor() { - if (this != default_instance_) { - } -} - -void DriverStation::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* DriverStation::descriptor() { - protobuf_AssignDescriptorsOnce(); - return DriverStation_descriptor_; -} - -const DriverStation& DriverStation::default_instance() { - if (default_instance_ == nullptr) protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto(); - return *default_instance_; -} - -DriverStation* DriverStation::default_instance_ = nullptr; - -DriverStation* DriverStation::New() const { - return new DriverStation; -} - -void DriverStation::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - enabled_ = false; - state_ = 0; - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool DriverStation::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // required bool enabled = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &enabled_))); - set_has_enabled(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(16)) goto parse_state; - break; - } - - // required .gazebo.msgs.DriverStation.State state = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_state: - int value; - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( - input, &value))); - if (::gazebo::msgs::DriverStation_State_IsValid(value)) { - set_state(static_cast< ::gazebo::msgs::DriverStation_State >(value)); - } else { - mutable_unknown_fields()->AddVarint(2, value); - } - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void DriverStation::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // required bool enabled = 1; - if (has_enabled()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->enabled(), output); - } - - // required .gazebo.msgs.DriverStation.State state = 2; - if (has_state()) { - ::google::protobuf::internal::WireFormatLite::WriteEnum( - 2, this->state(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* DriverStation::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // required bool enabled = 1; - if (has_enabled()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->enabled(), target); - } - - // required .gazebo.msgs.DriverStation.State state = 2; - if (has_state()) { - target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 2, this->state(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int DriverStation::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // required bool enabled = 1; - if (has_enabled()) { - total_size += 1 + 1; - } - - // required .gazebo.msgs.DriverStation.State state = 2; - if (has_state()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->state()); - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void DriverStation::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const DriverStation* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == nullptr) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void DriverStation::MergeFrom(const DriverStation& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_enabled()) { - set_enabled(from.enabled()); - } - if (from.has_state()) { - set_state(from.state()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void DriverStation::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void DriverStation::CopyFrom(const DriverStation& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool DriverStation::IsInitialized() const { - if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false; - - return true; -} - -void DriverStation::Swap(DriverStation* other) { - if (other != this) { - std::swap(enabled_, other->enabled_); - std::swap(state_, other->state_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata DriverStation::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = DriverStation_descriptor_; - metadata.reflection = DriverStation_reflection_; - return metadata; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace msgs -} // namespace gazebo - -// @@protoc_insertion_point(global_scope) diff --git a/wpilibc/wpilibC++Sim/src/simulation/msgs/float64.pb.cpp b/wpilibc/wpilibC++Sim/src/simulation/msgs/float64.pb.cpp deleted file mode 100644 index 2f2c94d104..0000000000 --- a/wpilibc/wpilibC++Sim/src/simulation/msgs/float64.pb.cpp +++ /dev/null @@ -1,310 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: msgs/float64.proto - -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "simulation/msgs/float64.pb.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace gazebo { -namespace msgs { - -namespace { - -const ::google::protobuf::Descriptor* Float64_descriptor_ = nullptr; -const ::google::protobuf::internal::GeneratedMessageReflection* - Float64_reflection_ = nullptr; - -} // namespace - - -void protobuf_AssignDesc_msgs_2ffloat64_2eproto() { - protobuf_AddDesc_msgs_2ffloat64_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "msgs/float64.proto"); - GOOGLE_CHECK(file != nullptr); - Float64_descriptor_ = file->message_type(0); - static const int Float64_offsets_[1] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Float64, data_), - }; - Float64_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - Float64_descriptor_, - Float64::default_instance_, - Float64_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Float64, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Float64, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(Float64)); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_msgs_2ffloat64_2eproto); -} - -void protobuf_RegisterTypes(const std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Float64_descriptor_, &Float64::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_msgs_2ffloat64_2eproto() { - delete Float64::default_instance_; - delete Float64_reflection_; -} - -void protobuf_AddDesc_msgs_2ffloat64_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\022msgs/float64.proto\022\013gazebo.msgs\"\027\n\007Flo" - "at64\022\014\n\004data\030\001 \002(\001B\013B\tGzFloat64", 71); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "msgs/float64.proto", &protobuf_RegisterTypes); - Float64::default_instance_ = new Float64(); - Float64::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_msgs_2ffloat64_2eproto); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_msgs_2ffloat64_2eproto { - StaticDescriptorInitializer_msgs_2ffloat64_2eproto() { - protobuf_AddDesc_msgs_2ffloat64_2eproto(); - } -} static_descriptor_initializer_msgs_2ffloat64_2eproto_; - -// =================================================================== - -#ifndef _MSC_VER -const int Float64::kDataFieldNumber; -#endif // !_MSC_VER - -Float64::Float64() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void Float64::InitAsDefaultInstance() { -} - -Float64::Float64(const Float64& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void Float64::SharedCtor() { - _cached_size_ = 0; - data_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -Float64::~Float64() { - SharedDtor(); -} - -void Float64::SharedDtor() { - if (this != default_instance_) { - } -} - -void Float64::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* Float64::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Float64_descriptor_; -} - -const Float64& Float64::default_instance() { - if (default_instance_ == nullptr) protobuf_AddDesc_msgs_2ffloat64_2eproto(); - return *default_instance_; -} - -Float64* Float64::default_instance_ = nullptr; - -Float64* Float64::New() const { - return new Float64; -} - -void Float64::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - data_ = 0; - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool Float64::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // required double data = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED64) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( - input, &data_))); - set_has_data(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void Float64::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // required double data = 1; - if (has_data()) { - ::google::protobuf::internal::WireFormatLite::WriteDouble(1, this->data(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* Float64::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // required double data = 1; - if (has_data()) { - target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(1, this->data(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int Float64::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // required double data = 1; - if (has_data()) { - total_size += 1 + 8; - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void Float64::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const Float64* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == nullptr) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void Float64::MergeFrom(const Float64& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_data()) { - set_data(from.data()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void Float64::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void Float64::CopyFrom(const Float64& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Float64::IsInitialized() const { - if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false; - - return true; -} - -void Float64::Swap(Float64* other) { - if (other != this) { - std::swap(data_, other->data_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata Float64::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Float64_descriptor_; - metadata.reflection = Float64_reflection_; - return metadata; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace msgs -} // namespace gazebo - -// @@protoc_insertion_point(global_scope) diff --git a/wpilibc/wpilibC++Sim/src/simulation/msgs/joystick.pb.cpp b/wpilibc/wpilibC++Sim/src/simulation/msgs/joystick.pb.cpp deleted file mode 100644 index 306e2471bb..0000000000 --- a/wpilibc/wpilibC++Sim/src/simulation/msgs/joystick.pb.cpp +++ /dev/null @@ -1,358 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: msgs/joystick.proto - -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "simulation/msgs/joystick.pb.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace gazebo { -namespace msgs { - -namespace { - -const ::google::protobuf::Descriptor* Joystick_descriptor_ = nullptr; -const ::google::protobuf::internal::GeneratedMessageReflection* - Joystick_reflection_ = nullptr; - -} // namespace - - -void protobuf_AssignDesc_msgs_2fjoystick_2eproto() { - protobuf_AddDesc_msgs_2fjoystick_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "msgs/joystick.proto"); - GOOGLE_CHECK(file != nullptr); - Joystick_descriptor_ = file->message_type(0); - static const int Joystick_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Joystick, axes_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Joystick, buttons_), - }; - Joystick_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - Joystick_descriptor_, - Joystick::default_instance_, - Joystick_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Joystick, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Joystick, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(Joystick)); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_msgs_2fjoystick_2eproto); -} - -void protobuf_RegisterTypes(const std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Joystick_descriptor_, &Joystick::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_msgs_2fjoystick_2eproto() { - delete Joystick::default_instance_; - delete Joystick_reflection_; -} - -void protobuf_AddDesc_msgs_2fjoystick_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\023msgs/joystick.proto\022\013gazebo.msgs\")\n\010Jo" - "ystick\022\014\n\004axes\030\001 \003(\001\022\017\n\007buttons\030\002 \003(\010B\014B" - "\nGzJoystick", 91); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "msgs/joystick.proto", &protobuf_RegisterTypes); - Joystick::default_instance_ = new Joystick(); - Joystick::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_msgs_2fjoystick_2eproto); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_msgs_2fjoystick_2eproto { - StaticDescriptorInitializer_msgs_2fjoystick_2eproto() { - protobuf_AddDesc_msgs_2fjoystick_2eproto(); - } -} static_descriptor_initializer_msgs_2fjoystick_2eproto_; - -// =================================================================== - -#ifndef _MSC_VER -const int Joystick::kAxesFieldNumber; -const int Joystick::kButtonsFieldNumber; -#endif // !_MSC_VER - -Joystick::Joystick() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void Joystick::InitAsDefaultInstance() { -} - -Joystick::Joystick(const Joystick& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void Joystick::SharedCtor() { - _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -Joystick::~Joystick() { - SharedDtor(); -} - -void Joystick::SharedDtor() { - if (this != default_instance_) { - } -} - -void Joystick::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* Joystick::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Joystick_descriptor_; -} - -const Joystick& Joystick::default_instance() { - if (default_instance_ == nullptr) protobuf_AddDesc_msgs_2fjoystick_2eproto(); - return *default_instance_; -} - -Joystick* Joystick::default_instance_ = nullptr; - -Joystick* Joystick::New() const { - return new Joystick; -} - -void Joystick::Clear() { - axes_.Clear(); - buttons_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool Joystick::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // repeated double axes = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED64) { - parse_axes: - DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< - double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( - 1, 9, input, this->mutable_axes()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< - double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( - input, this->mutable_axes()))); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(9)) goto parse_axes; - if (input->ExpectTag(16)) goto parse_buttons; - break; - } - - // repeated bool buttons = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_buttons: - DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - 1, 16, input, this->mutable_buttons()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, this->mutable_buttons()))); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(16)) goto parse_buttons; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void Joystick::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // repeated double axes = 1; - for (int i = 0; i < this->axes_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteDouble( - 1, this->axes(i), output); - } - - // repeated bool buttons = 2; - for (int i = 0; i < this->buttons_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteBool( - 2, this->buttons(i), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* Joystick::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // repeated double axes = 1; - for (int i = 0; i < this->axes_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteDoubleToArray(1, this->axes(i), target); - } - - // repeated bool buttons = 2; - for (int i = 0; i < this->buttons_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteBoolToArray(2, this->buttons(i), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int Joystick::ByteSize() const { - int total_size = 0; - - // repeated double axes = 1; - { - int data_size = 0; - data_size = 8 * this->axes_size(); - total_size += 1 * this->axes_size() + data_size; - } - - // repeated bool buttons = 2; - { - int data_size = 0; - data_size = 1 * this->buttons_size(); - total_size += 1 * this->buttons_size() + data_size; - } - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void Joystick::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const Joystick* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == nullptr) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void Joystick::MergeFrom(const Joystick& from) { - GOOGLE_CHECK_NE(&from, this); - axes_.MergeFrom(from.axes_); - buttons_.MergeFrom(from.buttons_); - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void Joystick::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void Joystick::CopyFrom(const Joystick& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Joystick::IsInitialized() const { - - return true; -} - -void Joystick::Swap(Joystick* other) { - if (other != this) { - axes_.Swap(&other->axes_); - buttons_.Swap(&other->buttons_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata Joystick::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Joystick_descriptor_; - metadata.reflection = Joystick_reflection_; - return metadata; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace msgs -} // namespace gazebo - -// @@protoc_insertion_point(global_scope) diff --git a/wpilibj/wpilibJavaSim/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java b/wpilibj/wpilibJavaSim/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java index a039304462..96983723e6 100644 --- a/wpilibj/wpilibJavaSim/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java +++ b/wpilibj/wpilibJavaSim/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java @@ -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(); diff --git a/wpilibj/wpilibJavaSim/src/main/java/edu/wpi/first/wpilibj/RobotBase.java b/wpilibj/wpilibJavaSim/src/main/java/edu/wpi/first/wpilibj/RobotBase.java index c54fc53602..633341fc12 100644 --- a/wpilibj/wpilibJavaSim/src/main/java/edu/wpi/first/wpilibj/RobotBase.java +++ b/wpilibj/wpilibJavaSim/src/main/java/edu/wpi/first/wpilibj/RobotBase.java @@ -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();} } diff --git a/wpilibj/wpilibJavaSim/src/main/java/edu/wpi/first/wpilibj/Servo.java b/wpilibj/wpilibJavaSim/src/main/java/edu/wpi/first/wpilibj/Servo.java new file mode 100644 index 0000000000..7db4467682 --- /dev/null +++ b/wpilibj/wpilibJavaSim/src/main/java/edu/wpi/first/wpilibj/Servo.java @@ -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.
+ * + * By default {@value #kDefaultMaxServoPWM} ms is used as the maxPWM value
+ * By default {@value #kDefaultMinServoPWM} ms is used as the minPWM value
+ * + * @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); + } +}