Compare commits

...

84 Commits

Author SHA1 Message Date
Brad Miller (WPI)
359a155915 Merge "Make 3 axis Accelerometers work in LiveWindow. Fixes artf3902." 2014-12-30 21:05:26 -08:00
Brad Miller
fb7f5e9de8 Add methods to retreive the FPGA index for counters and encoders and return the encoding type as an integer
Change-Id: Iaa4062ec124b968b27e7c812cc754032fcb354d2

Add methods to retrieve the FPGA index for counters and encoders and return the encoding type as an integer

Change-Id: If04dc291f39a9b331495d2b97a8b87d3ded71280
2014-12-30 23:23:04 -05:00
Joe Ross
7db63055f6 Make 3 axis Accelerometers work in LiveWindow. Fixes artf3902.
Change-Id: Iced12b3c408b0d7b8fe822a9f17a7992293bae7d
2014-12-30 19:59:25 -08:00
Thomas Clark (WPI)
b94341a23e Merge "Update nivision JNI generator to correctly gen Priv_ReadJPEGString_C." 2014-12-30 14:18:00 -08:00
Peter Johnson
afbd70d393 Update nivision JNI generator to correctly gen Priv_ReadJPEGString_C.
Change-Id: I206da9f3f660b4d567a3b535702b70e5f967b071
2014-12-30 13:24:30 -08:00
Joe Ross
ceccd95084 Add PDP to LiveWindow for C++
Change-Id: I45967739b81090e809b9e8f1c31ad7ff58554ec1
2014-12-30 12:31:35 -08:00
Brad Miller (WPI)
91b9812482 Merge "Add PDP LiveWindow code" 2014-12-30 11:57:28 -08:00
Brad Miller
0dbc40e515 Added missing .java file
Change-Id: I96aa235960bc59f435b7b1b55a29462f8f8052e4
2014-12-30 14:35:06 -05:00
Brad Miller
5ce89b3382 Added a Java AxisCamera sample program
Change-Id: Iba0eb9f06a91f577323cefd695f8dd601a96db97
2014-12-30 10:27:20 -05:00
Thomas Clark
8ccf3d9c14 Add AxisCamera Java class
The API is basically the same as the C++ one.

The JNI function for Priv_ReadJPEGString_C was manually renamed, since the
python scripts don't name the C++ functions correctly, causing an
UnsatisfiedLinkError at runtime. If further changes are made to the bindings,
either the method will have to be manually renamed again after the code is
regenerated, or the python scripts will have to be updated.

The old ignored edu.wpi.first.wpilibj.camera package was removed.

Change-Id: Icd37fc15c7bb41061568c3b2f580c6765cbf0300
2014-12-30 02:17:03 -05:00
Joe Ross
230fa2d168 Add PDP LiveWindow code
Change-Id: Ia3f4d8118d9068d021994fd2e5aca676d7dfa979
2014-12-29 21:10:21 -08:00
Joe Ross
d165f57e6e Clean up misc documentation
Change-Id: Ib0a4a7a389fb657d78d8b8bce4fcaeed67c3693d
2014-12-29 15:10:41 -08:00
Brad Miller (WPI)
2d15b6b03e Merge "Update Java install URL to the new URL with the java installer." 2014-12-29 13:38:47 -08:00
Brad Miller (WPI)
5d9baa44ee Merge changes Ie40db6c9,I0b5e752e
* changes:
  Write lib version from Java (fixes artf3788)
  Update Javadocs for Java (fixes artf3761 and artf3953)
2014-12-29 13:35:52 -08:00
Brad Miller (WPI)
822416d2f7 Merge "Write lib version from C++ (fixes artf3788)" 2014-12-29 13:35:04 -08:00
Brad Miller (WPI)
3fe726d851 Merge "Update docs for C++ (fixes artf3761 and artf3953)" 2014-12-29 13:26:13 -08:00
Kevin O'Connor
4c0b2c18ab Write lib version from Java (fixes artf3788)
Change-Id: Ie40db6c993d12aadb66b07fcfdc0a62b87a2e2ed
2014-12-29 16:06:11 -05:00
Kevin O'Connor
b4c5a3af77 Update Javadocs for Java (fixes artf3761 and artf3953)
Change-Id: I0b5e752e8f6377770163dcdc61aa79ad4c7cbe94
2014-12-29 16:02:07 -05:00
Kevin O'Connor
eddb0b20b0 Write lib version from C++ (fixes artf3788)
Change-Id: Ia11c2dab2050ffe4299d1ccd68c986573f0a05e3
2014-12-29 14:15:55 -05:00
Kevin O'Connor
6d8e782f53 Update docs for C++ (fixes artf3761 and artf3953)
Change-Id: Ic0c4ac8494cadff13461d9bb8b5943cd87619f0a
2014-12-29 14:09:37 -05:00
Joe Ross
0368322385 Update Camera templates to make C++ and Java more similar.
Include delays and template code from other examples to show how to use
these examples in a full robot program. Change Java example in example
finder to Simple Vision to match C++. Add comments about how to find cam
number and change default to cam0.

Change-Id: I85846ccfaf016c538a750b057a7fd766cdff9447
2014-12-29 13:48:11 -05:00
Joe Ross
19e05ff52b Update Java install URL to the new URL with the java installer.
Change-Id: Id554d0e2251d9efd7f06466bd2e093602911dc54
2014-12-28 20:23:48 -08:00
Brad Miller (WPI)
a6aef54ef4 Merge "Axis camera C++ example program" 2014-12-28 13:15:54 -08:00
Brad Miller
32f3bea465 Axis camera C++ example program
Change-Id: I60a14ce91fc09831b497ccdaaa7bb1bb26c8d945
2014-12-28 15:47:08 -05:00
Brad Miller (WPI)
9aacf5eb29 Merge "Artifact artf3925 : PCM : Can't find any user facing java/C++ API for getting/clearing PCM faults" 2014-12-28 10:58:12 -08:00
Thomas Clark
f3484686c9 Fix some typos in AxixCamera.cpp
There were some mistakes in comments left over from copying and pasting
comments from pre-2015 code, a couple formatting issues, and one getter
that wasn't implemented

Change-Id: I2e9d19be15445717cce175902c42e7e0932b56ad
2014-12-28 02:31:17 -05:00
Brad Miller (WPI)
b78b14bf5f Merge "Add AxisCamera C++ class" 2014-12-27 19:37:49 -08:00
Brad Miller (WPI)
c08dc98650 Merge "Add the 2014 C++ vision classes back in" 2014-12-27 19:37:29 -08:00
Brad Miller (WPI)
9fbffd88cb Merge "Change the java intermediate vision filename to match c++" 2014-12-27 18:38:11 -08:00
Brad Miller
6c15a3600a Change the java intermediate vision filename to match c++
Change-Id: Iadd173a6ea6089203103f0ca9c220a0b4ff5b286
2014-12-27 21:35:33 -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
Thomas Clark
9d8418c14e Add AxisCamera C++ class
Change-Id: I927334753027b519214d7541497f6c7f6d698163
2014-12-26 16:36:55 -05:00
Brad Miller (WPI)
326bf4fc9c Merge "Updates the InterrupatableSensorBase documentation to reflect the bug described in artf3623." 2014-12-26 13:28:20 -08:00
Fredric Silberberg
3c4a1d9a1a NIVision Forward Port
Ported the NIVision libraries from the old NIVision implementation to
the new autogenerated JNI bindings.

Change-Id: I7c68ca6abef1185d59a9787e9a269d720c825e2f
2014-12-24 16:39:46 -05:00
Fredric Silberberg
7687028269 Updates the InterrupatableSensorBase documentation to reflect the bug
described in artf3623.

Change-Id: I5f93dea65202cf30ba67c063eb8c90bedbfe43ae
2014-12-24 14:19:01 -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
Thomas Clark
53473e21be Add the 2014 C++ vision classes back in
Most of the old vision code still compiles with minimal changes. I haven't
tested it extensively, since the AxisCamera class isn't done, but it
should work, as it was barely modified.

Java bindings are still TODO, since they used some JNA stuff that probably
won't work now.

Change-Id: I8edf991410cb30b932379f277cee9d329ee35009
2014-12-23 17:42:14 -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
Brad Miller (WPI)
3b72114555 Merge "Fix imports on vision examples so they compile. Fix Typo." 2014-12-22 09:16:42 -08:00
Brad Miller (WPI)
cc36454b90 Merge "Add C interface for CanTalonSRX::SetModeSelect(modeSelect, demand)." 2014-12-22 08:45:10 -08:00
Omar Zrien
aae20ddbff Artifact artf3945 : CANTalon : Motor Safety Object never feed
Change-Id: I6894399d0eb7c36ff698639862fa6ad045a70db8
2014-12-21 16:47:03 -05:00
Joe Ross
ffd9061766 Fix imports on vision examples so they compile. Fix Typo.
Change-Id: I1d6ebf47c824fa93d8a312882cddc778f340009e
2014-12-20 20:47:09 -08:00
Peter Johnson
9ffdea188b Add C interface for CanTalonSRX::SetModeSelect(modeSelect, demand).
Change-Id: Ic8305ec283ddb89afc60d6bc5226411b1f8cc18b
2014-12-20 12:46:05 -08:00
Patrick Plenefisch
46dc99a115 Adding SFX to tools zip
Change-Id: I09a04506682a5d0ccbe8e556285de587915f7383
2014-12-19 09:52:25 -08:00
Brad Miller (WPI)
91d714d2e9 Merge "Single line bug in CanTalonSRX::GetAnalogInVel(). return value was not being sign-extended." 2014-12-19 07:02:09 -08:00
Brad Miller (WPI)
9a28aaaa7c Merge "Change expected voltage on CAN tests" 2014-12-19 07:01:20 -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
Brad Miller
d26059a4fb Change expected voltage on CAN tests
Change-Id: I8c4533c7bcc81e7904d10792316382d4c01a840a
2014-12-18 21:22:31 -05:00
Brad Miller
ee0d835304 Remove an extra constructor from a bad merge
Change-Id: I0475eef143814ebf8ee4ec71a019872420442c4f
2014-12-18 18:28:15 -05:00
James Kuszmaul
6080a3b186 Duplicate of gerrit 739; changed method from public to private.
Change-Id: Ib15210ff0e5d8d99a649397499bab4737a1a489e
2014-12-18 16:08:46 -05:00
Omar Zrien
3d06a763a2 CanTalon : Adding config routines for limit switch normally open vs normally closed.
They already existed in Labview, so this will keep parity
New C++/Java funcs
ConfigFwdLimitSwitchNormallyOpen
ConfigRevLimitSwitchNormallyOpen

Change-Id: Ifd65ead827838e7158f7261c67adc3738c72eabf
2014-12-18 15:57:26 -05:00
Omar Zrien
e1480ec798 Noticed that if changeControlMode() is called every teleop loop, it causes motor to stutter as it enters and immediately leaves kDisabled.
A simple improvement was to only perform the disable-before-next-set strategy if the caller's request mode is not equal to the current mode.

To keep things simple, SetControlMode was renamed to private method ApplyControlMode so we can still invoke it from c'tor.
Then, the new impl'n of SetControlMode() just calls ApplyControlMode() when caller's request mode is different.  That takes care of direct-calls from team source, and indirect calls through enableControl().

Applied to both c++ and java.
Tested in java so far...

Change-Id: I934c06c5339d933918470659acd635e12eb4d113
2014-12-18 15:54:47 -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
2434515d41 artf3913
Increased wait delay to 4ms to cover worst case delays for solicted signal getters.
Specifically....
-Get firmware vers
-Get P,I,D,F gains
-Get IZone, Get CloseLoopRampRate
-Get IAccum (integral accumulator)

Change-Id: I313ea984832cce5182af8e5af5e775837fd54fdc
2014-12-18 15:49:29 -05:00
Brad Miller (WPI)
741618250b Merge "C++ CANTalon was missing SetIzone. Added SetIzone to match java, and made the set/get Izone integral." 2014-12-18 12:45:34 -08:00
Omar Zrien
8b8d7e77cd C++ CANTalon was missing SetIzone. Added SetIzone to match java, and made the set/get Izone integral.
Change-Id: I264ac8faaab0ebd208062923f6da2094e7e28b0a
2014-12-18 15:16:10 -05:00
Omar Zrien
c093a553ee changed variable type of closeLoopRampRate in setpid to double from int. It's represents V per sec since it calls setCloseLoopRampRate() underneath.
The other remaining closeloopramprate changes are also merged into this commit, so they may be redundant on gerrit.

Change-Id: Ic3108bb3669e487009b8f52412da3c2f44c42f6f
2014-12-18 15:11:39 -05:00
Fred Silberberg (WPI)
a1375e58cd Merge "Don't fail silently if DIO or PWM allocation fails" 2014-12-18 11:25:39 -08:00
Brad Miller (WPI)
15ff7f5038 Merge "Added the getButtons method back that reads all the buttons at the same time" 2014-12-18 10:33:11 -08:00
Brad Miller
c17ba98f72 Added the getButtons method back that reads all the buttons at the same time
Change-Id: I0f7f35b6a70f861911166de7be3802547ff4b2eb
2014-12-18 10:57:11 -05:00
Brad Miller (WPI)
dee755ab19 Merge "renamed param to match function name." 2014-12-18 07:06:20 -08:00
Brad Miller (WPI)
92c54f5f5d Merge "Image v23" 2014-12-17 15:10:36 -08:00
Fred Silberberg (WPI)
1fde00643f Merge "Fixed post4066 bug: Prestart() inaccessible." 2014-12-17 14:19:03 -08:00
Colby Skeggs
47443b4e1e Fixed post4066 bug: Prestart() inaccessible.
Change-Id: Ie179453b038458e77257c1b2d0acba7a4224f6c4
2014-12-17 13:39:54 -08:00
PetaroMitaro
f01e5b5570 fixed robotCommand in src
Change-Id: I591939301da4427e9139b824b016bb00d4b24485
2014-12-17 16:11:48 -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
Fredric Silberberg
22c4207553 Image v23
This updates the image version to version 23. It also moves the vision libraries
to follow the same conventions as the rest of the ni libraries.

Change-Id: I39e6fb3d8bbd2fd3141c2a43a5bae2fd15149003
2014-12-17 11:04:21 -05:00
Omar Zrien
bea9eb0efa renamed param to match function name.
Change-Id: I89c483691e0f99a6d20bed1271209a8141e71c0e
2014-12-16 20:05:30 -05:00
Brad Miller (WPI)
b72eb4b812 Merge "added Java vision example programs" 2014-12-16 11:43:02 -08:00
Dustin Spicuzza
0d8c454727 Don't fail silently if DIO or PWM allocation fails
Change-Id: I800c429507c3436c2d49561ba279700ad52569fe
2014-12-16 14:24:14 -05:00
PetaroMitaro
d61d491a02 added Java vision example programs
Change-Id: Icd99f53cc544c2609a333f0a86f4eac064d565bd
2014-12-16 11:14:37 -05:00
Brad Miller (WPI)
786e844a9f Merge "Fix ControllerPower 5v faults and add javadocs. Fixes artf3918." 2014-12-16 08:07:30 -08:00
Joe Ross
170b5860ee Fix javadoc compile errors that broke build.
Change-Id: Ie110743154f842dc3a2e756f7917e3aa131c87bd
2014-12-15 19:03:27 -08:00
PetaroMitaro
26c50ebe02 fixed java CameraServer
Change-Id: I34b8c1e2ff05199afdcab579f7ac7188fbe40fd7
2014-12-15 19:45:56 -05:00
Joe Ross
46c659d6b6 Enable Java 8 doclint checking (except for missing tags).
Change-Id: Iebfc7b99cbe43375f9cc067cca322244af44395b
2014-12-15 15:50:44 -08:00
Joe Ross
6fdd491081 Fix javadoc warnings.
Change-Id: I37049f234c6dfddc138121822525794d74e1b74c
2014-12-15 18:48:46 -05:00
Fred Silberberg (WPI)
fe4535dfa0 Merge "Resolved artf3579: robot can no longer be enabled until robotInit() finishes in IterativeRobot; similar options available by overriding prestart() for other base classes." 2014-12-15 15:39:21 -08:00
Brad Miller
636e2e13ad Wrong package declaration in camera server
Change-Id: Ia35d7f78d37aa0db51eb98901364fc228dabaa53
2014-12-15 13:40:25 -05:00
PetaroMitaro
d3f5b74668 added CameraServer.java
Change-Id: I4c41b560d879ffc6d8aa4681cad8f75297fe6cda

Fixed some issues with the camera server class

Change-Id: Ifda524b55f84053be004a404a2890905ded7b266
2014-12-15 11:00:49 -05:00
Brad Miller (WPI)
8116bbd15b Merge "Fix various bugs in nivision wrappers." 2014-12-15 05:42:07 -08:00
Peter Johnson
37052246a5 Fix various bugs in nivision wrappers.
- IMAQdx typedef overrides were being ignored, resulting in incorrect types
(e.g. IMAQdxSession was a long instead of an int).

- Allocated byte buffers byte order was not being set.

- imaqDispose was incorrectly named.

Change-Id: I5d038d45e82755615f0a5bb928defb98f557f93e
2014-12-15 02:44:07 -08:00
Joe Ross
a649d3b553 Fix ControllerPower 5v faults and add javadocs. Fixes artf3918.
5V faults was returning count of 3.3V faults. Copied javadocs from
C++.

Change-Id: I95b5c6ed1213ed235ecde11ef7e28ad05aabca6e
2014-12-14 16:55:22 -08:00
Omar Zrien
6a7e7cf611 Two param constructor added to C++/java CANTalon so caller can optionally specify the periodMs at which the talon control frame is sent.
The param is capped in the HAL C++ class to [1ms, 95ms] so that zero and negative periods are caped to 1ms, and so that caller can't pass an absurdly large value, which causes TALON is appear disabled.

Change-Id: I4207194be25a33bbd6ad281a75301ce6684659a5
2014-12-14 17:09:52 -05:00
Colby Skeggs
1c24096cc9 Resolved artf3579: robot can no longer be enabled until robotInit() finishes in IterativeRobot; similar options available by overriding prestart() for other base classes.
Change-Id: I07fde4b1bd2fae0c2e2a04336639b44ec715628a
2014-12-14 01:22:41 +00:00
194 changed files with 8635 additions and 3560 deletions

View File

@@ -85,6 +85,14 @@
<outputDirectory>${tools-zip}</outputDirectory>
<destFileName>SmartDashboard.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>edu.wpi.first.wpilib</groupId>
<artifactId>sfx</artifactId>
<type>zip</type>
<classifier>zip</classifier>
<outputDirectory>${tools-zip}/../</outputDirectory>
<destFileName>sfx.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>edu.wpi.first.wpilib.networktables</groupId>
<artifactId>OutlineViewer</artifactId>
@@ -143,6 +151,7 @@
</goals>
<configuration>
<target>
<unzip src="${tools-zip}/../sfx.zip" dest="${tools-zip}"/>
<zip destfile="${project.build.directory}/classes/resources/tools.zip"
basedir="${tools-zip}"
update="true" />
@@ -208,6 +217,12 @@
<artifactId>SmartDashboard</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>edu.wpi.first.wpilib</groupId>
<artifactId>sfx</artifactId>
<type>zip</type>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>edu.wpi.first.wpilib.networktables</groupId>
<artifactId>OutlineViewer</artifactId>

View File

@@ -0,0 +1,37 @@
#include "WPILib.h"
/**
* Uses AxisCamera class to manually acquire a new image each frame, and annotate the image by drawing
* a circle on it, and show it on the FRC Dashboard.
*/
class AxisCameraSample : public SampleRobot
{
IMAQdxSession session;
Image *frame;
IMAQdxError imaqError;
AxisCamera *camera;
public:
void RobotInit() override {
// create an image
frame = imaqCreateImage(IMAQ_IMAGE_RGB, 0);
// open the camera at the IP address assigned. This is the IP address that the camera
// can be accessed through the web interface.
camera = new AxisCamera("10.1.91.103");
}
void OperatorControl() override {
// grab an image, draw the circle, and provide it for the camera server which will
// in turn send it to the dashboard.
while(IsOperatorControl() && IsEnabled()) {
camera->GetImage(frame);
imaqDrawShapeOnImage(frame, frame, { 10, 10, 100, 100 }, DrawMode::IMAQ_DRAW_VALUE, ShapeMode::IMAQ_SHAPE_OVAL, 0.0f);
CameraServer::GetInstance()->SetImage(frame);
Wait(0.05);
}
}
};
START_ROBOT_CLASS(AxisCameraSample);

View File

@@ -14,7 +14,7 @@ public:
void RobotInit() override {
// create an image
frame = imaqCreateImage(IMAQ_IMAGE_RGB, 0);
// open the camera
//the camera name (ex "cam0") can be found through the roborio web interface
imaqError = IMAQdxOpenCamera("cam0", IMAQdxCameraControlModeController, &session);
if(imaqError != IMAQdxErrorSuccess) {
DriverStation::ReportError("IMAQdxOpenCamera error: " + std::to_string((long)imaqError) + "\n");
@@ -39,6 +39,7 @@ public:
imaqDrawShapeOnImage(frame, frame, { 10, 10, 100, 100 }, DrawMode::IMAQ_DRAW_VALUE, ShapeMode::IMAQ_SHAPE_OVAL, 0.0f);
CameraServer::GetInstance()->SetImage(frame);
}
Wait(0.005); // wait for a motor update time
}
// stop image acquisition
IMAQdxStopAcquisition(session);

