Commit Graph

169 Commits

Author SHA1 Message Date
Tyler Veness
055ee09825 Fixed current and potential bugs caught by Coverity
Change-Id: I9f9d09dc797ffea062eeb49c881be1d5acb63d7b
2015-11-28 11:08:12 -08:00
Joe Ross
906fe65e39 Optimize Solenoid Gets. Fixes artf4730.
Implement GetAllSolenoids in the HAL so that SolenoidBase doesn't have to
read each solenoid individually.

Change-Id: I85559565949f7a7119ead410187235636a63f0ed
2015-11-28 03:29:03 -08:00
Thad House
2f2184e8ce Makes HALSetDataSem take a MULTIWAIT_ID rather then a NATIVE_MULTIWAIT_ID
Having the HAL take a NATIVE_MULTIWAIT_ID without any way to get that
structure from extern "C" code is a problem. This makes it so it just
takes a MULTIWAIT_ID, and then grabs the native handle inside the HAL.

Change-Id: I06da18ba34adcea2f16e4e53da672f38be79e28e
Signed-off-by: Dustin Spicuzza <dustin@virtualroadside.com>
2015-11-27 22:33:28 -08:00
Thad House
de39877efb artf4153 Adds HAL structure memory management
In the current HAL, once the port structures were created, there was no
way to free the structures. The way the C++ libraries were written this
wasn't a problem, since it grabbed a copy of each and stored them in an
array on bootup. However java does not do this, and grabs new ports
every time an object is created. This causes memory leaks if an object
is ever disposed in java. The same thing looks to be happening in
python, and C# does it too currently, but that would change if this gets
merged.

Adds java memory management fixes

Adds memory management to AnalogInput and Analog Output C++

SolenoidPorts and Digital Ports are all hold static arrays with their
port pointers (although solenoid overwrites them if a new solenoid on
the same module is created), however analog always grabbed new pointers.
I would fix the solenoid one, but I don't know what the ideal way to do
it would be.

Silently ignores free(null) calls by checking passed parameter is non-null.

Change-Id: Id32993b57b53f896e46e55c97541d3bd90b52648
2015-11-27 22:02:02 -08:00
Peter Johnson
e162e4d1c0 Merge "Fix HALGetJoystickAxisType() definition to match header." 2015-11-27 21:08:49 -08:00
Thad House
66b28e95a7 Adds new CanTalon HAL Functions to C library
New functions were added to CanTalonSRX in the HAL, however they were
not added to the C side of the library.

Change-Id: I15197e5dce5db0f5ff207d1318c21be485c90741
2015-11-26 02:21:33 -08:00
Peter Johnson
f36e36424f Fix HALGetJoystickAxisType() definition to match header.
Change-Id: Ie68546930dd1cd07d39f8796f855e8ee26ccd317
2015-11-26 00:03:55 -08:00
Brad Miller (WPI)
ad64c0b025 Merge "spiSetBitsPerWord doesn't exist; remove from headers." 2015-11-25 06:09:03 -08:00
Peter Johnson
964b243619 Make PDP parameters consistent with other HAL functions.
All other HAL functions have status as the last parameter, only PDP did not.
This changes makes the PDP parameter order consistent with the rest of the HAL.

Change-Id: I725e33f75deab34e6a83b7048b2d6c365fa56a21
2015-11-23 23:31:57 -08:00
Peter Johnson
51a35daed7 spiSetBitsPerWord doesn't exist; remove from headers.
Change-Id: I4899ec92a5198199699e7d840c9e0801cccdb861
2015-11-23 23:01:55 -08:00
Fredric Silberberg
6d854afb0e WPILib Reorganization
This is a major restructuring of the WPILib repository to simply build
procedures and remove the remnants of Maven from everything except the
eclipse plugins. Gradle files have been largely simplified or rewritten,
taking advantage of splitting up parts of the build into separate build
files for ease of reading.

The eclipse plugins are now in a separate project, as is ntcore. All
dependencies are resolved via Maven dependencies, with the
Jenkins-maintained WPILib repo. Project structures have also been
simplified: we no longer have separate subprojects inside wpilibc and
wpilibj. Where possible, these changes hav been done with git renames,
to make sure we still have full history for all repositories. Other
unrelated subprojects have also been broken out: OutlineViewer is now a
separate project.

Change-Id: Ib4e2a6e1a2f66427a14f16612b0e0d69ed661878
2015-11-21 18:26:49 -05:00
Colby Skeggs
d690974ad0 Improved error handling in HAL Digital and Solenoid systems.
Change-Id: Iafd68c5bd143e9ee87ecf714bccb2c77e599b649
2015-11-15 20:59:35 -08:00
Tyler Veness
231178c26a HALUsageReporting::kFramework_Simple was renamed to match the corresponding robot framework's name
Change-Id: I2ad0f8d48cabe5f6c1adf622cf5377eb5be362f7
2015-11-02 23:23:57 -08:00
Omar Zrien
a0cc45a8f0 Format and style changes.
Rebuilt last SRX-related commit with latest checkout.

Change-Id: I9f10418580275dae5cd07d740d401d45ee44e276

C++: Added Magnetic Encoder sensor types
C++: API for changing status frame rates updated to use paramEnums.
C++: Added Setting nominal and peak outputs for closed loop modes.
C++: Added current-closed loop
C++: added vcomp mode
C++: Added unit scaling (rotations and rpm)
C++ Added allowableclosedlooperr
C++: Added auto zero position on index pin
C++: Added pulse width decoder API
C++: Added multiplicands in status frames, increasing the max reported pos and max rpm.
C++: Added SetClosedLoopOutputDirection() for reversing slave output and reversing single-direction closed loopoutput.
C++: Added generic ConfigSet and ConfigGet for future flexibility/features.
C++: Added IsSensorPresent
Java: Added Magnetic Encoder sensor types
Java: Added unit scaling (rotations and rpm)
Java: Added current-closed loop
Java: added vcomp mode
Java Added allowableclosedlooperr
Java: Added auto zero position on index pin
Java: Added pulse width decoder API
Java: setForwardSoftLimit and setReverseSoftLimit takes double instead of int so underneath we can support rotations instead of native units.
Java: Added generic SetParam and GetParam for future flexibility/features.
Java Added isSensorPresent

Change-Id: I800251510e411624dce5ee10272606c31764b8ab
2015-10-16 11:27:57 -07:00
Tyler Veness
c0ecde302f Replaced instances of std::unique_lock with std::lock_guard where possible
If a lock is used with a mutex that doesn't need to be unlocked again before the lock is destroyed, std::lock_guard can be more efficient than std::unique_lock due to less overhead.

This commit also removes a redundant set of curly braces in PIDController.cpp intended to constrain a lock's scope.

Change-Id: Idd692ce439528ddb319a4c62c40c7351a664eb97
2015-10-04 13:20:11 -07:00
Patrick Plenefisch
9f859234fb Update for latest image, not sure about ctre folder so leaving
Change-Id: If2218df082bca93d25b88088696d6c2897732efd

Adding FRC Local new mdns name

Change-Id: I53d206879663b96009ba3a12de161b7a425ffd10

Adding rpath for new libstdc++

Change-Id: I0c022efb0b15f094d153b44f60215ca00d5f1924
2015-09-30 06:03:56 -07:00
Peter Johnson
89ae8f214e Initialize status in HALInitialize.
Change-Id: If6230f949ba0dc1061186b1877aaf34a4dd8a987
tGlobal::create() expects the incoming status to be 0.
2015-09-29 23:27:25 -07:00
jmanning
c21c47f546 artf4000
A fix contributed by James Ward to fix the restriction on the read/write sizes in I2C.

Change-Id: Iddc48dc55ff9cea37d8dcfaba5e63f0d14e4c7d0
2015-09-19 15:24:07 -07:00
Tyler Veness (3512)
5d1ab0e820 Merge "Unbreak cmake build." 2015-09-01 20:38:49 -07:00
peter mitrano
4514e4489a refactored HAL library
builds two libraries, Athena  and Desktop.
Simulation should use Desktop, Robots should use Athena

Also:
 - copied Driverstation and Joystick from Devices into Sim
 - Descreased dependency of pthreads in JNI.
 - removed Simulation ifdef from non simulation
 - added missing decprecated attribute for msvc
 - removed usage reporting from sim
 - removed unused pom.xml and constexpr

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

Change-Id: Ia702ff0f1fee10d77f543810ad88f56696443b05
2015-08-18 10:39:25 -04:00
Peter Johnson
738881099f Unbreak cmake build.
Several ctre headers were in source directories but were required by other
headers in include directories.  This worked in gradle but not in cmake.

Change-Id: I806c76031b396d1694a18b8e30c705e92f617a66
2015-08-14 08:01:59 -07:00
James Kuszmaul
b5695581c3 artf4170: Make CANTalon disable on destruction.
This both disables the CANTalon in the CANTalon class (which
should be redundant) and stops sending control signals in the
CanTalonSRX hal class.