View File

@@ -10,11 +10,18 @@ class QuickVisionRobot : public SampleRobot
{
public:
void RobotInit() override {
CameraServer::GetInstance()->SetQuality(75);
CameraServer::GetInstance()->StartAutomaticCapture();
CameraServer::GetInstance()->SetQuality(50);
//the camera name (ex "cam0") can be found through the roborio web interface
CameraServer::GetInstance()->StartAutomaticCapture("cam0");
}
void OperatorControl() override {
void OperatorControl()
{
while (IsOperatorControl() && IsEnabled())
{
/** robot code here! **/
Wait(0.005); // wait for a motor update time
}
}
};

View File

@@ -281,7 +281,7 @@
</example>
<example>
<name>Simple vision program</name>
<name>Simple Vision</name>
<description>The minimal program to acquire images from an attached USB camera on the robot
and send them to the dashboard.</description>
<tags>
@@ -298,7 +298,7 @@
</example>
<example>
<name>Intermediate vision</name>
<name>Intermediate Vision</name>
<description>An example program that acquires images from an attached USB camera and adds some
annotation to the image as you might do for showing operators the result of some image
recognition, and sends it to the dashboard for display.
@@ -316,6 +316,26 @@
</files>
</example>
<example>
<name>Axis Camera Sample</name>
<description>An example program that acquires images from an Axis network camera and adds some
annotation to the image as you might do for showing operators the result of some image
recognition, and sends it to the dashboard for display. This demonstrates the use of the
AxisCamera class.
</description>
<tags>
<tag>Vision</tag>
<tag>Complete List</tag>
</tags>
<packages>
<package>src</package>
</packages>
<files>
<file source="examples/AxisCameraSample/src/Robot.cpp"
destination="src/Robot.cpp"></file>
</files>
</example>
<example>
<name>GearsBot</name>

View File

@@ -8,7 +8,7 @@ command.dir=/home/lvuser/
# Libraries to use
wpilib=${user.home}/wpilib/cpp/${cpp-version}
wpilib.lib=${wpilib}/lib
roboRIOAllowedImages=22
roboRIOAllowedImages=23
# Ant support
wpilib.ant.dir=${wpilib}/ant

View File

@@ -0,0 +1,55 @@
package $package;
import com.ni.vision.NIVision;
import com.ni.vision.NIVision.DrawMode;
import com.ni.vision.NIVision.Image;
import com.ni.vision.NIVision.ShapeMode;
import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.vision.AxisCamera;
/**
* This demo shows the use of the AxisCamera class.
* Uses AxisCamera class to manually acquire a new image each frame, and annotate the image by drawing
* a circle on it, and show it on the FRC Dashboard.
*/
public class Robot extends SampleRobot {
int session;
Image frame;
AxisCamera camera;
public void robotInit() {
frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
// open the camera at the IP address assigned. This is the IP address that the camera
// can be accessed through the web interface.
camera = new AxisCamera("10.1.91.100");
}
public void operatorControl() {
/**
* grab an image from the camera, draw the circle, and provide it for the camera server
* which will in turn send it to the dashboard.
*/
NIVision.Rect rect = new NIVision.Rect(10, 10, 100, 100);
while (isOperatorControl() && isEnabled()) {
camera.getImage(frame);
NIVision.imaqDrawShapeOnImage(frame, frame, rect,
DrawMode.DRAW_VALUE, ShapeMode.SHAPE_OVAL, 0.0f);
CameraServer.getInstance().setImage(frame);
/** robot code here! **/
Timer.delay(0.005); // wait for a motor update time
}
}
public void test() {
}
}

View File

@@ -0,0 +1,57 @@
package $package;
import com.ni.vision.NIVision;
import com.ni.vision.NIVision.DrawMode;
import com.ni.vision.NIVision.Image;
import com.ni.vision.NIVision.ShapeMode;
import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Timer;
/**
* This is a demo program showing the use of the NIVision class to do vision processing.
* The image is acquired from the USB Webcam, then a circle is overlayed on it.
* The NIVision class supplies dozens of methods for different types of processing.
* The resulting image can then be sent to the FRC PC Dashboard with setImage()
*/
public class Robot extends SampleRobot {
int session;
Image frame;
public void robotInit() {
frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
// the camera name (ex "cam0") can be found through the roborio web interface
session = NIVision.IMAQdxOpenCamera("cam0",
NIVision.IMAQdxCameraControlMode.CameraControlModeController);
NIVision.IMAQdxConfigureGrab(session);
}
public void operatorControl() {
NIVision.IMAQdxStartAcquisition(session);
/**
* grab an image, draw the circle, and provide it for the camera server
* which will in turn send it to the dashboard.
*/
NIVision.Rect rect = new NIVision.Rect(10, 10, 100, 100);
while (isOperatorControl() && isEnabled()) {
NIVision.IMAQdxGrab(session, frame, 1);
NIVision.imaqDrawShapeOnImage(frame, frame, rect,
DrawMode.DRAW_VALUE, ShapeMode.SHAPE_OVAL, 0.0f);
CameraServer.getInstance().setImage(frame);
/** robot code here! **/
Timer.delay(0.005); // wait for a motor update time
}
NIVision.IMAQdxStopAcquisition(session);
}
public void test() {
}
}

View File

@@ -0,0 +1,35 @@
package $package;
import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Timer;
/**
* This is a demo program showing the use of the CameraServer class.
* With start automatic capture, there is no opportunity to process the image.
* Look at the IntermediateVision sample for how to process the image before sending it to the FRC PC Dashboard.
*/
public class Robot extends SampleRobot {
CameraServer server;
public Robot() {
server = CameraServer.getInstance();
server.setQuality(50);
//the camera name (ex "cam0") can be found through the roborio web interface
server.startAutomaticCapture("cam0");
}
/**
* start up automatic capture you should see the video stream from the
* webcam in your FRC PC Dashboard.
*/
public void operatorControl() {
while (isOperatorControl() && isEnabled()) {
/** robot code here! **/
Timer.delay(0.005); // wait for a motor update time
}
}
}

View File

@@ -81,12 +81,18 @@
<description>Example programs that demonstrate the use of the various commonly used sensors on FRC robots</description>
</tagDescription>
<tagDescription>
<name>Vision</name>
<description>Example programs that demonstrate the use of USB Cameras and image processing</description>
</tagDescription>
<example>
<name>Getting Started</name>
<description>An example program which demonstrates the simplest autonomous and
teleoperated routines.</description>
<tags>
<tag>Getting Started with Java</tag>
<tag>Complete List</tag>
</tags>
<packages>
<package>src/$package-dir</package>
@@ -287,4 +293,57 @@
destination="src/$package-dir/triggers/DoubleButton.java"></file>
</files>
</example>
<example>
<name>Simple Vision</name>
<description>Demonstrate the use of the CameraServer class to stream from a USB Webcam without processing the images.</description>
<tags>
<tag>Vision</tag>
<tag>Complete List</tag>
</tags>
<packages>
<package>src/$package-dir</package>
</packages>
<files>
<file source="examples/QuickVision/src/org/usfirst/frc/team190/robot/Robot.java"
destination="src/$package-dir/Robot.java"></file>
</files>
</example>
<example>
<name>Intermediate Vision</name>
<description>Demonstrate the use of the NIVision class to capture image from a Webcam, process them, and then send them to the dashboard.</description>
<tags>
<tag>Vision</tag>
<tag>Complete List</tag>
</tags>
<packages>
<package>src/$package-dir</package>
</packages>
<files>
<file source="examples/IntermediateVision/src/org/usfirst/frc/team190/robot/Robot.java"
destination="src/$package-dir/Robot.java"></file>
</files>
</example>
<example>
<name>Axis Camera Sample</name>
<description>An example program that acquires images from an Axis network camera and adds some
annotation to the image as you might do for showing operators the result of some image
recognition, and sends it to the dashboard for display. This demonstrates the use of the
AxisCamera class.
</description>
<tags>
<tag>Vision</tag>
<tag>Complete List</tag>
</tags>
<packages>
<package>src/$package-dir</package>
</packages>
<files>
<file source="examples/AxisCameraSample/src/org/usfirst/frc/team190/robot/Robot.java"
destination="src/$package-dir/Robot.java"></file>
</files>
</example>
</examples>

View File

@@ -20,7 +20,7 @@ networktables.sources=${wpilib.lib}/NetworkTables-sources.jar
#jnaerator.jar=${wpilib.lib}/jnaerator-runtime.jar
#classpath=${wpilib.jar}:${networktables.jar}:${jna.jar}:${jnaerator.jar}
classpath=${wpilib.jar}:${networktables.jar}
roboRIOAllowedImages=22
roboRIOAllowedImages=23
# Ant support
wpilib.ant.dir=${wpilib}/ant

View File

@@ -221,7 +221,7 @@
</bool>
</assert>
<echo>roboRIO image version validated</echo>
<echo>Checking for JRE. If this fails install the JRE using these instructions: http://wpilib.screenstepslive.com/s/4485/m/13809/l/243933-installing-java-8-on-the-roborio-java-only</echo>
<echo>Checking for JRE. If this fails install the JRE using these instructions: https://wpilib.screenstepslive.com/s/4485/m/13503/l/288822-installing-java-8-on-the-roborio-using-the-frc-roborio-java-installer-java-only</echo>
<sshexec host="${target}"
username="${username}"
password="${password}"

View File

@@ -1,2 +1,2 @@
/usr/local/frc/bin/netconsole-host /usr/local/frc/JRE/bin/java -jar /home/lvuser/FRCUserProgram.jar
env LD_PRELOAD=/lib/libstdc++.so.6.0.20 /usr/local/frc/bin/netconsole-host /usr/local/frc/JRE/bin/java -jar /home/lvuser/FRCUserProgram.jar

View File

@@ -1,2 +1,2 @@
/usr/local/frc/bin/netconsole-host /usr/local/frc/JRE/bin/java -XX:+UsePerfData -agentlib:jdwp=transport=dt_socket,address=8348,server=y,suspend=y -jar /home/lvuser/FRCUserProgram.jar
env LD_PRELOAD=/lib/libstdc++.so.6.0.20 /usr/local/frc/bin/netconsole-host /usr/local/frc/JRE/bin/java -XX:+UsePerfData -agentlib:jdwp=transport=dt_socket,address=8348,server=y,suspend=y -jar /home/lvuser/FRCUserProgram.jar

View File

@@ -23,6 +23,14 @@ extern "C" {
bool getPressureSwitch(void *pcm_pointer, int32_t *status);
float getCompressorCurrent(void *pcm_pointer, int32_t *status);
bool getCompressorCurrentTooHighFault(void *pcm_pointer, int32_t *status);
bool getCompressorCurrentTooHighStickyFault(void *pcm_pointer, int32_t *status);
bool getCompressorShortedStickyFault(void *pcm_pointer, int32_t *status);
bool getCompressorShortedFault(void *pcm_pointer, int32_t *status);
bool getCompressorNotConnectedStickyFault(void *pcm_pointer, int32_t *status);
bool getCompressorNotConnectedFault(void *pcm_pointer, int32_t *status);
void clearAllPCMStickyFaults(void *pcm_pointer, int32_t *status);
}
#endif

View File

@@ -47,6 +47,8 @@
#define ANALOG_TRIGGER_PULSE_OUTPUT_ERROR_MESSAGE "HAL: Attempted to read AnalogTrigger pulse output."
#define PARAMETER_OUT_OF_RANGE -1028
#define PARAMETER_OUT_OF_RANGE_MESSAGE "HAL: A parameter is out of range."
#define RESOURCE_IS_ALLOCATED -1029
#define RESOURCE_IS_ALLOCATED_MESSAGE "HAL: Resource already allocated"
#define VI_ERROR_SYSTEM_ERROR_MESSAGE "HAL - VISA: System Error";
#define VI_ERROR_INV_OBJECT_MESSAGE "HAL - VISA: Invalid Object"

View File

@@ -13,4 +13,9 @@ extern "C"
bool getSolenoid(void* solenoid_port_pointer, int32_t *status);
void setSolenoid(void* solenoid_port_pointer, bool value, int32_t *status);
int getPCMSolenoidBlackList(void* solenoid_port_pointer, int32_t *status);
bool getPCMSolenoidVoltageStickyFault(void* solenoid_port_pointer, int32_t *status);
bool getPCMSolenoidVoltageFault(void* solenoid_port_pointer, int32_t *status);
void clearAllPCMStickyFaults_sol(void *solenoid_port_pointer, int32_t *status);
}

View File

@@ -61,4 +61,56 @@ float getCompressorCurrent(void *pcm_pointer, int32_t *status) {
return value;
}
bool getCompressorCurrentTooHighFault(void *pcm_pointer, int32_t *status) {
PCM *module = (PCM *)pcm_pointer;
bool value;
*status = module->GetCompressorCurrentTooHighFault(value);
return value;
}
bool getCompressorCurrentTooHighStickyFault(void *pcm_pointer, int32_t *status) {
PCM *module = (PCM *)pcm_pointer;
bool value;
*status = module->GetCompressorCurrentTooHighStickyFault(value);
return value;
}
bool getCompressorShortedStickyFault(void *pcm_pointer, int32_t *status) {
PCM *module = (PCM *)pcm_pointer;
bool value;
*status = module->GetCompressorShortedStickyFault(value);
return value;
}
bool getCompressorShortedFault(void *pcm_pointer, int32_t *status) {
PCM *module = (PCM *)pcm_pointer;
bool value;
*status = module->GetCompressorShortedFault(value);
return value;
}
bool getCompressorNotConnectedStickyFault(void *pcm_pointer, int32_t *status) {
PCM *module = (PCM *)pcm_pointer;
bool value;
*status = module->GetCompressorNotConnectedStickyFault(value);
return value;
}
bool getCompressorNotConnectedFault(void *pcm_pointer, int32_t *status) {
PCM *module = (PCM *)pcm_pointer;
bool value;
*status = module->GetCompressorNotConnectedFault(value);
return value;
}
void clearAllPCMStickyFaults(void *pcm_pointer, int32_t *status) {
PCM *module = (PCM *)pcm_pointer;
*status = module->ClearStickyFaults();
}

View File