Change-Id: I63d6a9d016c221e385d5d5a3679d854882ac6650
2015-08-13 11:42:30 -07:00
Tyler Veness
918cde0c0f artf4155: Move Port.h from hal/lib/Athena to hal/include/HAL
Change-Id: I76a8d8baf4d77b7383c321d16a9286537632c3e9
2015-07-30 08:54:02 -07:00
peter mitrano
43f16510fa moved ctre includes from C++Devices into Hal
Change-Id: I0d0460516b5e26345faa321ed6e24d80eba65358
2015-07-30 07:57:14 -07:00
James Kuszmaul
4b575e3e7e Replaced ::std with std for readability/consistency.
Change-Id: I65f9673c237d3513f99827e28963eb22ae9df0c2
2015-07-29 16:48:04 -04:00
James Kuszmaul
534ea134a4 artf4154: Get rid of raw pointers in C++.
This deals with the majority of the user-facing code
in wpilibC++Devices and a substantial portion of it in
wpilibC++. wpilibC++Sim and wpilibC++IntegrationTests
are untouched except where it is necessary to make them
work with the rest of the libraries.

There is still a lot to do in the following areas:
-The HAL (which we may not want to touch at all).
-The I2C, Serial, and SPI interfaces in wpilibC++Devices,
  which I haven't gotten around to doing yet.
-Most wpilibC++Devices classes have void* pointers
  for interacting with the HAL.
-InterruptableSensorBase passes a void *params for
  the interrupt handler.
-I haven't converted all the const char* to std::strings.
-There are plenty of other cases of raw pointers still
  existing.
-This doesn't fall directly under raw pointer stuff,
  but move syntax and rvalue references could be introduced
  in many places.
-I haven't touched vision code.
-The Resource classes conflict (one is in the hal, the other
  in wpilibC++). Someone should figure out a more
  permanent fix (eg, just renaming them), then doing
  what I did (making a new namespace for one of them,
  essentially the same as renaming it).

A few other things:
-I created a NullDeleter class which is marked as deprecated.
  What this does is it can be passed as the deleter to a
  std::shared_ptr so that when you are converting raw pointers
  to shared_ptrs the shared_ptr doesn't do any deletion if
  someone else owns the raw pointer. This should only be
  used in making old raw pointer UIs.
-I had to alter the build.gradle so that it did not
  emit errors when deprecated functions called deprecated
  functions. Unfortunately, gradle doesn't appear to be
  actually printing out gcc warnigns for some reason.
  The best way I have found to fix this is to patch
  the toolchains (https://bitbucket.org/byteit101/toolchain-builder/pull-request/5/make-gcc-not-throw-warnings-for-nested/diff)
  so that a deprecated function calling a deprecated
  function is fine but a non-deprecated function calling
  a deprecated function will throw a warning (which we
  then elevate with -Werror). I believe that clang
  deals with this properly, although I have not
  tried it myself.

Change-Id: Ib8090c66893576fe73654f4e9d268f9d37be06a2
2015-07-20 13:18:29 -04:00
Tyler Veness
fd4c169658 artf4149: Removed references to VxWorks
Implemented setTaskPriority() and getTaskPriority() in Task HAL API

Removed all other unimplemented functions in HAL and removed spawnTask()

Replaced instances of pthread_t* with TASK typedef

Removed unused HAL error constants and removed commented-out classes and functions in wpilibj's HALLibrary

Changed Task class API to match the construction semantics of a std::thread

Change-Id: I3bc951a3da90d24c5589fae4d1ca2bb60225c873
2015-07-20 11:49:29 -04:00
James Kuszmaul
5712565068 Removed dependencies on pthread from frcsim.
Because we want to be able to compile/run wpilibC++Sim on
windows, we would prefer not to require a windows version
of pthread. This commit moves from pthread constructs to
standard library constructs.

Change-Id: I12392a8910189537dd067afdf017e4994d570a66
2015-07-20 07:06:57 -07:00
Tyler Veness
3f59f3472a artf4156: Replaced synchronization primitives with C++11 equivalents
Change-Id: I90da739347e875efda2a29dd5484b6dda3cd4753
2015-07-20 10:06:08 -04:00
Tyler Veness
045a9b32db DISALLOW_COPY_AND_ASSIGN macro now uses the delete keyword and allows move assignment and construction
Change-Id: Ibb19cdb4343e0d7ddaa073cff5373ec24f24a2d3
2015-07-02 21:41:27 -07:00
James Kuszmaul
35ccbb9c90 Fixed bad initialization of PDP.
Change-Id: I4603c7d51cfb8962d012aff0b6a1dac2e7525e40
2015-06-29 15:17:03 -04:00
jmanning
39130721d0 Artifact artf3528, Added support for PDP's having addresses other than zero, and added ability to have multiple PDP's.
Change-Id: I8e36ab47d6f60b99a668965396c25856cc07a0cb
2015-06-24 08:13:39 -07:00
jmanning
bf4ccf13d9 Added functions to get names, HID types and isXbox descriptors from joysticks.
Change-Id: I3cd6ebc04d64398f05001cd008696e13ee1ab6ea
2015-06-24 10:56:59 -04:00
Brian Silverman
4cac5a957b add some comments etc documenting various not-implemented things
Change-Id: I1103b65006e8330260bfe1202bdb64eb84d3fccc
2015-06-03 11:27:35 -04:00
Brad Miller (WPI)
d1d28e70e1 Merge "This commit adds JNI bindings for the C++ Notifier." 2015-06-03 06:02:03 -07:00
James Kuszmaul
0b7bb41b22 This commit adds JNI bindings for the C++ Notifier.
The bindings only wrap the HAL interface, rather than the entire C++ Notifier,
as I ran into issues trying to wrap the whole Notifier (all the existing
bindings only wrap HAL components, so wrapping stuff in :wpilibc is
unexplored). As such, the new edu.wpi.first.wpilibj.Notifier is just a
re-implementation of the wpilibc/.../Notifier.cpp.

The purpose of doing this bindings is to allow Java users a better option
for running tasks which require good timing (such as control loops). The
previous method used java.util.Timer to schedule a task, causing various
issues. Although this update does improve things, Java loop timing is still
substantially worse than that of C++, and, even worse, if Java decides to call
the garbage collector at the wrong time then the loop can be delayed by
multiple milliseconds and the next iteration will be shorter to account for it
(although this particular behavior could be updated).

A few notes on individual components:
-the HAL Task.hpp and Task.cpp were modified due to compilation/linkage
 issues with the JNI bindings. Nothing substantive changed.
-NotifierJNI was added to the build files for gradle.
-HALUtil was modified to include a function for getting the length of a C
 pointer, rather than relying on it being 32-bit.

Change-Id: I966512d8a82c2a438ed8c8bbcc6cdc6ed186d0f2
2015-06-02 16:05:03 -04:00
Kevin O'Connor
8b71ddc30f Fix usage reporting for new motor controllers and Analog output
Change-Id: I574e431ae551ecf8efc90c004abf14568f22c068
2015-06-02 09:46:09 -04:00
Fredric Silberberg
1e4e0bacde Gradle Build
This adds gradle support for building wpilibj and wpilibc. At this
point, both of these libraries should be fully ready to go.

Gradle should give us a number of improvements, including less
dependencies for getting building up and running, and MUCH faster build
times. I'm noticing significantly faster build times already compared to
Maven, with neither system building the plugins. The changes here should
be pretty straight forward. The basic command for gradle is './gradlew'.
This is the gradle wrapper, and it will find and download the correct
gradle executable for your system. There is no need to install anything
yourself. To see every task available, run './gradlew tasks'. The
important tasks for us are listed under the WPILib header when the tasks
command is run. To generate unit test binaries, the
fRCUserProgramExecutable command will create the C++ tester, and the
wpilibjIntegrationTestJar command will create the Java tester. The Jenkins
deploy scripts have been modified to know the difference between maven
generated and gradle generated jars with an environment variable. Creating
the eclipse plugins still requires Maven, but gradle will handle calling
it correctly and generating the proper dependencies for it. Create the
plugins by calling ./gradlew eclipsePlugins.

Jenkins can now be modified to support the new build system. Unit tests
are run with ./gradlew test. Generating the integration tests uses the
above two commands, and then process proceeds exactly as it did before.
For publishing documentation, a new task has been created, ./gradlew
publishDocs, which handles putting the documentation where Jenkins expects
for publishing.

Change-Id: I9a260d391984f98ef9170993efe933e4026161dc
2015-05-20 16:22:17 -04:00
Joe Ross
7bdd91a058 Use PCM Device ID when getting status. Fixes artf4014.
Change-Id: I0e1f478d1b96d20b97dec8d0ffe251c8fd0f6897
2015-02-15 16:43:09 -08:00
Brad Miller
215002e487 Fix analog trigger bug with MXP mapping (artf4010)
Add the interrupt code for MXP mapping and analog triggers
Took out the unneeded static definition
Change-Id: I9a3483ee8f806b46b4349845e7a189f497c36916
2015-02-12 17:33:31 -05:00
Joe Ross
9f057fddfd Correct energy to be in Joules rather then millijoules. Fixes artf3940
Note: power and thus energy will still be wrong until PDP firmware 1.39
or later is used. See artf3939.
Change-Id: Ic68b8a28c78f1b5d524fa5fb45e3bc0d9cd4a76a
2015-01-17 09:59:25 -08:00
Thomas Clark
a2dfffeddc Add encoder indexing support in C++
Java will be done tonight or tomorrow

Change-Id: I3a3287a197b6f071c261172eb8ec930693e8b3c7
2015-01-07 00:06:45 -05:00
Omar Zrien
548941dd99 Artifact artf3925 : PCM : Can't find any user facing java/C++ API for getting/clearing PCM faults
Change-Id: If5cb5b08f685158c5317233c4d9bc8e688138df7
2014-12-26 19:40:39 -05:00
Brad Miller
a55f34646d Encoder/Counter Fixes
This fixes all encoder variants with the getRate and getPeriod methods.
The clock speed in the HAL was updated, as was the scaling factors for setting
the stall periods. A default of .5 seconds is now set for the max period.
Additionally, a long standing bug was fixed with Java 2x encoders.

Changed tests to take into account the increased default timeout on encoders

Change-Id: I8b54c07ea467154be94d7ae7e9ada1775933dee4
2014-12-23 20:13:41 -05:00
Brad Miller (WPI)
b4097fbd58 Merge "ClearStickyFaults() should not take a param, just clears sticky flags in a one shot manner. GetCompressorFault() => GetCompressorCurrentTooHighFault() There are now three compressor related faults so getters needed to be more verbose. New getters()... GetCompressorCurrentTooHighStickyFault GetCompressorShortedStickyFault GetCompressorShortedFault GetCompressorNotConnectedStickyFault GetCompressorNotConnectedFault" 2014-12-22 09:20:31 -08:00
Peter Johnson
9ffdea188b Add C interface for CanTalonSRX::SetModeSelect(modeSelect, demand).
Change-Id: Ic8305ec283ddb89afc60d6bc5226411b1f8cc18b
2014-12-20 12:46:05 -08:00
Omar Zrien
96a76ba89e Single line bug in CanTalonSRX::GetAnalogInVel(). return value was not being sign-extended.
Change-Id: I44271726ece9aaa7b94f35e611f24a18dbb53825
2014-12-19 03:27:29 -05:00
Omar Zrien
a5d9ba412c Second pass through all the HAL functions and cpp/java API. Filled in some parity holes between java and cpp.
Java...
added setStatusFrameRateMs() to modify the frame rate for status frames
added missing func that already exists in c++
	isFwdLimitSwitchClosed()
	isRevLimitSwitchClosed()
	getNumberOfQuadIdxRises()
	getPinStateQuadA()
	getPinStateQuadB()
	getPinStateQuadIdx()
added getAnalogInRaw() that doesn't count overflows (for potentiometers).
added setStatusFrameRateMs() to modify the frame rate for status frames
added getBrakeEnableDuringNeutral()

C++...
added GetAnalogInRaw() that doesn't count overflows (for potentiometers).
added SetStatusFrameRateMs() to modify the frame rate for status frames
added GetBrakeEnableDuringNeutral()
added kLimitMode_SrxDisableSwitchInputs to CANSpeedController::LimitMode

Patch set 2: Joe Ross, fixed two javadoc errors

Change-Id: I0bf871e138953de60eeacb547dc359f2125b1327
2014-12-18 15:51:47 -05:00
Omar Zrien
198e2eed14 ClearStickyFaults() should not take a param, just clears sticky flags in a one shot manner.
GetCompressorFault() => GetCompressorCurrentTooHighFault()
	There are now three compressor related faults so getters needed to be more verbose.
New getters()...
	GetCompressorCurrentTooHighStickyFault
	GetCompressorShortedStickyFault
	GetCompressorShortedFault
	GetCompressorNotConnectedStickyFault
	GetCompressorNotConnectedFault

Fire and forget api added. Likely not used any time soon, BUT having it ready in HAL is harmless.
	FireOneShotSolenoid()
	SetOneShotDurationMs()

Solenoid fuse and compressor current too high fault bits were flipped in decoder

Change-Id: Ib47dddddd8e4cc22149de1b583968d99919b00af
2014-12-17 15:05:46 -05:00