@@ -384,7 +384,11 @@ bool allocateDIO(void* digital_port_pointer, bool input, int32_t *status) {
DigitalPort* port = (DigitalPort*) digital_port_pointer;
char buf[64];
snprintf(buf, 64, "DIO %d", port->port.pin);
if (DIOChannels->Allocate(port->port.pin, buf) == ~0ul) return false;
if (DIOChannels->Allocate(port->port.pin, buf) == ~0ul) {
*status = RESOURCE_IS_ALLOCATED;
return false;
}
{
Synchronized sync(digitalDIOSemaphore);
@@ -420,7 +424,11 @@ bool allocatePWMChannel(void* digital_port_pointer, int32_t *status) {
DigitalPort* port = (DigitalPort*) digital_port_pointer;
char buf[64];
snprintf(buf, 64, "PWM %d", port->port.pin);
if (PWMChannels->Allocate(port->port.pin, buf) == ~0ul) return false;
if (PWMChannels->Allocate(port->port.pin, buf) == ~0ul) {
*status = RESOURCE_IS_ALLOCATED;
return false;
}
if (port->port.pin > tPWM::kNumHdrRegisters-1) {
snprintf(buf, 64, "PWM %d and DIO %d", port->port.pin, remapMXPPWMChannel(port->port.pin) + 10);
if (DIOChannels->Allocate(remapMXPPWMChannel(port->port.pin) + 10, buf) == ~0ul) return false;
@@ -830,7 +838,7 @@ double getCounterPeriod(void* counter_pointer, int32_t *status) {
// output.Period is a fixed point number that counts by 2 (24 bits, 25 integer bits)
period = (double)(output.Period << 1) / (double)output.Count;
}
return period * 1.0e-6;
return period * 2.5e-8; // result * timebase (currently 40ns)
}
/**
@@ -842,7 +850,7 @@ double getCounterPeriod(void* counter_pointer, int32_t *status) {
*/
void setCounterMaxPeriod(void* counter_pointer, double maxPeriod, int32_t *status) {
Counter* counter = (Counter*) counter_pointer;
counter->counter->writeTimerConfig_StallPeriod((uint32_t)(maxPeriod * 1.0e6), status);
counter->counter->writeTimerConfig_StallPeriod((uint32_t)(maxPeriod * 4.0e8), status);
}
/**
@@ -992,7 +1000,7 @@ double getEncoderPeriod(void* encoder_pointer, int32_t *status) {
// output.Period is a fixed point number that counts by 2 (24 bits, 25 integer bits)
value = (double)(output.Period << 1) / (double)output.Count;
}
double measuredPeriod = value * 1.0e-6;
double measuredPeriod = value * 2.5e-8;
return measuredPeriod / DECODING_SCALING_FACTOR;
}
@@ -1010,7 +1018,7 @@ double getEncoderPeriod(void* encoder_pointer, int32_t *status) {
*/
void setEncoderMaxPeriod(void* encoder_pointer, double maxPeriod, int32_t *status) {
Encoder* encoder = (Encoder*) encoder_pointer;
encoder->encoder->writeTimerConfig_StallPeriod((uint32_t)(maxPeriod * 1.0e6 * DECODING_SCALING_FACTOR), status);
encoder->encoder->writeTimerConfig_StallPeriod((uint32_t)(maxPeriod * 4.0e8 * DECODING_SCALING_FACTOR), status);
}
/**

View File

@@ -52,3 +52,33 @@ void setSolenoid(void* solenoid_port_pointer, bool value, int32_t *status) {
port->module->SetSolenoid(port->pin, value);
}
int getPCMSolenoidBlackList(void* solenoid_port_pointer, int32_t *status){
solenoid_port_t* port = (solenoid_port_t*) solenoid_port_pointer;
UINT8 value;
*status = port->module->GetSolenoidBlackList(value);
return value;
}
bool getPCMSolenoidVoltageStickyFault(void* solenoid_port_pointer, int32_t *status){
solenoid_port_t* port = (solenoid_port_t*) solenoid_port_pointer;
bool value;
*status = port->module->GetSolenoidStickyFault(value);
return value;
}
bool getPCMSolenoidVoltageFault(void* solenoid_port_pointer, int32_t *status){
solenoid_port_t* port = (solenoid_port_t*) solenoid_port_pointer;
bool value;
*status = port->module->GetSolenoidFault(value);
return value;
}
void clearAllPCMStickyFaults_sol(void *solenoid_port_pointer, int32_t *status){
solenoid_port_t* port = (solenoid_port_t*) solenoid_port_pointer;
*status = port->module->ClearStickyFaults();
}

View File

@@ -242,6 +242,11 @@ typedef struct _TALON_Param_Response_t {
CanTalonSRX::CanTalonSRX(int deviceNumber,int controlPeriodMs): CtreCanNode(deviceNumber), _can_h(0), _can_stat(0)
{
/* bound period to be within [1 ms,95 ms] */
if(controlPeriodMs < 1)
controlPeriodMs = 1;
else if(controlPeriodMs > 95)
controlPeriodMs = 95;
RegisterRx(STATUS_1 | (UINT8)deviceNumber );
RegisterRx(STATUS_2 | (UINT8)deviceNumber );
RegisterRx(STATUS_3 | (UINT8)deviceNumber );
@@ -566,6 +571,11 @@ CTR_Code CanTalonSRX::GetReverseSoftEnable(int & enable)
CTR_Code CanTalonSRX::SetStatusFrameRate(unsigned frameEnum, unsigned periodMs)
{
int32_t status = 0;
/* bounds check the period */
if(periodMs < 1)
periodMs = 1;
else if (periodMs > 255)
periodMs = 255;
uint8_t period = (uint8_t)periodMs;
/* tweak just the status messsage rate the caller cares about */
switch(frameEnum){
@@ -866,9 +876,9 @@ CTR_Code CanTalonSRX::GetAnalogInVel(int &param)
raw |= rx->AnalogInVelH;
raw <<= 8;
raw |= rx->AnalogInVelL;
param = (int)raw;
raw <<= (32-16); /* sign extend */
raw >>= (32-16); /* sign extend */
param = (int)raw;
return rx.err;
}
CTR_Code CanTalonSRX::GetTemp(double &param)
@@ -1212,6 +1222,10 @@ CTR_Code c_TalonSRX_SetModeSelect(void *handle, int param)
{
return ((CanTalonSRX*)handle)->SetModeSelect(param);
}
CTR_Code c_TalonSRX_SetModeSelect2(void *handle, int modeSelect, int demand)
{
return ((CanTalonSRX*)handle)->SetModeSelect(modeSelect, demand);
}
CTR_Code c_TalonSRX_SetProfileSlotSelect(void *handle, int param)
{
return ((CanTalonSRX*)handle)->SetProfileSlotSelect(param);

View File

@@ -366,6 +366,7 @@ extern "C" {
CTR_Code c_TalonSRX_SetRevMotDuringCloseLoopEn(void *handle, int param);
CTR_Code c_TalonSRX_SetOverrideBrakeType(void *handle, int param);
CTR_Code c_TalonSRX_SetModeSelect(void *handle, int param);
CTR_Code c_TalonSRX_SetModeSelect2(void *handle, int modeSelect, int demand);
CTR_Code c_TalonSRX_SetProfileSlotSelect(void *handle, int param);
CTR_Code c_TalonSRX_SetRampThrottle(void *handle, int param);
CTR_Code c_TalonSRX_SetRevFeedbackSensor(void *handle, int param);

View File

@@ -17,7 +17,9 @@ static const INT32 kCANPeriod = 20;
#define GET_PCM_SOL_FAULTS() CtreCanNode::recMsg<PcmStatusFault_t> rx = GetRx<PcmStatusFault_t> (STATUS_SOL_FAULTS,EXPECTED_RESPONSE_TIMEOUT_MS)
#define GET_PCM_DEBUG() CtreCanNode::recMsg<PcmDebug_t> rx = GetRx<PcmDebug_t> (STATUS_DEBUG,EXPECTED_RESPONSE_TIMEOUT_MS)
#define CONTROL_1 0x09041C00
#define CONTROL_1 0x09041C00 /* PCM_Control */
#define CONTROL_2 0x09041C40 /* PCM_SupplemControl */
#define CONTROL_3 0x09041C80 /* PcmControlSetOneShotDur_t */
/* encoder/decoders */
typedef struct _PcmStatus_t{
@@ -27,8 +29,8 @@ typedef struct _PcmStatus_t{
unsigned compressorOn:1;
unsigned stickyFaultFuseTripped:1;
unsigned stickyFaultCompCurrentTooHigh:1;
unsigned faultCompCurrentTooHigh:1;
unsigned faultFuseTripped:1;
unsigned faultCompCurrentTooHigh:1;
unsigned faultHardwareFailure:1;
unsigned isCloseloopEnabled:1;
unsigned pressureSwitchEn:1;
@@ -40,7 +42,8 @@ typedef struct _PcmStatus_t{
unsigned compressorCurrentTop6:6;
unsigned solenoidVoltageBtm2:2;
/* Byte 5 */
unsigned reserved:2;
unsigned StickyFault_dItooHigh :1;
unsigned Fault_dItooHigh :1;
unsigned moduleEnabled:1;
unsigned closedLoopOutput:1;
unsigned compressorCurrentBtm4:4;
@@ -63,19 +66,28 @@ typedef struct _PcmControl_t{
unsigned compressorOn:1;
unsigned closedLoopEnable:1;
unsigned clearStickyFaults:1;
/* Byte 4 */
unsigned OneShotField_h8:8;
/* Byte 5 */
unsigned OneShotField_l8:8;
}PcmControl_t;
typedef struct _PcmControlSetOneShotDur_t{
uint8_t sol10MsPerUnit[8];
}PcmControlSetOneShotDur_t;
typedef struct _PcmStatusFault_t{
/* Byte 0 */
unsigned SolenoidBlacklist:8;
/* Byte 1 */
unsigned reserved1:8;
unsigned reserved2:8;
unsigned reserved3:8;
unsigned reserved4:8;
unsigned reserved5:8;
unsigned reserved6:8;
unsigned reserved7:8;
unsigned reserved_bit0 :1;
unsigned reserved_bit1 :1;
unsigned reserved_bit2 :1;
unsigned reserved_bit3 :1;
unsigned StickyFault_CompNoCurrent :1;
unsigned Fault_CompNoCurrent :1;
unsigned StickyFault_SolenoidJumper :1;
unsigned Fault_SolenoidJumper :1;
}PcmStatusFault_t;
typedef struct _PcmDebug_t{
@@ -135,12 +147,13 @@ CTR_Code PCM::SetSolenoid(unsigned char idx, bool en)
*
* @Param - clr - Clear / do not clear faults
*/
CTR_Code PCM::ClearStickyFaults(bool clr)
CTR_Code PCM::ClearStickyFaults()
{
CtreCanNode::txTask<PcmControl_t> toFill = GetTx<PcmControl_t>(CONTROL_1 | GetDeviceNumber());
if(toFill.IsEmpty())return CTR_UnexpectedArbId;
toFill->clearStickyFaults = clr;
FlushTx(toFill);
int32_t status = 0;
uint8_t pcmSupplemControl[] = { 0, 0, 0, 0x80 }; /* only bit set is ClearStickyFaults */
FRC_NetworkCommunication_CANSessionMux_sendMessage(CONTROL_2 | GetDeviceNumber(), pcmSupplemControl, sizeof(pcmSupplemControl), 0, &status);
if(status)
return CTR_TxFailed;
return CTR_OKAY;
}
@@ -158,6 +171,59 @@ CTR_Code PCM::SetClosedLoopControl(bool en)
FlushTx(toFill);
return CTR_OKAY;
}
/* Get solenoid Blacklist status
* @Return - CTR_Code - Error code (if any)
* @Param - idx - ID of solenoid [0,7] to fire one shot pulse.
*/
CTR_Code PCM::FireOneShotSolenoid(UINT8 idx)
{
CtreCanNode::txTask<PcmControl_t> toFill = GetTx<PcmControl_t>(CONTROL_1 | GetDeviceNumber());
if(toFill.IsEmpty())return CTR_UnexpectedArbId;
/* grab field as it is now */
uint16_t oneShotField;
oneShotField = toFill->OneShotField_h8;
oneShotField <<= 8;
oneShotField |= toFill->OneShotField_l8;
/* get the caller's channel */
uint16_t shift = 2*idx;
uint16_t mask = 3; /* two bits wide */
uint8_t chBits = (oneShotField >> shift) & mask;
/* flip it */
chBits = (chBits)%3 + 1;
/* clear out 2bits for this channel*/
oneShotField &= ~(mask << shift);
/* put new field in */
oneShotField |= chBits << shift;
/* apply field as it is now */
toFill->OneShotField_h8 = oneShotField >> 8;
toFill->OneShotField_l8 = oneShotField;
FlushTx(toFill);
return CTR_OKAY;
}
/* Configure the pulse width of a solenoid channel for one-shot pulse.
* Preprogrammed pulsewidth is 10ms resolute and can be between 20ms and 5.1s.
* @Return - CTR_Code - Error code (if any)
* @Param - idx - ID of solenoid [0,7] to configure.
* @Param - durMs - pulse width in ms.
*/
CTR_Code PCM::SetOneShotDurationMs(UINT8 idx,uint32_t durMs)
{
/* sanity check caller's param */
if(idx > 8)
return CTR_InvalidParamValue;
/* get latest tx frame */
CtreCanNode::txTask<PcmControlSetOneShotDur_t> toFill = GetTx<PcmControlSetOneShotDur_t>(CONTROL_3 | GetDeviceNumber());
if(toFill.IsEmpty()){
/* only send this out if caller wants to do one-shots */
RegisterTx(CONTROL_3 | _deviceNumber, kCANPeriod);
/* grab it */
toFill = GetTx<PcmControlSetOneShotDur_t>(CONTROL_3 | GetDeviceNumber());
}
toFill->sol10MsPerUnit[idx] = std::min(durMs/10,(uint32_t)0xFF);
/* apply the new data bytes */
FlushTx(toFill);
return CTR_OKAY;
}
/* Get solenoid state
*
@@ -248,12 +314,36 @@ CTR_Code PCM::GetHardwareFault(bool &status)
*
* @Return - True/False - True if shorted compressor detected, false if otherwise
*/
CTR_Code PCM::GetCompressorFault(bool &status)
CTR_Code PCM::GetCompressorCurrentTooHighFault(bool &status)
{
GET_PCM_STATUS();
status = rx->faultCompCurrentTooHigh;
return rx.err;
}
CTR_Code PCM::GetCompressorShortedStickyFault(bool &status)
{
GET_PCM_STATUS();
status = rx->StickyFault_dItooHigh;
return rx.err;
}
CTR_Code PCM::GetCompressorShortedFault(bool &status)
{
GET_PCM_STATUS();
status = rx->Fault_dItooHigh;
return rx.err;
}
CTR_Code PCM::GetCompressorNotConnectedStickyFault(bool &status)
{
GET_PCM_SOL_FAULTS();
status = rx->StickyFault_CompNoCurrent;
return rx.err;
}
CTR_Code PCM::GetCompressorNotConnectedFault(bool &status)
{
GET_PCM_SOL_FAULTS();
status = rx->Fault_CompNoCurrent;
return rx.err;
}
/* Get solenoid fault value
*
@@ -271,7 +361,7 @@ CTR_Code PCM::GetSolenoidFault(bool &status)
* @Return - True/False - True if solenoid had previously been shorted
* (and sticky fault was not cleared), false if otherwise
*/
CTR_Code PCM::GetCompressorStickyFault(bool &status)
CTR_Code PCM::GetCompressorCurrentTooHighStickyFault(bool &status)
{
GET_PCM_STATUS();
status = rx->stickyFaultCompCurrentTooHigh;
@@ -369,7 +459,7 @@ extern "C" {
return ((PCM*) handle)->SetClosedLoopControl(param);
}
CTR_Code c_ClearStickyFaults(void * handle, INT8 param) {
return ((PCM*) handle)->ClearStickyFaults(param);
return ((PCM*) handle)->ClearStickyFaults();
}
CTR_Code c_GetSolenoid(void * handle, UINT8 idx, INT8 * status) {
bool bstatus;
@@ -410,7 +500,7 @@ extern "C" {
}
CTR_Code c_GetCompressorFault(void * handle, INT8*status) {
bool bstatus;
CTR_Code retval = ((PCM*) handle)->GetCompressorFault(bstatus);
CTR_Code retval = ((PCM*) handle)->GetCompressorCurrentTooHighFault(bstatus);
*status = bstatus;
return retval;
}
@@ -422,7 +512,7 @@ extern "C" {
}
CTR_Code c_GetCompressorStickyFault(void * handle, INT8*status) {
bool bstatus;
CTR_Code retval = ((PCM*) handle)->GetCompressorStickyFault(bstatus);
CTR_Code retval = ((PCM*) handle)->GetCompressorCurrentTooHighStickyFault(bstatus);
*status = bstatus;
return retval;
}

View File

@@ -26,9 +26,8 @@ public:
/* Clears PCM sticky faults (indicators of past faults
* @Return - CTR_Code - Error code (if any) for setting solenoid
* @Param - clr - Clear / do not clear faults
*/
CTR_Code ClearStickyFaults(bool clr);
CTR_Code ClearStickyFaults();
/* Get solenoid state
*
@@ -76,9 +75,9 @@ public:
/* Get compressor fault value
* @Return - CTR_Code - Error code (if any)
* @Param - status - True if shorted compressor detected, false if otherwise
* @Param - status - True if abnormally high compressor current detected, false if otherwise
*/
CTR_Code GetCompressorFault(bool &status);
CTR_Code GetCompressorCurrentTooHighFault(bool &status);
/* Get solenoid fault value
* @Return - CTR_Code - Error code (if any)
@@ -91,7 +90,29 @@ public:
* @Param - status - True if solenoid had previously been shorted
* (and sticky fault was not cleared), false if otherwise
*/
CTR_Code GetCompressorStickyFault(bool &status);
CTR_Code GetCompressorCurrentTooHighStickyFault(bool &status);
/* Get compressor shorted sticky fault value
* @Return - CTR_Code - Error code (if any)
* @Param - status - True if compressor output is shorted, false if otherwise
*/
CTR_Code GetCompressorShortedStickyFault(bool &status);
/* Get compressor shorted fault value
* @Return - CTR_Code - Error code (if any)
* @Param - status - True if compressor output is shorted, false if otherwise
*/
CTR_Code GetCompressorShortedFault(bool &status);
/* Get compressor is not connected sticky fault value
* @Return - CTR_Code - Error code (if any)
* @Param - status - True if compressor current is too low,
* indicating compressor is not connected, false if otherwise
*/
CTR_Code GetCompressorNotConnectedStickyFault(bool &status);
/* Get compressor is not connected fault value
* @Return - CTR_Code - Error code (if any)
* @Param - status - True if compressor current is too low,
* indicating compressor is not connected, false if otherwise
*/
CTR_Code GetCompressorNotConnectedFault(bool &status);
/* Get solenoid sticky fault value
* @Return - CTR_Code - Error code (if any)
@@ -146,6 +167,21 @@ public:
* @Param - status - Returns TRUE if PCM is enabled, FALSE if disabled
*/
CTR_Code isModuleEnabled(bool &status);
/* Get solenoid Blacklist status
* @Return - CTR_Code - Error code (if any)
* @Param - idx - ID of solenoid [0,7] to fire one shot pulse.
*/
CTR_Code FireOneShotSolenoid(UINT8 idx);
/* Configure the pulse width of a solenoid channel for one-shot pulse.
* Preprogrammed pulsewidth is 10ms resolute and can be between 20ms and 5.1s.
* @Return - CTR_Code - Error code (if any)
* @Param - idx - ID of solenoid [0,7] to configure.
* @Param - durMs - pulse width in ms.
*/
CTR_Code SetOneShotDurationMs(UINT8 idx,uint32_t durMs);
};
//------------------ C interface --------------------------------------------//
extern "C" {

BIN
ni-libraries/libniimaqdx.so Executable file → Normal file

Binary file not shown.

View File

@@ -0,0 +1,2 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libniimaqdx.so.14.0 )

View File

@@ -0,0 +1,2 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libniimaqdx.so.14.0.0 )

Binary file not shown.

BIN
ni-libraries/libnivision.so Executable file → Normal file

Binary file not shown.

View File

@@ -0,0 +1,2 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libnivision.so.14.0 )

View File

@@ -0,0 +1,2 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libnivision.so.14.0.0 )

Binary file not shown.

BIN
ni-libraries/libnivissvc.so Executable file → Normal file

Binary file not shown.

View File

@@ -0,0 +1,2 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libnivissvc.so.14.0 )

View File

@@ -0,0 +1,2 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libnivissvc.so.14.0.0 )

Binary file not shown.

View File

@@ -7,6 +7,7 @@
#include "interfaces/Accelerometer.h"
#include "I2C.h"
#include "LiveWindow/LiveWindowSendable.h"
/**
* ADXL345 Accelerometer on I2C.
@@ -14,7 +15,7 @@
* This class allows access to a Analog Devices ADXL345 3-axis accelerometer on an I2C bus.
* This class assumes the default (not alternate) sensor address of 0x1D (7-bit address).
*/
class ADXL345_I2C : public Accelerometer, public I2C
class ADXL345_I2C : public Accelerometer, public I2C, public LiveWindowSendable
{
protected:
static const uint8_t kAddress = 0x1D;
@@ -48,6 +49,15 @@ public:
virtual double GetAcceleration(Axes axis);
virtual AllAxes GetAccelerations();
virtual std::string GetSmartDashboardType();
virtual void InitTable(ITable *subtable);
virtual void UpdateTable();
virtual ITable* GetTable();
virtual void StartLiveWindowMode() {}
virtual void StopLiveWindowMode() {}
protected:
//I2C* m_i2c;
private:
ITable *m_table;
};

View File

@@ -8,6 +8,7 @@
#include "interfaces/Accelerometer.h"
#include "SensorBase.h"
#include "SPI.h"
#include "LiveWindow/LiveWindowSendable.h"
class DigitalInput;
class DigitalOutput;
@@ -18,7 +19,7 @@ class DigitalOutput;
* This class allows access to an Analog Devices ADXL345 3-axis accelerometer via SPI.
* This class assumes the sensor is wired in 4-wire SPI mode.
*/
class ADXL345_SPI : public Accelerometer, public SensorBase
class ADXL345_SPI : public Accelerometer, public SensorBase, public LiveWindowSendable
{
protected:
static const uint8_t kPowerCtlRegister = 0x2D;
@@ -52,9 +53,18 @@ public:
virtual double GetAcceleration(Axes axis);
virtual AllAxes GetAccelerations();
virtual std::string GetSmartDashboardType();
virtual void InitTable(ITable *subtable);
virtual void UpdateTable();
virtual ITable* GetTable();
virtual void StartLiveWindowMode() {}
virtual void StopLiveWindowMode() {}
protected:
void Init(Range range);
SPI* m_spi;
SPI::Port m_port;
private:
ITable *m_table;
};

View File

@@ -54,7 +54,10 @@ public:
/** Only use switches for limits */
kLimitMode_SwitchInputsOnly = 0,
/** Use both switches and soft limits */
kLimitMode_SoftPositionLimits = 1
kLimitMode_SoftPositionLimits = 1,
/* SRX extensions */
/** Disable switches and disable soft limits */
kLimitMode_SrxDisableSwitchInputs = 2,
};
virtual float Get() = 0;

View File

@@ -26,8 +26,15 @@ public:
AnalogEncoder=3,
EncRising=4,
EncFalling=5
};
enum StatusFrameRate {
StatusFrameRateGeneral=0,
StatusFrameRateFeedback=1,
StatusFrameRateQuadEncoder=2,
StatusFrameRateAnalogTempVbat=3,
};
explicit CANTalon(int deviceNumber);
explicit CANTalon(int deviceNumber,int controlPeriodMs);
virtual ~CANTalon();
// PIDController interface
@@ -51,6 +58,7 @@ public:
virtual void SetI(double i) override;
virtual void SetD(double d) override;
void SetF(double f);
void SetIzone(unsigned iz);
virtual void SetPID(double p, double i, double d) override;
void SetPID(double p, double i, double d, double f);
virtual double GetP() override;
@@ -66,6 +74,7 @@ public:
virtual double GetSpeed() override;
virtual int GetClosedLoopError();
virtual int GetAnalogIn();
virtual int GetAnalogInRaw();
virtual int GetAnalogInVel();
virtual int GetEncPosition();
virtual int GetEncVel();
@@ -91,17 +100,41 @@ public:
virtual void ConfigLimitMode(LimitMode mode) override;
virtual void ConfigForwardLimit(double forwardLimitPosition) override;
virtual void ConfigReverseLimit(double reverseLimitPosition) override;
/**
* Change the fwd limit switch setting to normally open or closed.
* Talon will disable momentarilly if the Talon's current setting
* is dissimilar to the caller's requested setting.
*
* Since Talon saves setting to flash this should only affect
* a given Talon initially during robot install.
*
* @param normallyOpen true for normally open. false for normally closed.
*/
void ConfigFwdLimitSwitchNormallyOpen(bool normallyOpen);
/**
* Change the rev limit switch setting to normally open or closed.
* Talon will disable momentarilly if the Talon's current setting
* is dissimilar to the caller's requested setting.
*
* Since Talon saves setting to flash this should only affect
* a given Talon initially during robot install.
*
* @param normallyOpen true for normally open. false for normally closed.
*/
void ConfigRevLimitSwitchNormallyOpen(bool normallyOpen);
virtual void ConfigMaxOutputVoltage(double voltage) override;
virtual void ConfigFaultTime(float faultTime) override;
virtual void SetControlMode(ControlMode mode);
void SetFeedbackDevice(FeedbackDevice device);
void SetStatusFrameRateMs(StatusFrameRate stateFrame, int periodMs);
virtual ControlMode GetControlMode();
void SetSensorDirection(bool reverseSensor);
void SetCloseLoopRampRate(double rampRate);
void SelectProfileSlot(int slotIdx);
double GetIzone();
int GetIzone();
int GetIaccum();
void ClearIaccum();
int GetBrakeEnableDuringNeutral();
bool IsControlEnabled();
double GetSetpoint();
@@ -127,4 +160,12 @@ private:
TalonControlMode m_sendMode;
double m_setPoint;
static const unsigned int kDelayForSolicitedSignalsUs = 4000;
/**
* Fixup the sendMode so Set() serializes the correct demand value.
* Also fills the modeSelecet in the control frame to disabled.
* @param mode Control mode to ultimately enter once user calls Set().
* @see Set()
*/
void ApplyControlMode(CANSpeedController::ControlMode mode);
};

View File

@@ -32,6 +32,14 @@ public:
void SetClosedLoopControl(bool on);
bool GetClosedLoopControl();
bool GetCompressorCurrentTooHighFault();
bool GetCompressorCurrentTooHighStickyFault();
bool GetCompressorShortedStickyFault();
bool GetCompressorShortedFault();
bool GetCompressorNotConnectedStickyFault();
bool GetCompressorNotConnectedFault();
void ClearAllPCMStickyFaults();
void UpdateTable();
void StartLiveWindowMode();
void StopLiveWindowMode();

View File

@@ -67,7 +67,7 @@ public:
bool GetDirection();
void SetSamplesToAverage(int samplesToAverage);
int GetSamplesToAverage();
uint32_t GetIndex()
uint32_t GetFPGAIndex()
{
return m_index;
}

View File

@@ -31,6 +31,8 @@ public:
virtual ~DoubleSolenoid();
virtual void Set(Value value);
virtual Value Get();
bool IsFwdSolenoidBlackListed();
bool IsRevSolenoidBlackListed();
void ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew);
void UpdateTable();

View File

@@ -34,6 +34,7 @@ public:
float GetStickAxis(uint32_t stick, uint32_t axis);
int GetStickPOV(uint32_t stick, uint32_t pov);
uint32_t GetStickButtons(uint32_t stick);
bool GetStickButton(uint32_t stick, uint8_t button);
int GetStickAxisCount(uint32_t stick);

View File

@@ -41,6 +41,7 @@ public:
// CounterBase interface
int32_t Get();
int32_t GetRaw();
int32_t GetEncodingScale();
void Reset();
double GetPeriod();
void SetMaxPeriod(double maxPeriod);
@@ -63,6 +64,11 @@ public:
void InitTable(ITable *subTable);
ITable * GetTable();
int32_t GetFPGAIndex()
{
return m_index;
}
private:
void InitEncoder(bool _reverseDirection, EncodingType encodingType);
double DecodingScaleFactor();
@@ -72,9 +78,11 @@ private:
bool m_allocatedASource; // was the A source allocated locally?
bool m_allocatedBSource; // was the B source allocated locally?
void* m_encoder;
int32_t m_index; // The encoder's FPGA index.
double m_distancePerPulse; // distance of travel for each encoder tick
Counter *m_counter; // Counter object for 1x and 2x encoding
EncodingType m_encodingType; // Encoding type
int32_t m_encodingScale; // 1x, 2x, or 4x, per the encodingType
PIDSourceParameter m_pidSource; // Encoder parameter that sources a PID controller
ITable *m_table;

View File

@@ -60,6 +60,8 @@ public:
virtual void TestPeriodic();
protected:
virtual void Prestart();
virtual ~IterativeRobot();
IterativeRobot();

View File

@@ -13,16 +13,16 @@
* Class implements the PWM generation in the FPGA.
*
* The values supplied as arguments for PWM outputs range from -1.0 to 1.0. They are mapped
* to the hardware dependent values, in this case 0-255 for the FPGA.
* to the hardware dependent values, in this case 0-2000 for the FPGA.
* Changes are immediately sent to the FPGA, and the update occurs at the next
* FPGA cycle. There is no delay.
*
* As of revision 0.1.10 of the FPGA, the FPGA interprets the 0-255 values as follows:
* - 255 = full "forward"
* - 254 to 129 = linear scaling from "full forward" to "center"
* - 128 = center value
* - 127 to 2 = linear scaling from "center" to "full reverse"
* - 1 = full "reverse"
* As of revision 0.1.10 of the FPGA, the FPGA interprets the 0-2000 values as follows:
* - 2000 = maximum pulse width
* - 1999 to 1001 = linear scaling from "full forward" to "center"
* - 1000 = center value
* - 999 to 2 = linear scaling from "center" to "full reverse"
* - 1 = minimum pulse width (currently .5ms)
* - 0 = disabled (i.e. PWM output is held low)
*/
class PWM : public SensorBase, public ITableListener, public LiveWindowSendable

View File

@@ -9,12 +9,13 @@
#define __WPILIB_POWER_DISTRIBUTION_PANEL_H__
#include "SensorBase.h"
#include "LiveWindow/LiveWindowSendable.h"
/**
* Class for getting voltage, current, and temperature from the CAN PDP
* @author Thomas Clark
*/
class PowerDistributionPanel : public SensorBase {
class PowerDistributionPanel : public SensorBase, public LiveWindowSendable {
public:
PowerDistributionPanel();
@@ -26,6 +27,16 @@ class PowerDistributionPanel : public SensorBase {
double GetTotalEnergy();
void ResetTotalEnergy();
void ClearStickyFaults();
void UpdateTable();
void StartLiveWindowMode();
void StopLiveWindowMode();
std::string GetSmartDashboardType();
void InitTable(ITable *subTable);
ITable * GetTable();
private:
ITable *m_table;
};
#endif /* __WPILIB_POWER_DISTRIBUTION_PANEL_H__ */

View File

@@ -14,9 +14,9 @@ class DriverStation;
int main() \
{ \
if (!HALInitialize()){std::cerr<<"FATAL ERROR: HAL could not be initialized"<<std::endl;return -1;} \
HALNetworkCommunicationObserveUserProgramStarting(); \
HALReport(HALUsageReporting::kResourceType_Language, HALUsageReporting::kLanguage_CPlusPlus); \
(new _ClassName_())->StartCompetition(); \
_ClassName_ *robot = new _ClassName_(); \
RobotBase::robotSetup(robot); \
return 0; \
}
@@ -44,11 +44,15 @@ public:
static void startRobotTask(FUNCPTR factory);
static void robotTask(FUNCPTR factory, Task *task);
virtual void StartCompetition() = 0;
static void robotSetup(RobotBase *robot);
protected:
virtual ~RobotBase();
RobotBase();
virtual void Prestart();
Task *m_task;
DriverStation *m_ds;

View File

@@ -23,6 +23,7 @@ public:
virtual ~Solenoid();
virtual void Set(bool on);
virtual bool Get();
bool IsBlackListed();
void ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew);
void UpdateTable();

View File

@@ -20,6 +20,10 @@ public:
virtual ~SolenoidBase();
uint8_t GetAll();
uint8_t GetPCMSolenoidBlackList();
bool GetPCMSolenoidVoltageStickyFault();
bool GetPCMSolenoidVoltageFault();
void ClearAllPCMStickyFaults();
protected:
explicit SolenoidBase(uint8_t pcmID);
void Set(uint8_t value, uint8_t mask);

View File

@@ -0,0 +1,127 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2014. 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 <thread>
#include <string>
#include <mutex>
#include "ErrorBase.h"
#include "Vision/ColorImage.h"
#include "Vision/HSLImage.h"
#include "nivision.h"
/**
* Axis M1011 network camera
*/
class AxisCamera: public ErrorBase
{
public:
enum WhiteBalance
{
kWhiteBalance_Automatic,
kWhiteBalance_Hold,
kWhiteBalance_FixedOutdoor1,
kWhiteBalance_FixedOutdoor2,
kWhiteBalance_FixedIndoor,
kWhiteBalance_FixedFluorescent1,
kWhiteBalance_FixedFluorescent2
};
enum ExposureControl
{
kExposureControl_Automatic,
kExposureControl_Hold,
kExposureControl_FlickerFree50Hz,
kExposureControl_FlickerFree60Hz
};
enum Resolution
{
kResolution_640x480,
kResolution_480x360,
kResolution_320x240,
kResolution_240x180,
kResolution_176x144,
kResolution_160x120,
};
enum Rotation
{
kRotation_0, kRotation_180
};
explicit AxisCamera(std::string const& cameraHost);
virtual ~AxisCamera();
bool IsFreshImage() const;
int GetImage(Image *image);
int GetImage(ColorImage *image);
HSLImage *GetImage();
int CopyJPEG(char **destImage, unsigned int &destImageSize, unsigned int &destImageBufferSize);
void WriteBrightness(int brightness);
int GetBrightness();
void WriteWhiteBalance(WhiteBalance whiteBalance);
WhiteBalance GetWhiteBalance();
void WriteColorLevel(int colorLevel);
int GetColorLevel();
void WriteExposureControl(ExposureControl exposureControl);
ExposureControl GetExposureControl();
void WriteExposurePriority(int exposurePriority);
int GetExposurePriority();
void WriteMaxFPS(int maxFPS);
int GetMaxFPS();
void WriteResolution(Resolution resolution);
Resolution GetResolution();
void WriteCompression(int compression);
int GetCompression();
void WriteRotation(Rotation rotation);
Rotation GetRotation();
private:
std::thread m_captureThread;
std::string m_cameraHost;
int m_cameraSocket;
std::mutex m_captureMutex;
std::mutex m_imageDataMutex;
std::vector<uint8_t> m_imageData;
bool m_freshImage;
int m_brightness;
WhiteBalance m_whiteBalance;
int m_colorLevel;
ExposureControl m_exposureControl;
int m_exposurePriority;
int m_maxFPS;
Resolution m_resolution;
int m_compression;
Rotation m_rotation;
bool m_parametersDirty;
bool m_streamDirty;
std::mutex m_parametersMutex;
bool m_done;
void Capture();
void ReadImagesFromCamera();
bool WriteParameters();
int CreateCameraSocket(std::string const& requestString, bool setError);
DISALLOW_COPY_AND_ASSIGN(AxisCamera);
};

View File

@@ -0,0 +1,57 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2014. 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
/* Constants */
#define LOG_DEBUG __FILE__,__FUNCTION__,__LINE__,DEBUG_TYPE
#define LOG_INFO __FILE__,__FUNCTION__,__LINE__,INFO_TYPE
#define LOG_ERROR __FILE__,__FUNCTION__,__LINE__,ERROR_TYPE
#define LOG_CRITICAL __FILE__,__FUNCTION__,__LINE__,CRITICAL_TYPE
#define LOG_FATAL __FILE__,__FUNCTION__,__LINE__,FATAL_TYPE
#define LOG_DEBUG __FILE__,__FUNCTION__,__LINE__,DEBUG_TYPE
/* Enumerated Types */
/** debug levels */
enum dprint_type {DEBUG_TYPE, INFO_TYPE, ERROR_TYPE, CRITICAL_TYPE, FATAL_TYPE};
/** debug output setting */
typedef enum DebugOutputType_enum {
DEBUG_OFF, DEBUG_MOSTLY_OFF, DEBUG_SCREEN_ONLY, DEBUG_FILE_ONLY, DEBUG_SCREEN_AND_FILE
}DebugOutputType;
/* Enumerated Types */
/* Utility functions */
/* debug */
void SetDebugFlag ( DebugOutputType flag );
void dprintf ( const char * tempString, ... ); /* Variable argument list */
/* set FRC ranges for drive */
double RangeToNormalized(double pixel, int range);
/* change normalized value to any range - used for servo */
float NormalizeToRange(float normalizedValue, float minRange, float maxRange);
float NormalizeToRange(float normalizedValue);
/* system utilities */
void ShowActivity (char *fmt, ...);
double ElapsedTime (double startTime);
/* servo panning utilities */
class Servo;
double SinPosition (double *period, double sinStart);
void panInit();
void panInit(double period);
void panForTarget(Servo *panServo);
void panForTarget(Servo *panServo, double sinStart);
/* config file read utilities */
int processFile(char *inputFile, char *outputString, int lineNumber);
int emptyString(char *string);
void stripString(char *string);

View File

@@ -0,0 +1,39 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2014. 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 "MonoImage.h"
/**
* Included for ParticleAnalysisReport definition
* TODO: Eliminate this dependency!
*/
#include "Vision/VisionAPI.h"
#include <vector>
#include <algorithm>
class BinaryImage : public MonoImage
{
public:
BinaryImage();
virtual ~BinaryImage();
int GetNumberParticles();
ParticleAnalysisReport GetParticleAnalysisReport(int particleNumber);
void GetParticleAnalysisReport(int particleNumber, ParticleAnalysisReport *par);
std::vector<ParticleAnalysisReport>* GetOrderedParticleAnalysisReports();
BinaryImage *RemoveSmallObjects(bool connectivity8, int erosions);
BinaryImage *RemoveLargeObjects(bool connectivity8, int erosions);
BinaryImage *ConvexHull(bool connectivity8);
BinaryImage *ParticleFilter(ParticleFilterCriteria2 *criteria, int criteriaCount);
virtual void Write(const char *fileName);
private:
bool ParticleMeasurement(int particleNumber, MeasurementType whatToMeasure, int *result);
bool ParticleMeasurement(int particleNumber, MeasurementType whatToMeasure, double *result);
static double NormalizeFromRange(double position, int range);
static bool CompareParticleSizes(ParticleAnalysisReport particle1, ParticleAnalysisReport particle2);
};

View File

@@ -0,0 +1,65 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2014. 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 "ImageBase.h"
#include "BinaryImage.h"
#include "Threshold.h"
class ColorImage : public ImageBase
{
public:
ColorImage(ImageType type);
virtual ~ColorImage();
BinaryImage *ThresholdRGB(int redLow, int redHigh, int greenLow, int greenHigh, int blueLow, int blueHigh);
BinaryImage *ThresholdHSL(int hueLow, int hueHigh, int saturationLow, int saturationHigh, int luminenceLow, int luminenceHigh);
BinaryImage *ThresholdHSV(int hueLow, int hueHigh, int saturationLow, int saturationHigh, int valueHigh, int valueLow);
BinaryImage *ThresholdHSI(int hueLow, int hueHigh, int saturationLow, int saturationHigh, int intensityLow, int intensityHigh);
BinaryImage *ThresholdRGB(Threshold &threshold);
BinaryImage *ThresholdHSL(Threshold &threshold);
BinaryImage *ThresholdHSV(Threshold &threshold);
BinaryImage *ThresholdHSI(Threshold &threshold);
MonoImage *GetRedPlane();
MonoImage *GetGreenPlane();
MonoImage *GetBluePlane();
MonoImage *GetHSLHuePlane();
MonoImage *GetHSVHuePlane();
MonoImage *GetHSIHuePlane();
MonoImage *GetHSLSaturationPlane();
MonoImage *GetHSVSaturationPlane();
MonoImage *GetHSISaturationPlane();
MonoImage *GetLuminancePlane();
MonoImage *GetValuePlane();
MonoImage *GetIntensityPlane();
void ReplaceRedPlane(MonoImage *plane);
void ReplaceGreenPlane(MonoImage *plane);
void ReplaceBluePlane(MonoImage *plane);
void ReplaceHSLHuePlane(MonoImage *plane);
void ReplaceHSVHuePlane(MonoImage *plane);
void ReplaceHSIHuePlane(MonoImage *plane);
void ReplaceHSLSaturationPlane(MonoImage *plane);
void ReplaceHSVSaturationPlane(MonoImage *plane);
void ReplaceHSISaturationPlane(MonoImage *plane);
void ReplaceLuminancePlane(MonoImage *plane);
void ReplaceValuePlane(MonoImage *plane);
void ReplaceIntensityPlane(MonoImage *plane);
void ColorEqualize();
void LuminanceEqualize();
private:
BinaryImage *ComputeThreshold(ColorMode colorMode, int low1, int high1, int low2, int high2, int low3, int high3);
void Equalize(bool allPlanes);
MonoImage * ExtractColorPlane(ColorMode mode, int planeNumber);
MonoImage * ExtractFirstColorPlane(ColorMode mode);
MonoImage * ExtractSecondColorPlane(ColorMode mode);
MonoImage * ExtractThirdColorPlane(ColorMode mode);
void ReplacePlane(ColorMode mode, MonoImage *plane, int planeNumber);
void ReplaceFirstColorPlane(ColorMode mode, MonoImage *plane);
void ReplaceSecondColorPlane(ColorMode mode, MonoImage *plane);
void ReplaceThirdColorPlane(ColorMode mode, MonoImage *plane);
};

View File

@@ -0,0 +1,30 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2014. 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
/* Error Codes */
#define ERR_VISION_GENERAL_ERROR 166000 //
#define ERR_COLOR_NOT_FOUND 166100 // TrackAPI.cpp
#define ERR_PARTICLE_TOO_SMALL 166101 // TrackAPI.cpp
#define ERR_CAMERA_FAILURE 166200 // AxisCamera.cpp
#define ERR_CAMERA_SOCKET_CREATE_FAILED 166201 // AxisCamera.cpp
#define ERR_CAMERA_CONNECT_FAILED 166202 // AxisCamera.cpp
#define ERR_CAMERA_STALE_IMAGE 166203 // AxisCamera.cpp
#define ERR_CAMERA_NOT_INITIALIZED 166204 // AxisCamera.cpp
#define ERR_CAMERA_NO_BUFFER_AVAILABLE 166205 // AxisCamera.cpp
#define ERR_CAMERA_HEADER_ERROR 166206 // AxisCamera.cpp
#define ERR_CAMERA_BLOCKING_TIMEOUT 166207 // AxisCamera.cpp
#define ERR_CAMERA_AUTHORIZATION_FAILED 166208 // AxisCamera.cpp
#define ERR_CAMERA_TASK_SPAWN_FAILED 166209 // AxisCamera.cpp
#define ERR_CAMERA_TASK_INPUT_OUT_OF_RANGE 166210 // AxisCamera.cpp
#define ERR_CAMERA_COMMAND_FAILURE 166211 // AxisCamera.cpp
/* error handling functions */
int GetLastVisionError();
const char* GetVisionErrorText(int errorCode);

View File

@@ -0,0 +1,22 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2014. 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 "ColorImage.h"
/**
* A color image represented in HSL color space at 3 bytes per pixel.
*/
class HSLImage : public ColorImage
{
public:
HSLImage();
HSLImage(const char *fileName);
virtual ~HSLImage();
};

View File

@@ -0,0 +1,27 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2014. 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 <stdio.h>
#include "nivision.h"
#include "ErrorBase.h"
#define DEFAULT_BORDER_SIZE 3
class ImageBase : public ErrorBase
{
public:
ImageBase(ImageType type);
virtual ~ImageBase();
virtual void Write(const char *fileName);
int GetHeight();
int GetWidth();
Image *GetImaqImage();
protected:
Image *m_imaqImage;
};

View File

@@ -0,0 +1,25 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2014. 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 "ImageBase.h"
#include <vector>
class MonoImage : public ImageBase
{
public:
MonoImage();
virtual ~MonoImage();
std::vector<EllipseMatch> *DetectEllipses(EllipseDescriptor *ellipseDescriptor,
CurveOptions *curveOptions,
ShapeDetectionOptions *shapeDetectionOptions,
ROI *roi);
std::vector<EllipseMatch> * DetectEllipses(EllipseDescriptor *ellipseDescriptor);
};

View File

@@ -0,0 +1,21 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2014. 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 "ColorImage.h"
/**
* A color image represented in RGB color space at 3 bytes per pixel.
*/
class RGBImage : public ColorImage
{
public:
RGBImage();
RGBImage(const char *fileName);
virtual ~RGBImage();
};

View File

@@ -0,0 +1,28 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2014. 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
/**
* Color threshold values.
* This object represnts the threshold values for any type of color object
* that is used in a threshhold operation. It simplifies passing values
* around in a program for color detection.
*/
class Threshold
{
public:
int plane1Low;
int plane1High;
int plane2Low;
int plane2High;
int plane3Low;
int plane3High;
Threshold(int plane1Low, int plane1High,
int plane2Low, int plane2High,
int plane3Low, int plane3High);
};

View File

@@ -0,0 +1,148 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2014. 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 "nivision.h"
/* Constants */
#define DEFAULT_BORDER_SIZE 3 //VisionAPI.frcCreateImage
#define DEFAULT_SATURATION_THRESHOLD 40 //TrackAPI.FindColor
/* Forward Declare Data Structures */
typedef struct FindEdgeOptions_struct FindEdgeOptions;
typedef struct CircularEdgeReport_struct CircularEdgeReport;
/* Data Structures */
/** frcParticleAnalysis returns this structure */
typedef struct ParticleAnalysisReport_struct {
int imageHeight;
int imageWidth;
double imageTimestamp;
int particleIndex; // the particle index analyzed
/* X-coordinate of the point representing the average position of the
* total particle mass, assuming every point in the particle has a constant density */
int center_mass_x; // MeasurementType: IMAQ_MT_CENTER_OF_MASS_X
/* Y-coordinate of the point representing the average position of the
* total particle mass, assuming every point in the particle has a constant density */
int center_mass_y; // MeasurementType: IMAQ_MT_CENTER_OF_MASS_Y
double center_mass_x_normalized; //Center of mass x value normalized to -1.0 to +1.0 range
double center_mass_y_normalized; //Center of mass y value normalized to -1.0 to +1.0 range
/* Area of the particle */
double particleArea; // MeasurementType: IMAQ_MT_AREA
/* Bounding Rectangle */
Rect boundingRect; // left/top/width/height
/* Percentage of the particle Area covering the Image Area. */
double particleToImagePercent; // MeasurementType: IMAQ_MT_AREA_BY_IMAGE_AREA
/* Percentage of the particle Area in relation to its Particle and Holes Area */
double particleQuality; // MeasurementType: IMAQ_MT_AREA_BY_PARTICLE_AND_HOLES_AREA
} ParticleAnalysisReport;
/** Tracking functions return this structure */
typedef struct ColorReport_struct {
int numberParticlesFound; // Number of particles found for this color
int largestParticleNumber; // The particle index of the largest particle
/* Color information */
float particleHueMax; // HistogramReport: hue max
float particleHueMin; // HistogramReport: hue max
float particleHueMean; // HistogramReport: hue mean
float particleSatMax; // HistogramReport: saturation max
float particleSatMin; // HistogramReport: saturation max
float particleSatMean; // HistogramReport: saturation mean
float particleLumMax; // HistogramReport: luminance max
float particleLumMin; // HistogramReport: luminance max
float particleLumMean; // HistogramReport: luminance mean
} ColorReport;
/* Image Management functions */
/* Create: calls imaqCreateImage. Border size is set to some default value */
Image* frcCreateImage( ImageType type );
/* Dispose: calls imaqDispose */
int frcDispose( void* object );
int frcDispose( const char* filename, ... ) ;
/* Copy: calls imaqDuplicateImage */
int frcCopyImage( Image* dest, const Image* source );
/* Image Extraction: Crop: calls imaqScale */
int frcCrop( Image* dest, const Image* source, Rect rect );
/* Image Extraction: Scale: calls imaqScale. Scales entire image */
int frcScale(Image* dest, const Image* source, int xScale, int yScale, ScalingMode scaleMode );
/* Read Image : calls imaqReadFile */
int frcReadImage( Image* image, const char* fileName );
/* Write Image : calls imaqWriteFile */
int frcWriteImage( const Image* image, const char* fileName);
/* Measure Intensity functions */
/* Histogram: calls imaqHistogram */
HistogramReport* frcHistogram( const Image* image, int numClasses, float min, float max, Rect rect );
/* Color Histogram: calls imaqColorHistogram2 */
ColorHistogramReport* frcColorHistogram(const Image* image, int numClasses, ColorMode mode, Image* mask);
/* Get Pixel Value: calls imaqGetPixel */
int frcGetPixelValue( const Image* image, Point pixel, PixelValue* value );
/* Particle Analysis functions */
/* Particle Filter: calls imaqParticleFilter3 */
int frcParticleFilter(Image* dest, Image* source, const ParticleFilterCriteria2* criteria,
int criteriaCount, const ParticleFilterOptions* options, Rect rect, int* numParticles);
int frcParticleFilter(Image* dest, Image* source, const ParticleFilterCriteria2* criteria,
int criteriaCount, const ParticleFilterOptions* options, int* numParticles);
/* Morphology: calls imaqMorphology */
int frcMorphology(Image* dest, Image* source, MorphologyMethod method);
int frcMorphology(Image* dest, Image* source, MorphologyMethod method, const StructuringElement* structuringElement);
/* Reject Border: calls imaqRejectBorder */
int frcRejectBorder(Image* dest, Image* source);
int frcRejectBorder(Image* dest, Image* source, int connectivity8);
/* Count Particles: calls imaqCountParticles */
int frcCountParticles(Image* image, int* numParticles);
/* Particle Analysis Report: calls imaqMeasureParticle */
int frcParticleAnalysis(Image* image, int particleNumber, ParticleAnalysisReport* par);
/* Image Enhancement functions */
/* Equalize: calls imaqEqualize */
int frcEqualize(Image* dest, const Image* source, float min, float max);
int frcEqualize(Image* dest, const Image* source, float min, float max, const Image* mask);
/* Color Equalize: calls imaqColorEqualize */
int frcColorEqualize(Image* dest, const Image* source);
int frcColorEqualize(Image* dest, const Image* source, int colorEqualization);
/* Image Thresholding & Conversion functions */
/* Smart Threshold: calls imaqLocalThreshold */
int frcSmartThreshold(Image* dest, const Image* source, unsigned int windowWidth, unsigned int windowHeight,
LocalThresholdMethod method, double deviationWeight, ObjectType type);
int frcSmartThreshold(Image* dest, const Image* source, unsigned int windowWidth, unsigned int windowHeight,
LocalThresholdMethod method, double deviationWeight, ObjectType type, float replaceValue);
/* Simple Threshold: calls imaqThreshold */
int frcSimpleThreshold(Image* dest, const Image* source, float rangeMin, float rangeMax, float newValue);
int frcSimpleThreshold(Image* dest, const Image* source, float rangeMin, float rangeMax);
/* Color/Hue Threshold: calls imaqColorThreshold */
int frcColorThreshold(Image* dest, const Image* source, ColorMode mode,
const Range* plane1Range, const Range* plane2Range, const Range* plane3Range);
int frcColorThreshold(Image* dest, const Image* source, int replaceValue, ColorMode mode,
const Range* plane1Range, const Range* plane2Range, const Range* plane3Range);
int frcHueThreshold(Image* dest, const Image* source, const Range* hueRange);
int frcHueThreshold(Image* dest, const Image* source, const Range* hueRange, int minSaturation);
/* Extract ColorHue Plane: calls imaqExtractColorPlanes */
int frcExtractColorPlanes(const Image* image, ColorMode mode, Image* plane1, Image* plane2, Image* plane3);
int frcExtractHuePlane(const Image* image, Image* huePlane);
int frcExtractHuePlane(const Image* image, Image* huePlane, int minSaturation);

View File

@@ -85,5 +85,13 @@
#include "Utility.h"
#include "Victor.h"
#include "VictorSP.h"
#include "Vision/AxisCamera.h"
#include "Vision/BinaryImage.h"
#include "Vision/ColorImage.h"
#include "Vision/HSLImage.h"
#include "Vision/ImageBase.h"
#include "Vision/MonoImage.h"
#include "Vision/RGBImage.h"
#include "Vision/Threshold.h"
// XXX: #include "Vision/AxisCamera.h"
#include "WPIErrors.h"

View File

@@ -5339,5 +5339,7 @@ IMAQ_FUNC ReadTextReport* IMAQ_STDCALL imaqReadText(const Image* image, c
IMAQ_FUNC ThresholdData* IMAQ_STDCALL imaqAutoThreshold(Image* dest, Image* source, int numClasses, ThresholdMethod method);
IMAQ_FUNC ColorHistogramReport* IMAQ_STDCALL imaqColorHistogram(Image* image, int numClasses, ColorMode mode, const Image* mask);
IMAQ_FUNC RakeReport* IMAQ_STDCALL imaqRake(const Image* image, const ROI* roi, RakeDirection direction, EdgeProcess process, const RakeOptions* options);
IMAQ_FUNC int IMAQ_STDCALL Priv_ReadJPEGString_C(Image* image, const unsigned char* string, unsigned int stringLength);
#endif

View File

@@ -7,6 +7,7 @@
#include "ADXL345_I2C.h"
#include "I2C.h"
#include "HAL/HAL.hpp"
#include "LiveWindow/LiveWindow.h"
const uint8_t ADXL345_I2C::kAddress;
const uint8_t ADXL345_I2C::kPowerCtlRegister;
@@ -17,6 +18,7 @@ constexpr double ADXL345_I2C::kGsPerLSB;
/**
* Constructor.
*
* @param port The I2C port the accelerometer is attached to
* @param range The range (+ or -) that the accelerometer will measure.
*/
ADXL345_I2C::ADXL345_I2C(Port port, Range range):
@@ -30,6 +32,7 @@ ADXL345_I2C::ADXL345_I2C(Port port, Range range):
SetRange(range);
HALReport(HALUsageReporting::kResourceType_ADXL345, HALUsageReporting::kADXL345_I2C, 0);
LiveWindow::GetInstance()->AddSensor("ADXL345_I2C", port, this);
}
/**
@@ -84,7 +87,7 @@ double ADXL345_I2C::GetAcceleration(ADXL345_I2C::Axes axis)
/**
* Get the acceleration of all axes in Gs.
*
* @return Acceleration measured on all axes of the ADXL345 in Gs.
* @return An object containing the acceleration measured on each axis of the ADXL345 in Gs.
*/
ADXL345_I2C::AllAxes ADXL345_I2C::GetAccelerations()
{
@@ -100,3 +103,24 @@ ADXL345_I2C::AllAxes ADXL345_I2C::GetAccelerations()
//}
return data;
}
std::string ADXL345_I2C::GetSmartDashboardType() {
return "3AxisAccelerometer";
}
void ADXL345_I2C::InitTable(ITable *subtable) {
m_table = subtable;
UpdateTable();
}
void ADXL345_I2C::UpdateTable() {
if (m_table != NULL) {
m_table->PutNumber("X", GetX());
m_table->PutNumber("Y", GetY());
m_table->PutNumber("Z", GetZ());
}
}
ITable* ADXL345_I2C::GetTable() {
return m_table;
}

View File

@@ -8,16 +8,25 @@
#include "DigitalInput.h"
#include "DigitalOutput.h"
#include "SPI.h"
#include "LiveWindow/LiveWindow.h"
const uint8_t ADXL345_SPI::kPowerCtlRegister;
const uint8_t ADXL345_SPI::kDataFormatRegister;
const uint8_t ADXL345_SPI::kDataRegister;
constexpr double ADXL345_SPI::kGsPerLSB;
/**
* Constructor.
*
* @param port The SPI port the accelerometer is attached to
* @param range The range (+ or -) that the accelerometer will measure.
*/
ADXL345_SPI::ADXL345_SPI(SPI::Port port, ADXL345_SPI::Range range)
{
m_port = port;
Init(range);
LiveWindow::GetInstance()->AddSensor("ADXL345_SPI", port, this);
}
/**
@@ -106,7 +115,7 @@ double ADXL345_SPI::GetAcceleration(ADXL345_SPI::Axes axis)
/**
* Get the acceleration of all axes in Gs.
*
* @return Acceleration measured on all axes of the ADXL345 in Gs.
* @return An object containing the acceleration measured on each axis of the ADXL345 in Gs.
*/
ADXL345_SPI::AllAxes ADXL345_SPI::GetAccelerations()
{
@@ -131,3 +140,24 @@ ADXL345_SPI::AllAxes ADXL345_SPI::GetAccelerations()
}
return data;
}
std::string ADXL345_SPI::GetSmartDashboardType() {
return "3AxisAccelerometer";
}
void ADXL345_SPI::InitTable(ITable *subtable) {
m_table = subtable;
UpdateTable();
}
void ADXL345_SPI::UpdateTable() {
if (m_table != NULL) {
m_table->PutNumber("X", GetX());
m_table->PutNumber("Y", GetY());
m_table->PutNumber("Z", GetZ());
}
}
ITable* ADXL345_SPI::GetTable() {
return m_table;
}

View File

@@ -23,8 +23,8 @@ void AnalogAccelerometer::InitAccelerometer()
/**
* Create a new instance of an accelerometer.
*
* The constructor allocates desired analog input.
* @param channel The channel number for the analog input the accelerometer is connected to
*/
AnalogAccelerometer::AnalogAccelerometer(int32_t channel)
{
@@ -38,6 +38,7 @@ AnalogAccelerometer::AnalogAccelerometer(int32_t channel)
* Make a new instance of accelerometer given an AnalogInput. This is particularly
* useful if the port is going to be read as an analog channel as well as through
* the Accelerometer class.
* @param channel The existing AnalogInput object for the analog input the accelerometer is connected to
*/
AnalogAccelerometer::AnalogAccelerometer(AnalogInput *channel)
{
@@ -80,7 +81,7 @@ float AnalogAccelerometer::GetAcceleration()
* Set the accelerometer sensitivity.
*
* This sets the sensitivity of the accelerometer used for calculating the acceleration.
* The sensitivity varys by accelerometer model. There are constants defined for various models.
* The sensitivity varies by accelerometer model. There are constants defined for various models.
*
* @param sensitivity The sensitivity of accelerometer in Volts per G.
*/
@@ -92,7 +93,7 @@ void AnalogAccelerometer::SetSensitivity(float sensitivity)
/**
* Set the voltage that corresponds to 0 G.
*
* The zero G voltage varys by accelerometer model. There are constants defined for various models.
* The zero G voltage varies by accelerometer model. There are constants defined for various models.
*
* @param zero The zero G voltage.
*/

View File

@@ -54,7 +54,7 @@ void AnalogInput::InitAnalogInput(uint32_t channel)
/**
* Construct an analog input.
*
* @param channel The channel number to represent.
* @param channel The channel number on the roboRIO to represent. 0-3 are on-board 4-7 are on the MXP port.
*/
AnalogInput::AnalogInput(uint32_t channel)
{
@@ -86,9 +86,9 @@ int16_t AnalogInput::GetValue()
/**
* Get a sample from the output of the oversample and average engine for this channel.
* The sample is 12-bit + the value configured in SetOversampleBits().
* The sample is 12-bit + the bits configured in SetOversampleBits().
* The value configured in SetAverageBits() will cause this value to be averaged 2**bits number of samples.
* This is not a sliding window. The sample will not change until 2**(OversamplBits + AverageBits) samples
* This is not a sliding window. The sample will not change until 2**(OversampleBits + AverageBits) samples
* have been acquired from the module on this channel.
* Use GetAverageVoltage() to get the analog value in calibrated units.
* @return A sample from the oversample and average engine for this channel.
@@ -176,7 +176,7 @@ uint32_t AnalogInput::GetChannel()
/**
* Set the number of averaging bits.
* This sets the number of averaging bits. The actual number of averaged samples is 2**bits.
* This sets the number of averaging bits. The actual number of averaged samples is 2^bits.
* Use averaging to improve the stability of your measurement at the expense of sampling rate.
* The averaging is done automatically in the FPGA.
*
@@ -192,7 +192,7 @@ void AnalogInput::SetAverageBits(uint32_t bits)
/**
* Get the number of averaging bits previously configured.
* This gets the number of averaging bits from the FPGA. The actual number of averaged samples is 2**bits.
* This gets the number of averaging bits from the FPGA. The actual number of averaged samples is 2^bits.
* The averaging is done automatically in the FPGA.
*
* @return Number of bits of averaging previously configured.
@@ -207,7 +207,7 @@ uint32_t AnalogInput::GetAverageBits()
/**
* Set the number of oversample bits.
* This sets the number of oversample bits. The actual number of oversampled values is 2**bits.
* This sets the number of oversample bits. The actual number of oversampled values is 2^bits.
* Use oversampling to improve the resolution of your measurements at the expense of sampling rate.
* The oversampling is done automatically in the FPGA.
*
@@ -224,7 +224,7 @@ void AnalogInput::SetOversampleBits(uint32_t bits)
/**
* Get the number of oversample bits previously configured.
* This gets the number of oversample bits from the FPGA. The actual number of oversampled values is
* 2**bits. The oversampling is done automatically in the FPGA.
* 2^bits. The oversampling is done automatically in the FPGA.
*
* @return Number of bits of oversampling previously configured.
*/
@@ -265,7 +265,7 @@ void AnalogInput::InitAccumulator()
/**
* Set an inital value for the accumulator.
* Set an initial value for the accumulator.
*
* This will be added to all values returned to the user.
* @param initialValue The value that the accumulator should start from when reset.
@@ -301,11 +301,11 @@ void AnalogInput::ResetAccumulator()
* Set the center value of the accumulator.
*
* The center value is subtracted from each A/D value before it is added to the accumulator. This
* is used for the center value of devices like gyros and accelerometers to make integration work
* and to take the device offset into account when integrating.
* is used for the center value of devices like gyros and accelerometers to
* take the device offset into account when integrating.
*
* This center value is based on the output of the oversampled and averaged source from channel 1.
* Because of this, any non-zero oversample bits will affect the size of the value for this field.
* This center value is based on the output of the oversampled and averaged source from the accumulator
* channel. Because of this, any non-zero oversample bits will affect the size of the value for this field.
*/
void AnalogInput::SetAccumulatorCenter(int32_t center)
{
@@ -317,6 +317,7 @@ void AnalogInput::SetAccumulatorCenter(int32_t center)
/**
* Set the accumulator's deadband.
* @param
*/
void AnalogInput::SetAccumulatorDeadband(int32_t deadband)
{
@@ -329,7 +330,7 @@ void AnalogInput::SetAccumulatorDeadband(int32_t deadband)
/**
* Read the accumulated value.
*
* Read the value that has been accumulating on channel 1.
* Read the value that has been accumulating.
* The accumulator is attached after the oversample and average engine.
*
* @return The 64-bit value accumulated since the last Reset().
@@ -379,8 +380,9 @@ void AnalogInput::GetAccumulatorOutput(int64_t *value, uint32_t *count)
}
/**
* Set the sample rate for all analog channels.
*
* Set the sample rate per channel for all analog channels.
* The maximum rate is 500kS/s divided by the number of channels in use.
* This is 62500 samples/s per channel.
* @param samplesPerSecond The number of samples per second.
*/
void AnalogInput::SetSampleRate(float samplesPerSecond)

View File

@@ -44,12 +44,17 @@ void AnalogOutput::InitAnalogOutput(uint32_t channel) {
}
/**
* Construct an anlog output on the given channel
* Construct an analog output on the given channel.
* All analog outputs are located on the MXP port.
* @param The channel number on the roboRIO to represent.
*/
AnalogOutput::AnalogOutput(uint32_t channel) {
InitAnalogOutput(channel);
}
/**
* Destructor. Frees analog output resource
*/
AnalogOutput::~AnalogOutput() {
outputs->Free(m_channel);
}

View File

@@ -11,21 +11,42 @@ void AnalogPotentiometer::initPot(AnalogInput *input, double fullRange, double o
m_analog_input = input;
}
/**
* Construct an Analog Potentiometer object from a channel number.
* @param channel The channel number on the roboRIO to represent. 0-3 are on-board 4-7 are on the MXP port.
* @param fullRange The angular value (in desired units) representing the full 0-5V range of the input.
* @param offset The angular value (in desired units) representing the angular output at 0V.
*/
AnalogPotentiometer::AnalogPotentiometer(int channel, double fullRange, double offset) {
m_init_analog_input = true;
initPot(new AnalogInput(channel), fullRange, offset);
}
/**
* Construct an Analog Potentiometer object from an existing Analog Input pointer.
* @param channel The existing Analog Input pointer
* @param fullRange The angular value (in desired units) representing the full 0-5V range of the input.
* @param offset The angular value (in desired units) representing the angular output at 0V.
*/
AnalogPotentiometer::AnalogPotentiometer(AnalogInput *input, double fullRange, double offset) {
m_init_analog_input = false;
initPot(input, fullRange, offset);
}
/**
* Construct an Analog Potentiometer object from an existing Analog Input reference.
* @param channel The existing Analog Input reference
* @param fullRange The angular value (in desired units) representing the full 0-5V range of the input.
* @param offset The angular value (in desired units) representing the angular output at 0V.
*/
AnalogPotentiometer::AnalogPotentiometer(AnalogInput &input, double fullRange, double offset) {
m_init_analog_input = false;
initPot(&input, fullRange, offset);
}
/**
* Destructor. Releases the Analog Input resource if it was allocated by this object
*/
AnalogPotentiometer::~AnalogPotentiometer() {
if(m_init_analog_input){
delete m_analog_input;
@@ -36,7 +57,7 @@ AnalogPotentiometer::~AnalogPotentiometer() {
/**
* Get the current reading of the potentiometer.
*
* @return The current position of the potentiometer.
* @return The current position of the potentiometer (in the units used for fullRaneg and offset).
*/
double AnalogPotentiometer::Get() {
return (m_analog_input->GetVoltage() / ControllerPower::GetVoltage5V()) * m_fullRange + m_offset;

View File

@@ -29,7 +29,7 @@ void AnalogTrigger::InitTrigger(uint32_t channel)
/**
* Constructor for an analog trigger given a channel number.
*
* @param channel The analog channel (0..7).
* @param channel The channel number on the roboRIO to represent. 0-3 are on-board 4-7 are on the MXP port.
*/
AnalogTrigger::AnalogTrigger(int32_t channel)
{
@@ -40,6 +40,7 @@ AnalogTrigger::AnalogTrigger(int32_t channel)
* Construct an analog trigger given an analog input.
* This should be used in the case of sharing an analog channel between the
* trigger and an analog input object.
* @param channel The pointer to the existing AnalogInput object
*/
AnalogTrigger::AnalogTrigger(AnalogInput *input)
{
@@ -57,6 +58,8 @@ AnalogTrigger::~AnalogTrigger()
* Set the upper and lower limits of the analog trigger.
* The limits are given in ADC codes. If oversampling is used, the units must be scaled
* appropriately.
* @param lower The lower limit of the trigger in ADC codes (12-bit values).
* @param upper The upper limit of the trigger in ADC codes (12-bit values).
*/
void AnalogTrigger::SetLimitsRaw(int32_t lower, int32_t upper)
{
@@ -69,6 +72,8 @@ void AnalogTrigger::SetLimitsRaw(int32_t lower, int32_t upper)
/**
* Set the upper and lower limits of the analog trigger.
* The limits are given as floating point voltage values.
* @param lower The lower limit of the trigger in Volts.
* @param upper The upper limit of the trigger in Volts.
*/
void AnalogTrigger::SetLimitsVoltage(float lower, float upper)
{
@@ -82,6 +87,7 @@ void AnalogTrigger::SetLimitsVoltage(float lower, float upper)
* Configure the analog trigger to use the averaged vs. raw values.
* If the value is true, then the averaged value is selected for the analog trigger, otherwise
* the immediate value is used.
* @param useAveragedValue If true, use the Averaged value, otherwise use the instantaneous reading
*/
void AnalogTrigger::SetAveraged(bool useAveragedValue)
{
@@ -95,6 +101,7 @@ void AnalogTrigger::SetAveraged(bool useAveragedValue)
* Configure the analog trigger to use a filtered value.
* The analog trigger will operate with a 3 point average rejection filter. This is designed to
* help with 360 degree pot applications for the period where the pot crosses through zero.
* @param useFilteredValue If true, use the 3 point rejection filter, otherwise use the unfiltered value
*/
void AnalogTrigger::SetFiltered(bool useFilteredValue)
{
@@ -118,7 +125,7 @@ uint32_t AnalogTrigger::GetIndex()
/**
* Return the InWindow output of the analog trigger.
* True if the analog input is between the upper and lower limits.
* @return The InWindow output of the analog trigger.
* @return True if the analog input is between the upper and lower limits.
*/
bool AnalogTrigger::GetInWindow()
{
@@ -134,7 +141,7 @@ bool AnalogTrigger::GetInWindow()
* True if above upper limit.
* False if below lower limit.
* If in Hysteresis, maintain previous state.
* @return The TriggerState output of the analog trigger.
* @return True if above upper limit. False if below lower limit. If in Hysteresis, maintain previous state.
*/
bool AnalogTrigger::GetTriggerState()
{

View File

@@ -7,6 +7,7 @@
#include "BuiltInAccelerometer.h"
#include "HAL/HAL.hpp"
#include "WPIErrors.h"
#include "LiveWindow/LiveWindow.h"
/**
* Constructor.
@@ -18,6 +19,7 @@ BuiltInAccelerometer::BuiltInAccelerometer(Range range)
SetRange(range);
HALReport(HALUsageReporting::kResourceType_Accelerometer, 0, 0, "Built-in accelerometer");
LiveWindow::GetInstance()->AddSensor((std::string)"BuiltInAccel",0, this);
}
BuiltInAccelerometer::~BuiltInAccelerometer()
@@ -62,7 +64,7 @@ double BuiltInAccelerometer::GetZ()
}
std::string BuiltInAccelerometer::GetSmartDashboardType() {
return "Accelerometer";
return "3AxisAccelerometer";
}
void BuiltInAccelerometer::InitTable(ITable *subtable) {

View File

@@ -21,10 +21,27 @@ CANTalon::CANTalon(int deviceNumber)
, m_controlMode(kPercentVbus)
, m_setPoint(0)
{
SetControlMode(m_controlMode);
ApplyControlMode(m_controlMode);
m_impl->SetProfileSlotSelect(m_profile);
}
/**
* Constructor for the CANTalon device.
* @param deviceNumber The CAN ID of the Talon SRX
* @param controlPeriodMs The period in ms to send the CAN control frame.
* Period is bounded to [1ms, 95ms].
*/
CANTalon::CANTalon(int deviceNumber,int controlPeriodMs)
: m_deviceNumber(deviceNumber)
, m_impl(new CanTalonSRX(deviceNumber,controlPeriodMs)) /* bounded underneath to be within [1 ms,95 ms] */
, m_safetyHelper(new MotorSafetyHelper(this))
, m_profile(0)
, m_controlEnabled(true)
, m_controlMode(kPercentVbus)
, m_setPoint(0)
{
ApplyControlMode(m_controlMode);
m_impl->SetProfileSlotSelect(m_profile);
}
CANTalon::~CANTalon() {
delete m_impl;
delete m_safetyHelper;
@@ -88,6 +105,8 @@ float CANTalon::Get()
*/
void CANTalon::Set(float value, uint8_t syncGroup)
{
/* feed safety helper since caller just updated our output */
m_safetyHelper->Feed();
if(m_controlEnabled) {
m_setPoint = value;
CTR_Code status;
@@ -203,6 +222,19 @@ void CANTalon::SetF(double f)
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
/**
* Set the Izone to a nonzero value to auto clear the integral accumulator
* when the absolute value of CloseLoopError exceeds Izone.
*
* @see SelectProfileSlot to choose between the two sets of gains.
*/
void CANTalon::SetIzone(unsigned iz)
{
CTR_Code status = m_impl->SetIzone(m_profile, iz);
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
/**
* SRX has two available slots for PID.
* @param slotIdx one or zero depending on which slot caller wants.
@@ -243,6 +275,16 @@ void CANTalon::SetFeedbackDevice(FeedbackDevice device)
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
/**
* Select the feedback device to use in closed-loop
*/
void CANTalon::SetStatusFrameRateMs(StatusFrameRate stateFrame, int periodMs)
{
CTR_Code status = m_impl->SetStatusFrameRate((int)stateFrame,periodMs);
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
/**
* TODO documentation (see CANJaguar.cpp)
@@ -256,7 +298,7 @@ double CANTalon::GetP()
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
usleep(1000); /* small yield for getting response */
usleep(kDelayForSolicitedSignalsUs); /* small yield for getting response */
double p;
status = m_impl->GetPgain(m_profile, p);
if(status != CTR_OKAY) {
@@ -277,7 +319,7 @@ double CANTalon::GetI()
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
usleep(1000); /* small yield for getting response */
usleep(kDelayForSolicitedSignalsUs); /* small yield for getting response */
double i;
status = m_impl->GetIgain(m_profile, i);
@@ -299,7 +341,7 @@ double CANTalon::GetD()
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
usleep(1000); /* small yield for getting response */
usleep(kDelayForSolicitedSignalsUs); /* small yield for getting response */
double d;
status = m_impl->GetDgain(m_profile, d);
@@ -321,7 +363,7 @@ double CANTalon::GetF()
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
usleep(1000); /* small yield for getting response */
usleep(kDelayForSolicitedSignalsUs); /* small yield for getting response */
double f;
status = m_impl->GetFgain(m_profile, f);
if(status != CTR_OKAY) {
@@ -332,7 +374,7 @@ double CANTalon::GetF()
/**
* @see SelectProfileSlot to choose between the two sets of gains.
*/
double CANTalon::GetIzone()
int CANTalon::GetIzone()
{
CanTalonSRX::param_t param = m_profile ? CanTalonSRX::eProfileParamSlot1_IZone: CanTalonSRX::eProfileParamSlot0_IZone;
// Update the info in m_impl.
@@ -340,14 +382,14 @@ double CANTalon::GetIzone()
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
usleep(1000);
usleep(kDelayForSolicitedSignalsUs);
int iz;
status = m_impl->GetIzone(m_profile, iz);
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
return (double)iz;
return iz;
}
/**
@@ -499,7 +541,9 @@ double CANTalon::GetSpeed()
* Get the position of whatever is in the analog pin of the Talon, regardless of
* whether it is actually being used for feedback.
*
* @returns The value (0 - 1023) on the analog pin of the Talon.
* @returns The 24bit analog value. The bottom ten bits is the ADC (0 - 1023) on
* the analog pin of the Talon. The upper 14 bits
* tracks the overflows and underflows (continuous sensor).
*/
int CANTalon::GetAnalogIn()
{
@@ -510,7 +554,16 @@ int CANTalon::GetAnalogIn()
}
return position;
}
/**
* Get the position of whatever is in the analog pin of the Talon, regardless of
* whether it is actually being used for feedback.
*
* @returns The ADC (0 - 1023) on analog pin of the Talon.
*/
int CANTalon::GetAnalogInRaw()
{
return GetAnalogIn() & 0x3FF;
}
/**
* Get the position of whatever is in the analog pin of the Talon, regardless of
* whether it is actually being used for feedback.
@@ -835,7 +888,7 @@ uint32_t CANTalon::GetFirmwareVersion()
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
usleep(1000);
usleep(kDelayForSolicitedSignalsUs);
status = m_impl->GetParamResponseInt32(CanTalonSRX::eFirmVers,firmwareVersion);
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
@@ -858,7 +911,7 @@ int CANTalon::GetIaccum()
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
usleep(1000); /* small yield for getting response */
usleep(kDelayForSolicitedSignalsUs); /* small yield for getting response */
int iaccum;
status = m_impl->GetParamResponseInt32(CanTalonSRX::ePidIaccum,iaccum);
if(status != CTR_OKAY) {
@@ -899,7 +952,18 @@ void CANTalon::ConfigNeutralMode(NeutralMode mode)
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
/**
* @return nonzero if brake is enabled during neutral. Zero if coast is enabled during neutral.
*/
int CANTalon::GetBrakeEnableDuringNeutral()
{
int brakeEn = 0;
CTR_Code status = m_impl->GetBrakeIsEnabled(brakeEn);
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
return brakeEn;
}
/**
* TODO documentation (see CANJaguar.cpp)
*/
@@ -975,6 +1039,23 @@ void CANTalon::ConfigLimitMode(LimitMode mode)
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
break;
case kLimitMode_SrxDisableSwitchInputs: /** disable both limit switches and soft limits */
/* turn on both limits. SRX has individual enables and polarity for each limit switch.*/
status = m_impl->SetForwardSoftEnable(false);
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
status = m_impl->SetReverseSoftEnable(false);
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
/* override enable the limit switches, this circumvents the webdash */
status = m_impl->SetOverrideLimitSwitchEn(CanTalonSRX::kLimitSwitchOverride_DisableFwd_DisableRev);
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
break;
}
}
@@ -989,7 +1070,40 @@ void CANTalon::ConfigForwardLimit(double forwardLimitPosition)
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
/**
* Change the fwd limit switch setting to normally open or closed.
* Talon will disable momentarilly if the Talon's current setting
* is dissimilar to the caller's requested setting.
*
* Since Talon saves setting to flash this should only affect
* a given Talon initially during robot install.
*
* @param normallyOpen true for normally open. false for normally closed.
*/
void CANTalon::ConfigFwdLimitSwitchNormallyOpen(bool normallyOpen)
{
CTR_Code status = m_impl->SetParam(CanTalonSRX::eOnBoot_LimitSwitch_Forward_NormallyClosed, normallyOpen ? 0 : 1);
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
/**
* Change the rev limit switch setting to normally open or closed.
* Talon will disable momentarilly if the Talon's current setting
* is dissimilar to the caller's requested setting.
*
* Since Talon saves setting to flash this should only affect
* a given Talon initially during robot install.
*
* @param normallyOpen true for normally open. false for normally closed.
*/
void CANTalon::ConfigRevLimitSwitchNormallyOpen(bool normallyOpen)
{
CTR_Code status = m_impl->SetParam(CanTalonSRX::eOnBoot_LimitSwitch_Reverse_NormallyClosed, normallyOpen ? 0 : 1);
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
/**
* TODO documentation (see CANJaguar.cpp)
*/
@@ -1021,9 +1135,12 @@ void CANTalon::ConfigFaultTime(float faultTime)
}
/**
* TODO documentation (see CANJaguar.cpp)
* Fixup the sendMode so Set() serializes the correct demand value.
* Also fills the modeSelecet in the control frame to disabled.
* @param mode Control mode to ultimately enter once user calls Set().
* @see Set()
*/
void CANTalon::SetControlMode(CANSpeedController::ControlMode mode)
void CANTalon::ApplyControlMode(CANSpeedController::ControlMode mode)
{
m_controlMode = mode;
switch (mode) {
@@ -1052,6 +1169,17 @@ void CANTalon::SetControlMode(CANSpeedController::ControlMode mode)
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
/**
* TODO documentation (see CANJaguar.cpp)
*/
void CANTalon::SetControlMode(CANSpeedController::ControlMode mode)
{
if(m_controlMode == mode){
/* we already are in this mode, don't perform disable workaround */
}else{
ApplyControlMode(mode);
}
}
/**
* TODO documentation (see CANJaguar.cpp)

View File

@@ -15,7 +15,7 @@ void Compressor::InitCompressor(uint8_t pcmID) {
/**
* Constructor
*
* Uses the default solenoid module number
* Uses the default PCM ID (0)
*/
Compressor::Compressor() {
InitCompressor(GetDefaultSolenoidModule());
@@ -24,7 +24,7 @@ Compressor::Compressor() {
/**
* Constructor
*
* @param module The module number to use (1 or 2)
* @param module The PCM ID to use (0-62)
*/
Compressor::Compressor(uint8_t pcmID) {
InitCompressor(pcmID);
@@ -35,20 +35,21 @@ Compressor::~Compressor() {
}
/**
* Starts closed-loop control
* Starts closed-loop control. Note that closed loop control is enabled by default.
*/
void Compressor::Start() {
SetClosedLoopControl(true);
}
/**
* Stops closed-loop control
* Stops closed-loop control. Note that closed loop control is enabled by default.
*/
void Compressor::Stop() {
SetClosedLoopControl(false);
}
/**
* Check if compressor output is active
* @return true if the compressor is on
*/
bool Compressor::Enabled() {
@@ -65,6 +66,7 @@ bool Compressor::Enabled() {
}
/**
* Check if the pressure switch is triggered
* @return true if pressure is low
*/
bool Compressor::GetPressureSwitchValue() {
@@ -82,6 +84,7 @@ bool Compressor::GetPressureSwitchValue() {
/**
* Query how much current the compressor is drawing
* @return The current through the compressor, in amps
*/
float Compressor::GetCompressorCurrent() {
@@ -101,6 +104,7 @@ float Compressor::GetCompressorCurrent() {
/**
* Enables or disables automatically turning the compressor on when the
* pressure is low.
* @param on Set to true to enable closed loop control of the compressor. False to disable.
*/
void Compressor::SetClosedLoopControl(bool on) {
int32_t status = 0;
@@ -115,6 +119,7 @@ void Compressor::SetClosedLoopControl(bool on) {
/**
* Returns true if the compressor will automatically turn on when the
* pressure is low.
* @return True if closed loop control of the compressor is enabled. False if disabled.
*/
bool Compressor::GetClosedLoopControl() {
int32_t status = 0;
@@ -129,6 +134,132 @@ bool Compressor::GetClosedLoopControl() {
return value;
}
/**
* Query if the compressor output has been disabled due to high current draw.
* @return true if PCM is in fault state : Compressor Drive is
* disabled due to compressor current being too high.
*/
bool Compressor::GetCompressorCurrentTooHighFault() {
int32_t status = 0;
bool value;
value = getCompressorCurrentTooHighFault(m_pcm_pointer, &status);
if(status) {
wpi_setWPIError(Timeout);
}
return value;
}
/**
* Query if the compressor output has been disabled due to high current draw (sticky).
* A sticky fault will not clear on device reboot, it must be cleared through code or the webdash.
* @return true if PCM sticky fault is set : Compressor Drive is
* disabled due to compressor current being too high.
*/
bool Compressor::GetCompressorCurrentTooHighStickyFault() {
int32_t status = 0;
bool value;
value = getCompressorCurrentTooHighStickyFault(m_pcm_pointer, &status);
if(status) {
wpi_setWPIError(Timeout);
}
return value;
}
/**
* Query if the compressor output has been disabled due to a short circuit (sticky).
* A sticky fault will not clear on device reboot, it must be cleared through code or the webdash.
* @return true if PCM sticky fault is set : Compressor output
* appears to be shorted.
*/
bool Compressor::GetCompressorShortedStickyFault() {
int32_t status = 0;
bool value;
value = getCompressorShortedStickyFault(m_pcm_pointer, &status);
if(status) {
wpi_setWPIError(Timeout);
}
return value;
}
/**
* Query if the compressor output has been disabled due to a short circuit.
* @return true if PCM is in fault state : Compressor output
* appears to be shorted.
*/
bool Compressor::GetCompressorShortedFault() {
int32_t status = 0;
bool value;
value = getCompressorShortedFault(m_pcm_pointer, &status);
if(status) {
wpi_setWPIError(Timeout);
}
return value;
}
/**
* Query if the compressor output does not appear to be wired (sticky).
* A sticky fault will not clear on device reboot, it must be cleared through code or the webdash.
* @return true if PCM sticky fault is set : Compressor does not
* appear to be wired, i.e. compressor is
* not drawing enough current.
*/
bool Compressor::GetCompressorNotConnectedStickyFault() {
int32_t status = 0;
bool value;
value = getCompressorNotConnectedStickyFault(m_pcm_pointer, &status);
if(status) {
wpi_setWPIError(Timeout);
}
return value;
}
/**
* Query if the compressor output does not appear to be wired.
* @return true if PCM is in fault state : Compressor does not
* appear to be wired, i.e. compressor is
* not drawing enough current.
*/
bool Compressor::GetCompressorNotConnectedFault() {
int32_t status = 0;
bool value;
value = getCompressorNotConnectedFault(m_pcm_pointer, &status);
if(status) {
wpi_setWPIError(Timeout);
}
return value;
}
/**
* Clear ALL sticky faults inside PCM that Compressor is wired to.
*
* If a sticky fault is set, then it will be persistently cleared. Compressor drive
* maybe momentarily disable while flags are being cleared. Care should be
* taken to not call this too frequently, otherwise normal compressor
* functionality may be prevented.
*
* If no sticky faults are set then this call will have no effect.
*/
void Compressor::ClearAllPCMStickyFaults() {
int32_t status = 0;
clearAllPCMStickyFaults(m_pcm_pointer, &status);
if(status) {
wpi_setWPIError(Timeout);
}
}
void Compressor::UpdateTable() {
if(m_table) {
m_table->PutBoolean("Enabled", Enabled());

View File

@@ -13,7 +13,7 @@
/**
* Get the input voltage to the robot controller
* @return The controller input voltage value
* @return The controller input voltage value in Volts
*/
double ControllerPower::GetInputVoltage() {
int32_t status = 0;
@@ -24,7 +24,7 @@ double ControllerPower::GetInputVoltage() {
/**
* Get the input current to the robot controller
* @return The controller input current value
* @return The controller input current value in Amps
*/
double ControllerPower::GetInputCurrent() {
int32_t status = 0;
@@ -35,7 +35,7 @@ double ControllerPower::GetInputCurrent() {
/**
* Get the voltage of the 6V rail
* @return The controller 6V rail voltage value
* @return The controller 6V rail voltage value in Volts
*/
double ControllerPower::GetVoltage6V() {
int32_t status = 0;
@@ -46,7 +46,7 @@ double ControllerPower::GetVoltage6V() {
/**
* Get the current output of the 6V rail
* @return The controller 6V rail output current value
* @return The controller 6V rail output current value in Amps
*/
double ControllerPower::GetCurrent6V() {
int32_t status = 0;
@@ -58,7 +58,7 @@ double ControllerPower::GetCurrent6V() {
/**
* Get the enabled state of the 6V rail. The rail may be disabled due to a controller
* brownout, a short circuit on the rail, or controller over-voltage
* @return The controller 6V rail enabled value
* @return The controller 6V rail enabled value. True for enabled.
*/
bool ControllerPower::GetEnabled6V() {
int32_t status = 0;
@@ -69,7 +69,7 @@ bool ControllerPower::GetEnabled6V() {
/**
* Get the count of the total current faults on the 6V rail since the controller has booted
* @return The number of faults
* @return The number of faults.
*/
int ControllerPower::GetFaultCount6V() {
int32_t status = 0;
@@ -80,6 +80,7 @@ int ControllerPower::GetFaultCount6V() {
/**
* Get the voltage of the 5V rail
* @return The controller 5V rail voltage value in Volts
*/
double ControllerPower::GetVoltage5V() {
int32_t status = 0;
@@ -90,6 +91,7 @@ double ControllerPower::GetVoltage5V() {
/**
* Get the current output of the 5V rail
* @return The controller 5V rail output current value in Amps
*/
double ControllerPower::GetCurrent5V() {
int32_t status = 0;
@@ -101,7 +103,7 @@ double ControllerPower::GetCurrent5V() {
/**
* Get the enabled state of the 5V rail. The rail may be disabled due to a controller
* brownout, a short circuit on the rail, or controller over-voltage
* @return The controller 5V rail enabled value
* @return The controller 5V rail enabled value. True for enabled.
*/
bool ControllerPower::GetEnabled5V() {
int32_t status = 0;
@@ -123,6 +125,7 @@ int ControllerPower::GetFaultCount5V() {
/**
* Get the voltage of the 3.3V rail
* @return The controller 3.3V rail voltage value in Volts
*/
double ControllerPower::GetVoltage3V3() {
int32_t status = 0;
@@ -133,6 +136,7 @@ double ControllerPower::GetVoltage3V3() {
/**
* Get the current output of the 3.3V rail
* @return The controller 3.3V rail output current value in Amps
*/
double ControllerPower::GetCurrent3V3() {
int32_t status = 0;
@@ -145,7 +149,7 @@ double ControllerPower::GetCurrent3V3() {
/**
* Get the enabled state of the 3.3V rail. The rail may be disabled due to a controller
* brownout, a short circuit on the rail, or controller over-voltage
* @return The controller 3.3V rail enabled value
* @return The controller 3.3V rail enabled value. True for enabled.
*/
bool ControllerPower::GetEnabled3V3() {
int32_t status = 0;

View File

@@ -16,14 +16,15 @@
* This creates a ChipObject counter and initializes status variables appropriately
*
* The counter will start counting immediately.
* @param mode The counter mode
*/
void Counter::InitCounter(Mode mode)
{
m_table = NULL;
int32_t status = 0;
uint32_t index = 0;
m_counter = initializeCounter(mode, &index, &status);
m_index = 0;
m_counter = initializeCounter(mode, &m_index, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
m_upSource = NULL;
@@ -31,12 +32,14 @@ void Counter::InitCounter(Mode mode)
m_allocatedUpSource = false;
m_allocatedDownSource = false;
HALReport(HALUsageReporting::kResourceType_Counter, index, mode);
SetMaxPeriod(.5);
HALReport(HALUsageReporting::kResourceType_Counter, m_index, mode);
}
/**
* Create an instance of a counter where no sources are selected.
* Then they all must be selected by calling functions to specify the upsource and the downsource
* They all must be selected by calling functions to specify the upsource and the downsource
* independently.
*
* The counter will start counting immediately.
@@ -50,11 +53,12 @@ Counter::Counter() :
}
/**
* Create an instance of a counter from a Digital Input.
* Create an instance of a counter from a Digital Source (such as a Digital Input).
* This is used if an existing digital input is to be shared by multiple other objects such
* as encoders.
* as encoders or if the Digital Source is not a Digital Input channel (such as an Analog Trigger).
*
* The counter will start counting immediately.
* @param source A pointer to the existing DigitalSource object. It will be set as the Up Source.
*/
Counter::Counter(DigitalSource *source) :
m_upSource(NULL),
@@ -66,6 +70,14 @@ Counter::Counter(DigitalSource *source) :
ClearDownSource();
}
/**
* Create an instance of a counter from a Digital Source (such as a Digital Input).
* This is used if an existing digital input is to be shared by multiple other objects such
* as encoders or if the Digital Source is not a Digital Input channel (such as an Analog Trigger).
*
* The counter will start counting immediately.
* @param source A reference to the existing DigitalSource object. It will be set as the Up Source.
*/
Counter::Counter(DigitalSource &source) :
m_upSource(NULL),
m_downSource(NULL),
@@ -81,6 +93,7 @@ Counter::Counter(DigitalSource &source) :
* Create an up-Counter instance given a channel.
*
* The counter will start counting immediately.
* @param channel The DIO channel to use as the up source. 0-9 are on-board, 10-25 are on the MXP
*/
Counter::Counter(int32_t channel) :
m_upSource(NULL),
@@ -98,6 +111,7 @@ Counter::Counter(int32_t channel) :
* Use the trigger state output from the analog trigger.
*
* The counter will start counting immediately.
* @param trigger The pointer to the existing AnalogTrigger object.
*/
Counter::Counter(AnalogTrigger *trigger) :
m_upSource(NULL),
@@ -110,6 +124,14 @@ Counter::Counter(AnalogTrigger *trigger) :
m_allocatedUpSource = true;
}
/**
* Create an instance of a Counter object.
* Create an instance of a simple up-Counter given an analog trigger.
* Use the trigger state output from the analog trigger.
*
* The counter will start counting immediately.
* @param trigger The reference to the existing AnalogTrigger object.
*/
Counter::Counter(AnalogTrigger &trigger) :
m_upSource(NULL),
m_downSource(NULL),
@@ -121,6 +143,15 @@ Counter::Counter(AnalogTrigger &trigger) :
m_allocatedUpSource = true;
}
/**
* Create an instance of a Counter object.
* Creates a full up-down counter given two Digital Sources
* @param encodingType The quadrature decoding mode (1x or 2x)
* @param upSource The pointer to the DigitalSource to set as the up source
* @param downSource The pointer to the DigitalSource to set as the down source
* @param inverted True to invert the output (reverse the direction)
*/
Counter::Counter(EncodingType encodingType, DigitalSource *upSource, DigitalSource *downSource, bool inverted) :
m_upSource(NULL),
m_downSource(NULL),
@@ -176,6 +207,7 @@ Counter::~Counter()
/**
* Set the upsource for the counter as a digital input channel.
* @param channel The DIO channel to use as the up source. 0-9 are on-board, 10-25 are on the MXP
*/
void Counter::SetUpSource(int32_t channel)
{
@@ -209,6 +241,7 @@ void Counter::SetUpSource(AnalogTrigger &analogTrigger, AnalogTriggerType trigge
/**
* Set the source object that causes the counter to count up.
* Set the up counting DigitalSource.
* @param source Pointer to the DigitalSource object to set as the up source
*/
void Counter::SetUpSource(DigitalSource *source)
{
@@ -236,6 +269,7 @@ void Counter::SetUpSource(DigitalSource *source)
/**
* Set the source object that causes the counter to count up.
* Set the up counting DigitalSource.
* @param source Reference to the DigitalSource object to set as the up source
*/
void Counter::SetUpSource(DigitalSource &source)
{
@@ -244,7 +278,9 @@ void Counter::SetUpSource(DigitalSource &source)
/**
* Set the edge sensitivity on an up counting source.
* Set the up source to either detect rising edges or falling edges.
* Set the up source to either detect rising edges or falling edges or both.
* @param risingEdge True to trigger on rising edges
* @param fallingEdge True to trigger on falling edges
*/
void Counter::SetUpSourceEdge(bool risingEdge, bool fallingEdge)
{
@@ -277,6 +313,7 @@ void Counter::ClearUpSource()
/**
* Set the down counting source to be a digital input channel.
* @param channel The DIO channel to use as the up source. 0-9 are on-board, 10-25 are on the MXP
*/
void Counter::SetDownSource(int32_t channel)
{
@@ -310,6 +347,7 @@ void Counter::SetDownSource(AnalogTrigger &analogTrigger, AnalogTriggerType trig
/**
* Set the source object that causes the counter to count down.
* Set the down counting DigitalSource.
* @param source Pointer to the DigitalSource object to set as the down source
*/
void Counter::SetDownSource(DigitalSource *source)
{
@@ -337,6 +375,7 @@ void Counter::SetDownSource(DigitalSource *source)
/**
* Set the source object that causes the counter to count down.
* Set the down counting DigitalSource.
* @param source Reference to the DigitalSource object to set as the down source
*/
void Counter::SetDownSource(DigitalSource &source)
{
@@ -346,6 +385,8 @@ void Counter::SetDownSource(DigitalSource &source)
/**
* Set the edge sensitivity on a down counting source.
* Set the down source to either detect rising edges or falling edges.
* @param risingEdge True to trigger on rising edges
* @param fallingEdge True to trigger on falling edges
*/
void Counter::SetDownSourceEdge(bool risingEdge, bool fallingEdge)
{
@@ -484,11 +525,11 @@ void Counter::Reset()
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
/*
/**
* Get the Period of the most recent count.
* Returns the time interval of the most recent count. This can be used for velocity calculations
* to determine shaft speed.
* @returns The period of the last two pulses in units of seconds.
* @returns The period between the last two pulses in units of seconds.
*/
double Counter::GetPeriod()
{
@@ -525,6 +566,7 @@ void Counter::SetMaxPeriod(double maxPeriod)
* output (except when there have been no events since an FPGA reset) and you will likely not
* see the stopped bit become true (since it is updated at the end of an average and there are
* no samples to average).
* @param enabled True to enable update when empty
*/
void Counter::SetUpdateWhenEmpty(bool enabled)
{

View File

@@ -40,7 +40,7 @@ void DigitalInput::InitDigitalInput(uint32_t channel)
* Create an instance of a Digital Input class.
* Creates a digital input given a channel.
*
* @param channel The digital channel (0..19).
* @param channel The DIO channel 0-9 are on-board, 10-25 are on the MXP port
*/
DigitalInput::DigitalInput(uint32_t channel)
{
@@ -67,7 +67,7 @@ DigitalInput::~DigitalInput()
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
/*
/**
* Get the value from a digital input channel.
* Retrieve the value of a single digital input channel from the FPGA.
*/

View File

@@ -39,7 +39,7 @@ void DigitalOutput::InitDigitalOutput(uint32_t channel)
* Create an instance of a digital output.
* Create a digital output given a channel.
*
* @param channel The digital channel (0..19)
* @param channel The digital channel 0-9 are on-board, 10-25 are on the MXP port
*/
DigitalOutput::DigitalOutput(uint32_t channel)
{
@@ -63,6 +63,7 @@ DigitalOutput::~DigitalOutput()
/**
* Set the value of a digital output.
* Set the value of a digital output to either one (true) or zero (false).
* @param value 1 (true) for high, 0 (false) for disabled
*/
void DigitalOutput::Set(uint32_t value)
{

View File

@@ -10,7 +10,7 @@
#include "LiveWindow/LiveWindow.h"
/**
* Common function to implement constructor behavior.
* Common function to implement constructor behaviour.
*/
void DoubleSolenoid::InitSolenoid()
{
@@ -59,9 +59,9 @@ void DoubleSolenoid::InitSolenoid()
/**
* Constructor.
*
* @param forwardChannel The forward channel on the module to control.
* @param reverseChannel The reverse channel on the module to control.
* Uses the default PCM ID of 0
* @param forwardChannel The forward channel number on the PCM.
* @param reverseChannel The reverse channel number on the PCM.
*/
DoubleSolenoid::DoubleSolenoid(uint32_t forwardChannel, uint32_t reverseChannel)
: SolenoidBase (GetDefaultSolenoidModule())
@@ -101,7 +101,7 @@ DoubleSolenoid::~DoubleSolenoid()
/**
* Set the value of a solenoid.
*
* @param value Move the solenoid to forward, reverse, or don't move it.
* @param value The value to set (Off, Forward or Reverse)
*/
void DoubleSolenoid::Set(Value value)
{
@@ -138,6 +138,32 @@ DoubleSolenoid::Value DoubleSolenoid::Get()
if (value & m_reverseMask) return kReverse;
return kOff;
}
/**
* Check if the forward solenoid is blacklisted.
* If a solenoid is shorted, it is added to the blacklist and
* disabled until power cycle, or until faults are cleared.
* @see ClearAllPCMStickyFaults()
*
* @return If solenoid is disabled due to short.
*/
bool DoubleSolenoid::IsFwdSolenoidBlackListed()
{
int blackList = GetPCMSolenoidBlackList();
return (blackList & m_forwardMask) ? 1 : 0;
}
/**
* Check if the reverse solenoid is blacklisted.
* If a solenoid is shorted, it is added to the blacklist and
* disabled until power cycle, or until faults are cleared.
* @see ClearAllPCMStickyFaults()
*
* @return If solenoid is disabled due to short.
*/
bool DoubleSolenoid::IsRevSolenoidBlackListed()
{
int blackList = GetPCMSolenoidBlackList();
return (blackList & m_reverseMask) ? 1 : 0;
}
void DoubleSolenoid::ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew) {
Value lvalue = kOff;

View File

@@ -116,6 +116,7 @@ void DriverStation::Run()
/**
* Return a pointer to the singleton DriverStation.
* @return Pointer to the DS instance
*/
DriverStation* DriverStation::GetInstance()
{
@@ -146,7 +147,7 @@ void DriverStation::GetData()
/**
* Read the battery voltage.
*
* @return The battery voltage.
* @return The battery voltage in Volts.
*/
float DriverStation::GetBatteryVoltage()
{
@@ -157,6 +158,10 @@ float DriverStation::GetBatteryVoltage()
return voltage;
}
/**
* Reports errors related to unplugged joysticks
* Throttles the errors so that they don't overwhelm the DS
*/
void DriverStation::ReportJoystickUnpluggedError(std::string message) {
double currentTime = Timer::GetFPGATimestamp();
if (currentTime > m_nextMessageTime) {
@@ -165,10 +170,11 @@ void DriverStation::ReportJoystickUnpluggedError(std::string message) {
}
}
/** Returns the number of axis on a given joystick port
/**
* Returns the number of axes on a given joystick port
*
* @param stick The joystick port number
* @return the number of axis on the indicated joystick
* @return The number of axes on the indicated joystick
*/
int DriverStation::GetStickAxisCount(uint32_t stick)
{
@@ -182,10 +188,11 @@ int DriverStation::GetStickAxisCount(uint32_t stick)
return joystickAxes.count;
}
/** Returns the number of POVs on a given joystick port
/**
* Returns the number of POVs on a given joystick port
*
* @param stick The joystick port number
* @return thenumber of POVs on the indicated joystick
* @return The number of POVs on the indicated joystick
*/
int DriverStation::GetStickPOVCount(uint32_t stick)
{
@@ -199,7 +206,8 @@ int DriverStation::GetStickPOVCount(uint32_t stick)
return joystickPOVs.count;
}
/** Returns the number of buttons on a given joystick port
/**
* Returns the number of buttons on a given joystick port
*
* @param stick The joystick port number
* @return The number of buttons on the indicated joystick
@@ -283,6 +291,24 @@ int DriverStation::GetStickPOV(uint32_t stick, uint32_t pov) {
* @param stick The joystick to read.
* @return The state of the buttons on the joystick.
*/
uint32_t DriverStation::GetStickButtons(uint32_t stick)
{
if (stick >= kJoystickPorts)
{
wpi_setWPIError(BadJoystickIndex);
return 0;
}
return m_joystickButtons[stick].buttons;
}
/**
* The state of one joystick button. Button indexes begin at 1.
*
* @param stick The joystick to read.
* @param button The button index, beginning at 1.
* @return The state of the joystick button.
*/
bool DriverStation::GetStickButton(uint32_t stick, uint8_t button)
{
if (stick >= kJoystickPorts)
@@ -304,6 +330,10 @@ bool DriverStation::GetStickButton(uint32_t stick, uint8_t button)
return ((0x1 << (button-1)) & m_joystickButtons[stick].buttons) !=0;
}
/**
* Check if the DS has enabled the robot
* @return True if the robot is enabled and the DS is connected
*/
bool DriverStation::IsEnabled()
{
HALControlWord controlWord;
@@ -312,6 +342,10 @@ bool DriverStation::IsEnabled()
return controlWord.enabled && controlWord.dsAttached;
}
/**
* Check if the robot is disabled
* @return True if the robot is explicitly disabled or the DS is not connected
*/
bool DriverStation::IsDisabled()
{
HALControlWord controlWord;
@@ -320,6 +354,10 @@ bool DriverStation::IsDisabled()
return !(controlWord.enabled && controlWord.dsAttached);
}
/**
* Check if the DS is commanding autonomous mode
* @return True if the robot is being commanded to be in autonomous mode
*/
bool DriverStation::IsAutonomous()
{
HALControlWord controlWord;
@@ -328,6 +366,10 @@ bool DriverStation::IsAutonomous()
return controlWord.autonomous;
}
/**
* Check if the DS is commanding teleop mode
* @return True if the robot is being commanded to be in teleop mode
*/
bool DriverStation::IsOperatorControl()
{
HALControlWord controlWord;
@@ -336,6 +378,10 @@ bool DriverStation::IsOperatorControl()
return !(controlWord.autonomous || controlWord.test);
}
/**
* Check if the DS is commanding test mode
* @return True if the robot is being commanded to be in test mode
*/
bool DriverStation::IsTest()
{
HALControlWord controlWord;
@@ -343,6 +389,10 @@ bool DriverStation::IsTest()
return controlWord.test;
}
/**
* Check if the DS is attached
* @return True if the DS is connected to the robot
*/
bool DriverStation::IsDSAttached()
{
HALControlWord controlWord;
@@ -351,6 +401,11 @@ bool DriverStation::IsDSAttached()
return controlWord.dsAttached;
}
/**
* Check if the FPGA outputs are enabled. The outputs may be disabled if the robot is disabled
* or e-stopped, the watchdog has expired, or if the roboRIO browns out.
* @return True if the FPGA outputs are enabled.
*/
bool DriverStation::IsSysActive()
{
int32_t status = 0;
@@ -359,6 +414,10 @@ bool DriverStation::IsSysActive()
return retVal;
}
/**
* Check if the system is browned out.
* @return True if the system is browned out
*/
bool DriverStation::IsSysBrownedOut()
{
int32_t status = 0;
@@ -370,7 +429,7 @@ bool DriverStation::IsSysBrownedOut()
/**
* Has a new control packet from the driver station arrived since the last time this function was called?
* Warning: If you call this function from more than one place at the same time,
* you will not get the get the intended behavior
* you will not get the get the intended behaviour.
* @return True if the control data has been updated since the last call.
*/
bool DriverStation::IsNewControlData()
@@ -380,7 +439,6 @@ bool DriverStation::IsNewControlData()
/**
* Is the driver station attached to a Field Management System?
* Note: This does not work with the Blue DS.
* @return True if the robot is competing on a field being controlled by a Field Management System
*/
bool DriverStation::IsFMSAttached()
@@ -393,7 +451,7 @@ bool DriverStation::IsFMSAttached()
/**
* Return the alliance that the driver station says it is on.
* This could return kRed or kBlue
* @return The Alliance enum
* @return The Alliance enum (kRed, kBlue or kInvalid)
*/
DriverStation::Alliance DriverStation::GetAlliance()
{
@@ -417,7 +475,7 @@ DriverStation::Alliance DriverStation::GetAlliance()
/**
* Return the driver station location on the field
* This could return 1, 2, or 3
* @return The location of the driver station
* @return The location of the driver station (1-3, 0 for invalid)
*/
uint32_t DriverStation::GetLocation()
{
@@ -451,13 +509,12 @@ void DriverStation::WaitForData()
/**
* Return the approximate match time
* The FMS does not currently send the official match time to the robots
* This returns the time since the enable signal sent from the Driver Station
* At the beginning of autonomous, the time is reset to 0.0 seconds
* At the beginning of teleop, the time is reset to +15.0 seconds
* If the robot is disabled, this returns 0.0 seconds
* Warning: This is not an official time (so it cannot be used to argue with referees)
* @return Match time in seconds since the beginning of autonomous
* The FMS does not send an official match time to the robots, but does send an approximate match time.
* The value will count down the time remaining in the current period (auto or teleop).
* Warning: This is not an official time (so it cannot be used to dispute ref calls or guarantee that a function
* will trigger before the match ends)
* The Practice Match function of the DS approximates the behaviour seen on the field.
* @return Time remaining in current match period (auto or teleop)
*/
double DriverStation::GetMatchTime()
{

View File

@@ -28,11 +28,12 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType)
{
m_table = NULL;
m_encodingType = encodingType;
int32_t index = 0;
m_index = 0;
switch (encodingType)
{
case k4X:
{
m_encodingScale = 4;
if (m_aSource->StatusIsFatal())
{
CloneError(m_aSource);
@@ -44,28 +45,32 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType)
return;
}
int32_t status = 0;
int32_t index = 0;
m_encoder = initializeEncoder(m_aSource->GetModuleForRouting(), m_aSource->GetChannelForRouting(),
m_aSource->GetAnalogTriggerForRouting(),
m_bSource->GetModuleForRouting(), m_bSource->GetChannelForRouting(),
m_bSource->GetAnalogTriggerForRouting(),
reverseDirection, &index, &status);
reverseDirection, &m_index, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
m_counter = NULL;
SetMaxPeriod(.5);
break;
}
case k1X:
case k2X:
{
m_encodingScale = encodingType == k1X ? 1 : 2;
m_counter = new Counter(m_encodingType, m_aSource, m_bSource, reverseDirection);
index = m_counter->GetIndex();
m_index = m_counter->GetFPGAIndex();
break;
}
default:
wpi_setErrorWithContext(-1, "Invalid encodingType argument");
break;
}
m_distancePerPulse = 1.0;
m_pidSource = kDistance;
HALReport(HALUsageReporting::kResourceType_Encoder, index, encodingType);
HALReport(HALUsageReporting::kResourceType_Encoder, m_index, encodingType);
LiveWindow::GetInstance()->AddSensor("Encoder", m_aSource->GetChannelForRouting(), this);
}
@@ -75,8 +80,8 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType)
*
* The counter will start counting immediately.
*
* @param aChannel The a channel digital input channel.
* @param bChannel The b channel digital input channel.
* @param aChannel The a channel DIO channel. 0-9 are on-board, 10-25 are on the MXP port
* @param bChannel The b channel DIO channel. 0-9 are on-board, 10-25 are on the MXP port
* @param reverseDirection represents the orientation of the encoder and inverts the output values
* if necessary so forward represents positive values.
* @param encodingType either k1X, k2X, or k4X to indicate 1X, 2X or 4X decoding. If 4X is
@@ -177,6 +182,12 @@ Encoder::~Encoder()
}
}
/**
* The encoding scale factor 1x, 2x, or 4x, per the requested encodingType.
* Used to divide raw edge counts down to spec'd counts.
*/
int32_t Encoder::GetEncodingScale() { return m_encodingScale; }
/**
* Gets the raw value from the encoder.
* The raw value is the actual count unscaled by the 1x, 2x, or 4x scale
@@ -231,7 +242,7 @@ void Encoder::Reset()
/**
* Returns the period of the most recent pulse.
* Returns the period of the most recent Encoder pulse in seconds.
* This method compenstates for the decoding type.
* This method compensates for the decoding type.
*
* @deprecated Use GetRate() in favor of this method. This returns unscaled periods and GetRate() scales using value from SetDistancePerPulse().
*

View File

@@ -23,8 +23,8 @@ void GearTooth::EnableDirectionSensing(bool directionSensitive)
/**
* Construct a GearTooth sensor given a channel.
*
* @param channel The GPIO channel that the sensor is connected to.
* @param directionSensitive Enable the pulse length decoding in hardware to specify count direction.
* @param channel The DIO channel that the sensor is connected to. 0-9 are on-board, 10-25 are on the MXP.
* @param directionSensitive True to enable the pulse length decoding in hardware to specify count direction.
*/
GearTooth::GearTooth(uint32_t channel, bool directionSensitive)
: Counter(channel)
@@ -35,10 +35,10 @@ GearTooth::GearTooth(uint32_t channel, bool directionSensitive)
/**
* Construct a GearTooth sensor given a digital input.
* This should be used when sharing digial inputs.
* This should be used when sharing digital inputs.
*
* @param source An object that fully descibes the input that the sensor is connected to.
* @param directionSensitive Enable the pulse length decoding in hardware to specify count direction.
* @param source A pointer to the existing DigitalSource object (such as a DigitalInput)
* @param directionSensitive True to enable the pulse length decoding in hardware to specify count direction.
*/
GearTooth::GearTooth(DigitalSource *source, bool directionSensitive)
: Counter(source)
@@ -46,6 +46,13 @@ GearTooth::GearTooth(DigitalSource *source, bool directionSensitive)
EnableDirectionSensing(directionSensitive);
}
/**
* Construct a GearTooth sensor given a digital input.
* This should be used when sharing digital inputs.
*
* @param source A reference to the existing DigitalSource object (such as a DigitalInput)
* @param directionSensitive True to enable the pulse length decoding in hardware to specify count direction.
*/
GearTooth::GearTooth(DigitalSource &source, bool directionSensitive): Counter(source)
{
EnableDirectionSensing(directionSensitive);

View File

@@ -19,8 +19,8 @@ constexpr float Gyro::kDefaultVoltsPerDegreePerSecond;
/**
* Initialize the gyro.
* Calibrate the gyro by running for a number of samples and computing the center value for this
* part. Then use the center value as the Accumulator center value for subsequent measurements.
* Calibrate the gyro by running for a number of samples and computing the center value.
* Then use the center value as the Accumulator center value for subsequent measurements.
* It's important to make sure that the robot is not moving while the centering calculations are
* in progress, this is typically done when the robot is first turned on while it's sitting at
* rest before the competition starts.
@@ -71,9 +71,10 @@ void Gyro::InitGyro()
}
/**
* Gyro constructor with only a channel..
* Gyro constructor using the Analog Input channel number.
*
* @param channel The analog channel the gyro is connected to.
* @param channel The analog channel the gyro is connected to. Gyros
can only be used on on-board Analog Inputs 0-1.
*/
Gyro::Gyro(int32_t channel)
{
@@ -83,10 +84,11 @@ Gyro::Gyro(int32_t channel)
}
/**
* Gyro constructor with a precreated analog channel object.
* Use this constructor when the analog channel needs to be shared. There
* is no reference counting when an AnalogInput is passed to the gyro.
* @param channel The AnalogInput object that the gyro is connected to.
* Gyro constructor with a precreated AnalogInput object.
* Use this constructor when the analog channel needs to be shared.
* This object will not clean up the AnalogInput object when using this constructor.
* Gyros can only be used on on-board channels 0-1.
* @param channel A pointer to the AnalogInput object that the gyro is connected to.
*/
Gyro::Gyro(AnalogInput *channel)
{
@@ -102,6 +104,12 @@ Gyro::Gyro(AnalogInput *channel)
}
}
/**
* Gyro constructor with a precreated AnalogInput object.
* Use this constructor when the analog channel needs to be shared.
* This object will not clean up the AnalogInput object when using this constructor
* @param channel A reference to the AnalogInput object that the gyro is connected to.
*/
Gyro::Gyro(AnalogInput &channel)
{
m_analog = &channel;
@@ -133,8 +141,8 @@ Gyro::~Gyro()
*
* 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.
* The angle is continuous, that is it will continue from 360->361 degrees. This allows algorithms that wouldn't
* want to see a discontinuity in the gyro output as it sweeps from 360 to 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.
@@ -169,11 +177,12 @@ double Gyro::GetRate( void )
/**
* Set the gyro type based on the sensitivity.
* Set the gyro sensitivity.
* This takes the number of volts/degree/second sensitivity of the gyro and uses it in subsequent
* calculations to allow the code to work with multiple gyros.
* calculations to allow the code to work with multiple gyros. This value is typically found in
* the gyro datasheet.
*
* @param voltsPerDegreePerSecond The type of gyro specified as the voltage that represents one degree/second.
* @param voltsPerDegreePerSecond The sensitivity in Volts/degree/second
*/
void Gyro::SetSensitivity( float voltsPerDegreePerSecond )
{
@@ -193,6 +202,11 @@ void Gyro::SetDeadband( float volts ) {
m_analog->SetAccumulatorDeadband(deadband);
}
/**
* Sets the type of output to use with the WPILib PID class
* The gyro supports using either rate or angle for PID calculations
*/
void Gyro::SetPIDSourceParameter(PIDSourceParameter pidSource)
{
if(pidSource == 0 || pidSource > 2)
@@ -201,9 +215,10 @@ void Gyro::SetPIDSourceParameter(PIDSourceParameter pidSource)
}
/**
* Get the angle in degrees for the PIDSource base object.
* Get the PIDOutput for the PIDSource base object. Can be set to return
* angle or rate using SetPIDSourceParameter(). Defaults to angle.
*
* @return The angle in degrees.
* @return The PIDOutput (angle or rate, defaults to angle)
*/
double Gyro::PIDGet()
{

View File

@@ -12,7 +12,7 @@
/**
* Constructor.
*
* @param Port The I2C port to which the device is connected.
* @param port The I2C port to which the device is connected.
* @param deviceAddress The address of the device on the I2C bus.
*/
I2C::I2C(Port port, uint8_t deviceAddress) :

View File

@@ -101,7 +101,9 @@ void InterruptableSensorBase::CancelInterrupts()
}
/**
* In synchronous mode, wait for the defined interrupt to occur.
* In synchronous mode, wait for the defined interrupt to occur. You should <b>NOT</b> attempt to read the
* sensor from another thread while waiting for an interrupt. This is not threadsafe, and can cause
* memory corruption
* @param timeout Timeout in seconds
* @param ignorePrevious If true, ignore interrupts that happened before
* WaitForInterrupt was called.

View File

@@ -36,13 +36,15 @@ IterativeRobot::~IterativeRobot()
{
}
void IterativeRobot::Prestart() {
// Don't immediately say that the robot's ready to be enabled.
// See below.
}
/**
* Provide an alternate "main loop" via StartCompetition().
*
* This specific StartCompetition() implements "main loop" behavior like that of the FRC
* control system in 2008 and earlier, with a primary (slow) loop that is
* called periodically, and a "fast loop" (a.k.a. "spin loop") that is
* called as fast as possible with no delay between calls.
* This specific StartCompetition() implements "main loop" behaviour synced with the DS packets
*/
void IterativeRobot::StartCompetition()
{
@@ -54,6 +56,12 @@ void IterativeRobot::StartCompetition()
NetworkTable::GetTable("LiveWindow")->GetSubTable("~STATUS~")->PutBoolean("LW Enabled", false);
RobotInit();
// We call this now (not in Prestart like default) so that the robot
// won't enable until the initialization has finished. This is useful
// because otherwise it's sometimes possible to enable the robot
// before the code is ready.
HALNetworkCommunicationObserveUserProgramStarting();
// loop forever, calling the appropriate mode-dependent function
lw->SetEnabled(false);
while (true)

View File

@@ -14,7 +14,7 @@
*/
void Jaguar::InitJaguar()
{
/*
/**
* Input profile defined by Luminary Micro.
*
* Full reverse ranges from 0.671325ms to 0.6972211ms
@@ -33,7 +33,8 @@ void Jaguar::InitJaguar()
}
/**
* @param channel The PWM channel that the Jaguar is attached to.
* Constructor for a Jaguar connected via PWM
* @param channel The PWM channel that the Jaguar is attached to. 0-9 are on-board, 10-19 are on the MXP port
*/
Jaguar::Jaguar(uint32_t channel) : SafePWM(channel)
{

View File

@@ -24,7 +24,7 @@ static bool joySticksInitialized = false;
* Construct an instance of a joystick.
* The joystick index is the usb port on the drivers station.
*
* @param port The port on the driver station that the joystick is plugged into.
* @param port The port on the driver station that the joystick is plugged into (0-5).
*/
Joystick::Joystick(uint32_t port)
: m_ds (NULL)
@@ -221,12 +221,12 @@ bool Joystick::GetBumper(JoystickHand hand)
}
/**
* Get the button value for buttons 1 through 12.
* Get the button value (starting at button 1)
*
* The buttons are returned in a single 16 bit value with one bit representing the state
* of each button. The appropriate button is returned as a boolean value.
*
* @param button The button number to be read.
* @param button The button number to be read (starting at 1)
* @return The state of the button.
**/
bool Joystick::GetRawButton(uint32_t button)
@@ -237,6 +237,7 @@ bool Joystick::GetRawButton(uint32_t button)
/**
* Get the state of a POV on the joystick.
*
* @param pov The index of the POV to read (starting at 0)
* @return the angle of the POV in degrees, or -1 if the POV is not pressed.
*/
int Joystick::GetPOV(uint32_t pov) {

View File

@@ -56,7 +56,7 @@ MotorSafetyHelper::~MotorSafetyHelper()
}
}
/*
/**
* Feed the motor safety object.
* Resets the timer on this object that is used to do the timeouts.
*/
@@ -66,7 +66,7 @@ void MotorSafetyHelper::Feed()
m_stopTime = Timer::GetFPGATimestamp() + m_expiration;
}
/*
/**
* Set the expiration time for the corresponding motor safety object.
* @param expirationTime The timeout value in seconds.
*/
@@ -78,7 +78,7 @@ void MotorSafetyHelper::SetExpiration(float 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()
{
@@ -88,7 +88,7 @@ float MotorSafetyHelper::GetExpiration()
/**
* 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()
{
@@ -133,7 +133,7 @@ void MotorSafetyHelper::SetSafetyEnabled(bool 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()
{

View File

@@ -23,6 +23,7 @@ const int32_t PWM::kPwmDisabled;
* This method is private and is the common path for all the constructors for creating PWM
* instances. Checks channel value range and allocates the appropriate channel.
* The allocation is only done to help users ensure that they don't double assign channels.
* @param channel The PWM channel number. 0-9 are on-board, 10-19 are on the MXP port
*/
void PWM::InitPWM(uint32_t channel)
{

View File

@@ -7,14 +7,17 @@
#include "PowerDistributionPanel.h"
#include "WPIErrors.h"
#include "HAL/PDP.hpp"
#include "LiveWindow/LiveWindow.h"
/**
* Initialize the PDP.
*/
PowerDistributionPanel::PowerDistributionPanel() {
m_table=NULL;
}
/**
* Query the input voltage of the PDP
* @return The voltage of the PDP
*/
double
@@ -31,6 +34,7 @@ PowerDistributionPanel::GetVoltage() {
}
/**
* Query the temperature of the PDP
* @return The temperature of the PDP in degrees Celsius
*/
double
@@ -47,6 +51,7 @@ PowerDistributionPanel::GetTemperature() {
}
/**
* Query the current of a single channel of the PDP
* @return The current of one of the PDP channels (channels 0-15) in Amperes
*/
double
@@ -70,6 +75,7 @@ PowerDistributionPanel::GetCurrent(uint8_t channel) {
}
/**
* Query the total current of all monitored PDP channels (0-15)
* @return The the total current drawn from the PDP channels in Amperes
*/
double
@@ -86,6 +92,7 @@ PowerDistributionPanel::GetTotalCurrent() {
}
/**
* Query the total power drawn from the monitored PDP channels
* @return The the total power drawn from the PDP channels in Joules
*/
double
@@ -102,6 +109,7 @@ PowerDistributionPanel::GetTotalPower() {
}
/**
* Query the total energy drawn from the monitored PDP channels
* @return The the total energy drawn from the PDP channels in Watts
*/
double
@@ -146,3 +154,44 @@ PowerDistributionPanel::ClearStickyFaults() {
}
}
void PowerDistributionPanel::UpdateTable() {
if (m_table != NULL) {
m_table->PutNumber("Chan0", GetCurrent(0));
m_table->PutNumber("Chan1", GetCurrent(1));
m_table->PutNumber("Chan2", GetCurrent(2));
m_table->PutNumber("Chan3", GetCurrent(3));
m_table->PutNumber("Chan4", GetCurrent(4));
m_table->PutNumber("Chan5", GetCurrent(5));
m_table->PutNumber("Chan6", GetCurrent(6));
m_table->PutNumber("Chan7", GetCurrent(7));
m_table->PutNumber("Chan8", GetCurrent(8));
m_table->PutNumber("Chan9", GetCurrent(9));
m_table->PutNumber("Chan10", GetCurrent(10));
m_table->PutNumber("Chan11", GetCurrent(11));
m_table->PutNumber("Chan12", GetCurrent(12));
m_table->PutNumber("Chan13", GetCurrent(13));
m_table->PutNumber("Chan14", GetCurrent(14));
m_table->PutNumber("Chan15", GetCurrent(15));
m_table->PutNumber("Voltage", GetVoltage());
m_table->PutNumber("TotalCurrent", GetTotalCurrent());
}
}
void PowerDistributionPanel::StartLiveWindowMode() {
}
void PowerDistributionPanel::StopLiveWindowMode() {
}
std::string PowerDistributionPanel::GetSmartDashboardType() {
return "PowerDistributionPanel";
}
void PowerDistributionPanel::InitTable(ITable *subTable) {
m_table = subTable;
UpdateTable();
}
ITable * PowerDistributionPanel::GetTable() {
return m_table;
}

View File

@@ -16,6 +16,7 @@
#include "Utility.h"
#include <cstring>
#include "HAL/HAL.hpp"
#include <cstdio>
#ifdef __vxworks
// VXWorks needs som special unloading code
@@ -37,9 +38,15 @@ RobotBase &RobotBase::getInstance()
return *m_instance;
}
void RobotBase::robotSetup(RobotBase *robot)
{
robot->Prestart();
robot->StartCompetition();
}
/**
* Constructor for a generic robot program.
* User code should be placed in the constuctor that runs before the Autonomous or Operator
* User code should be placed in the constructor that runs before the Autonomous or Operator
* Control period starts. The constructor will run to completion before Autonomous is entered.
*
* This must be used to ensure that the communications code starts. In the future it would be
@@ -54,6 +61,13 @@ RobotBase::RobotBase()
HLUsageReporting::SetImplementation(new HardwareHLReporting()); \
RobotBase::setInstance(this);
FILE *file = NULL;
file = fopen("/tmp/frc_versions/FRC_Lib_Version.ini", "w");
fputs("2015 C++ 1.0.0", file);
if (file != NULL)
fclose(file);
}
/**
@@ -88,7 +102,7 @@ bool RobotBase::IsDisabled()
}
/**
* Determine if the robot is currently in Autnomous mode.
* Determine if the robot is currently in Autonomous mode.
* @return True if the robot is currently operating Autonomously as determined by the field controls.
*/
bool RobotBase::IsAutonomous()
@@ -114,6 +128,17 @@ bool RobotBase::IsTest()
return m_ds->IsTest();
}
/**
* This hook is called right before startCompetition(). By default, tell the DS that the robot is now ready to
* be enabled. If you don't want for the robot to be enabled yet, you can override this method to do nothing.
* If you do so, you will need to call HALNetworkCommunicationObserveUserProgramStarting() from your code when
* you are ready for the robot to be enabled.
*/
void RobotBase::Prestart()
{
HALNetworkCommunicationObserveUserProgramStarting();
}
/**
* Indicates if new data is available from the driver station.
* @return Has new data arrived over the network since the last time this function was called?

View File

@@ -43,12 +43,13 @@ void RobotDrive::InitRobotDrive() {
m_safetyHelper->SetSafetyEnabled(true);
}
/** Constructor for RobotDrive with 2 motors specified with channel numbers.
/**
* Constructor for RobotDrive with 2 motors specified with channel numbers.
* Set up parameters for a two wheel drive system where the
* left and right motor pwm channels are specified in the call.
* This call assumes Talons for controlling the motors.
* @param leftMotorChannel The PWM channel number that drives the left motor.
* @param rightMotorChannel The PWM channel number that drives the right motor.
* @param leftMotorChannel The PWM channel number that drives the left motor. 0-9 are on-board, 10-19 are on the MXP port
* @param rightMotorChannel The PWM channel number that drives the right motor. 0-9 are on-board, 10-19 are on the MXP port
*/
RobotDrive::RobotDrive(uint32_t leftMotorChannel, uint32_t rightMotorChannel)
{
@@ -68,10 +69,10 @@ RobotDrive::RobotDrive(uint32_t leftMotorChannel, uint32_t rightMotorChannel)
* Set up parameters for a four wheel drive system where all four motor
* pwm channels are specified in the call.
* This call assumes Talons for controlling the motors.
* @param frontLeftMotor Front left motor channel number
* @param rearLeftMotor Rear Left motor channel number
* @param frontRightMotor Front right motor channel number
* @param rearRightMotor Rear Right motor channel number
* @param frontLeftMotor Front left motor channel number. 0-9 are on-board, 10-19 are on the MXP port
* @param rearLeftMotor Rear Left motor channel number. 0-9 are on-board, 10-19 are on the MXP port
* @param frontRightMotor Front right motor channel number. 0-9 are on-board, 10-19 are on the MXP port
* @param rearRightMotor Rear Right motor channel number. 0-9 are on-board, 10-19 are on the MXP port
*/
RobotDrive::RobotDrive(uint32_t frontLeftMotor, uint32_t rearLeftMotor,
uint32_t frontRightMotor, uint32_t rearRightMotor)
@@ -94,7 +95,7 @@ RobotDrive::RobotDrive(uint32_t frontLeftMotor, uint32_t rearLeftMotor,
* The SpeedController version of the constructor enables programs to use the RobotDrive classes with
* subclasses of the SpeedController objects, for example, versions with ramping or reshaping of
* the curve to suit motor bias or deadband elimination.
* @param leftMotor The left SpeedController object used to drive the robot.
* @param leftMotor The left SpeedController object used to drive the robot.
* @param rightMotor the right SpeedController object used to drive the robot.
*/
RobotDrive::RobotDrive(SpeedController *leftMotor, SpeedController *rightMotor)

View File

@@ -39,7 +39,9 @@ SPI::~SPI()
/**
* Configure the rate of the generated clock signal.
* The default and maximum value is 500,000 Hz.
*
* The default value is 500,000Hz.
* The maximum value is 4,000,000Hz.
*
* @param hz The clock rate in Hertz.
*/

View File

@@ -19,7 +19,7 @@ void SafePWM::InitSafePWM()
/**
* Constructor for a SafePWM object taking a channel number.
* @param channel The PWM channel number (0..19).
* @param channel The PWM channel number 0-9 are on-board, 10-19 are on the MXP port
*/
SafePWM::SafePWM(uint32_t channel): PWM(channel)
{
@@ -31,7 +31,7 @@ SafePWM::~SafePWM()
delete m_safetyHelper;
}
/*
/**
* Set the expiration time for the PWM object
* @param timeout The timeout (in seconds) for this motor object
*/

View File

@@ -16,6 +16,7 @@
* Create an instance of a Serial Port class.
*
* @param baudRate The baud rate to configure the serial port.
* @param port The physical port to use
* @param dataBits The number of data bits per transfer. Valid values are between 5 and 8 bits.
* @param parity Select the type of parity checking to use.
* @param stopBits The number of stop bits to use as defined by the enum StopBits.
@@ -235,14 +236,4 @@ void SerialPort::Reset()
int32_t status = 0;
serialClear(m_port, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
//void SerialPort::_internalHandler(uint32_t port, uint32_t eventType, uint32_t event)
//{
//}
//ViStatus _VI_FUNCH ioCompleteHandler (ViSession vi, ViEventType eventType, ViEvent event, ViAddr userHandle)
//{
// ((SerialPort*) userHandle)->_internalHandler(vi, eventType, event);
// return VI_SUCCESS;
//}
}

View File

@@ -32,7 +32,7 @@ void Servo::InitServo()
}
/**
* @param channel The PWM channel to which the servo is attached.
* @param channel The PWM channel to which the servo is attached. 0-9 are on-board, 10-19 are on the MXP port
*/
Servo::Servo(uint32_t channel) : SafePWM(channel)
{

View File

@@ -42,9 +42,9 @@ void Solenoid::InitSolenoid()
}
/**
* Constructor.
* Constructor using the default PCM ID (0).
*
* @param channel The channel on the solenoid module to control (1..8).
* @param channel The channel on the PCM to control (0..7).
*/
Solenoid::Solenoid(uint32_t channel)
: SolenoidBase (GetDefaultSolenoidModule())
@@ -56,8 +56,8 @@ Solenoid::Solenoid(uint32_t channel)
/**
* Constructor.
*
* @param moduleNumber The solenoid module (1 or 2).
* @param channel The channel on the solenoid module to control (1..8).
* @param moduleNumber The CAN ID of the PCM the solenoid is attached to
* @param channel The channel on the PCM to control (0..7).
*/
Solenoid::Solenoid(uint8_t moduleNumber, uint32_t channel)
: SolenoidBase (moduleNumber)
@@ -102,7 +102,19 @@ bool Solenoid::Get()
uint8_t value = GetAll() & ( 1 << m_channel);
return (value != 0);
}
/**
* Check if solenoid is blacklisted.
* If a solenoid is shorted, it is added to the blacklist and
* disabled until power cycle, or until faults are cleared.
* @see ClearAllPCMStickyFaults()
*
* @return If solenoid is disabled due to short.
*/
bool Solenoid::IsBlackListed()
{
int value = GetPCMSolenoidBlackList() & ( 1 << m_channel);
return (value != 0);
}
void Solenoid::ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew) {
Set(value.b);

Some files were not shown because too many files have changed in this diff Show More