Compare commits

...

46 Commits

Author SHA1 Message Date
Vasista Vovveti
38611e9dd7 [hal] Fix REVPH Analog Pressure channel selection (#3716) 2021-11-10 18:22:18 -08:00
sciencewhiz
4d78def31e [wpilib] Add DeadbandElimination forwarding to PWMMotorController (#3714) 2021-11-09 21:24:47 -08:00
Tyler Veness
3be0c1217a [wpilibcExamples] Make GearsBot use idiomatic C++ (#3711)
Replace pointer constructor arguments with references, and const qualify
getters where possible.

Also remove redundant simulation P gain.

Fixes #1146.
2021-11-09 20:11:50 -08:00
Tyler Veness
42d3a50aa2 [hal] Check error codes during serial port initialization (#3712)
Throw if serial port init fails.

Fixes #2036.
2021-11-09 20:10:48 -08:00
PJ Reiniger
52f1464029 Add project with field images and their json config files (#3668) 2021-11-08 22:48:16 -08:00
Thad House
68ce62e2e9 [hal] Add autodetect for power modules (#3706)
Default autodetect to REV if no devices are found, as only the REV devices have control functionality (the switchable output).
2021-11-07 13:53:38 -08:00
Thad House
3dd41c0d37 [wpilib] Don't print PD errors for LiveWindow reads (#3708)
If something happens with the PD connection, these would have spammed messages continuously.
This wasn't the case previously, and we don't want this behavior now.
2021-11-07 13:45:28 -08:00
Thad House
7699a1f827 [hal] Fix sim not working with automatic PD type and default module (#3707) 2021-11-05 23:30:10 -07:00
Peter Johnson
e473a00f97 [wpiutil] Base64: Add unsigned span/vector variants (#3702) 2021-11-01 07:48:26 -07:00
Peter Johnson
52f2d580eb [wpiutil] raw_uv_ostream: Add reset() (#3701)
This enables reuse of a raw_uv_ostream object.
2021-11-01 07:47:13 -07:00
Peter Johnson
d7b1e3576f [wpiutil] WebSocket: move std::function (#3700) 2021-11-01 07:46:15 -07:00
sciencewhiz
93799fbe9d [examples] Fix description of TrapezoidProfileSubsystem (#3699) 2021-11-01 00:08:53 -07:00
Tyler Veness
b84644740d [wpimath] Document pose estimator states, inputs, and outputs (#3698)
Fixes #3244.
2021-10-29 17:37:13 -07:00
Tyler Veness
2dc35c1399 [wpimath] Fix classpaths for JNI class loads (#3697)
Found by inspecting the results of the following rg commands:
`rg --multiline 'FindClass\(\s*"'`
`rg 'JClass' -A 1`

Fixes #3660.
2021-10-29 16:23:46 -07:00
Tyler Veness
2cb171f6f5 [docs] Set Doxygen extract_all to true and fix Doxygen failures (#3695)
The template argument order for UnscentedTransform was reversed to match
all the other UKF classes. Since UnscentedTransform is intended as a
class for internal use only, this shouldn't cause much breakage.
2021-10-29 15:07:05 -07:00
Tyler Veness
a939cd9c89 [wpimath] Print uncontrollable/unobservable models in LQR and KF (#3694)
IsDetectable() was added to make the code easier to read.
2021-10-29 00:03:02 -07:00
Tyler Veness
d5270d113b [wpimath] Clean up C++ StateSpaceUtil tests (#3692) 2021-10-29 00:02:03 -07:00
Tyler Veness
b20903960b [wpimath] Remove redundant discretization tests from StateSpaceUtilTest (#3689)
DiscretizationTest already does these.
2021-10-29 00:01:41 -07:00
Tyler Veness
c0cb545b41 [wpilibc] Add deprecated Doxygen attribute to SpeedController (#3691)
Fixes #3690.
2021-10-29 00:01:04 -07:00
Tyler Veness
35c9f66a75 [wpilib] Rename PneumaticsHub to PneumaticHub (#3686)
Fixes #3684.
2021-10-29 00:00:31 -07:00
Tyler Veness
796d03d105 [wpiutil] Remove unused LLVM header (#3688) 2021-10-28 00:18:26 -07:00
Tyler Veness
8723caf78d [wpilibj] Make Java TrapezoidProfile.Constraints an immutable class (#3687) 2021-10-28 00:17:36 -07:00
Tyler Veness
187f50a344 [wpimath] Catch incorrect parameters to state-space models earlier (#3680)
This allows giving more descriptive exceptions than if they are thrown
later in KalmanFilter, for example.

Fixes #3678.
2021-10-27 20:18:57 -07:00
Tyler Veness
8d04606c4d Replace instances of frc-characterization with SysId (NFC) (#3681) 2021-10-27 06:40:17 -07:00
Peter Johnson
b82d4f6e58 [hal, cscore, ntcore] Use WPI common handle type base 2021-10-26 23:39:11 -07:00
Peter Johnson
87e34967ef [wpiutil] Add synchronization primitives
These enable more consistent use of synchronization across the
native libraries.  Users can create Event and Semaphore primitives, but
in addition, libraries can set up any handle as an Event-type signal.
2021-10-26 23:39:11 -07:00
Peter Johnson
e32499c546 [wpiutil] Add ParallelTcpConnector (#3655)
This is a libuv-based parallel, repeating TCP connector for making
multiple parallel DNS resolution and TCP connection attempts to a
network server.
2021-10-26 23:37:58 -07:00
Tyler Veness
aa0b49228d [wpilib] Remove redundant "quick turn" docs for curvature drive (NFC) (#3674)
The parameter docs for allowTurnInPlace say the same thing, and it's no
longer called "quick turn".
2021-10-26 23:37:11 -07:00
Noah Andrews
57301a7f9c [hal] REVPH: Start closed-loop compressor control on init (#3673)
Similar to the PCM, we're going to make the PH not do anything with the compressor until the PH HAL object has been initialized. The mechanism we're going to use to signal to the PH that that has happened is to begin sending the state of the solenoids (which will all be set to off at this point).
2021-10-26 23:36:47 -07:00
sciencewhiz
d1842ea8fb [wpilib] Improve interrupt docs (NFC) (#3679) 2021-10-26 23:35:01 -07:00
Peter Johnson
558151061e [wpiutil] Add DsClient (#3654)
This is a libuv-based implementation of the Driver Station client
for getting robot IPs from the Driver Station port 1742 server.
2021-10-26 23:34:27 -07:00
Tyler Veness
181723e573 Replace .to<double>() and .template to<double>() with .value() (#3667)
It's a less verbose way to do the same thing.
2021-10-25 08:58:12 -07:00
sciencewhiz
6bc1db44bc [commands] Add pointer overload of AddRequirements (artf6003) (#3669)
Also update documentation in CommandBase.
2021-10-25 08:57:22 -07:00
Tyler Veness
737b57ed5f [wpimath] Update to drake v0.35.0 (#3665) 2021-10-22 23:02:08 -07:00
Austin Shalit
4d287d1ae2 [build] Upgrade WPIJREArtifact to JRE 2022-11.0.12u5 (#3666) 2021-10-22 23:01:09 -07:00
apple
f26eb5ada4 [hal] Fix another typo (get -> gets) (NFC) (#3663) 2021-10-22 11:49:21 -07:00
apple
94ed275ba6 [hal] Fix misspelling (numer -> number) (NFC) (#3662) 2021-10-22 07:23:13 -07:00
Peter Johnson
ac2f44da33 [wpiutil] uv: use move for std::function (#3653)
Also use function_ref for Loop::Walk().
2021-10-20 23:24:59 -07:00
Peter Johnson
75fa1fbfbf [wpiutil] json::serializer: Optimize construction (#3647)
Remove unused locale pointer.
2021-10-20 21:09:04 -07:00
Peter Johnson
5e689faea8 [wpiutil] Import MessagePack implementation (mpack) (#3650) 2021-10-20 21:08:31 -07:00
Peter Johnson
649a50b401 [wpiutil] Add LEB128 byte-by-byte reader (#3652)
This is needed for compatibility with streaming data (e.g. libuv) where partial data
may be received.  Also add raw_ostream writer.
2021-10-20 18:50:20 -07:00
Peter Johnson
e94397a97d [wpiutil] Move json_serializer.h to public headers (#3646)
This makes it possible to do "manual" JSON-compliant serialization more efficiently
(e.g. without needing to construct a full json object).
2021-10-20 11:18:13 -07:00
Peter Johnson
4ec58724d7 [wpiutil] uv::Tcp: Clarify SetNoDelay documentation (#3649) 2021-10-20 08:46:44 -07:00
Peter Johnson
8cb294aa4a [wpiutil] WebSocket: Make Shutdown() public (#3651) 2021-10-20 08:45:58 -07:00
Peter Johnson
2b3a9a52b3 [wpiutil] json: Fix map iterator key() for std::string_view (#3645) 2021-10-20 08:45:16 -07:00
Peter Johnson
138cbb94b2 [wpiutil] uv::Async: Add direct call for no-parameter specialization (#3648) 2021-10-20 08:44:33 -07:00
327 changed files with 20246 additions and 1659 deletions

View File

@@ -16,6 +16,7 @@ modifiableFileExclude {
generatedFileExclude {
FRCNetComm\.java$
simulation/gz_msgs/src/include/simulation/gz_msgs/msgs\.h$
fieldImages/src/main/native/resources/
}
repoRootNameOverride {

View File

@@ -239,6 +239,7 @@ if (WITH_TESTS)
include(GoogleTest)
endif()
add_subdirectory(fieldImages)
add_subdirectory(wpiutil)
add_subdirectory(ntcore)

View File

@@ -32,6 +32,8 @@ sigslot wpiutil/src/main/native/include/wpi/Signal.h
wpiutil/src/test/native/cpp/sigslot/
tcpsockets wpiutil/src/main/native/cpp/TCP{Stream,Connector,Acceptor}.cpp
wpiutil/src/main/native/include/wpi/TCP*.h
MPack wpiutil/src/main/native/include/mpack.h
wpiutil/src/main/native/cpp/mpack.cpp
Bootstrap wpiutil/src/main/native/resources/bootstrap-*
CoreUI wpiutil/src/main/native/resources/coreui-*
Feather Icons wpiutil/src/main/native/resources/feather-*
@@ -235,6 +237,32 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================
MPacks License
==============================================================================
The MIT License (MIT)
Copyright (c) 2015-2021 Nicholas Fraser and the MPack authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
==============================================================================
Bootstrap License
==============================================================================

View File

@@ -24,7 +24,7 @@ public class WPIJREArtifact extends MavenArtifact {
this.configName = configName;
Project project = target.getProject();
getConfiguration().set(project.getConfigurations().create(configName));
getDependency().set(project.getDependencies().add(configName, "edu.wpi.first.jdk:roborio-2022:11.0.9u12-1"));
getDependency().set(project.getDependencies().add(configName, "edu.wpi.first.jdk:roborio-2022:11.0.12u5-1"));
setOnlyIf(new PredicateWrapper({ DeployContext ctx ->
return jreMissing(ctx) || project.hasProperty("force-redeploy-jre");

View File

@@ -5,6 +5,8 @@
#ifndef CSCORE_HANDLE_H_
#define CSCORE_HANDLE_H_
#include <wpi/Synchronization.h>
#include "cscore_c.h"
namespace cs {
@@ -18,7 +20,7 @@ class Handle {
public:
enum Type {
kUndefined = 0,
kProperty = 0x40,
kProperty = wpi::kHandleTypeCSBase,
kSource,
kSink,
kListener,

View File

@@ -84,7 +84,6 @@ doxygen {
exclude 'wpi/FunctionExtras.h'
exclude 'wpi/function_ref.h'
exclude 'wpi/Hashing.h'
exclude 'wpi/IntrusiveRefCntPtr.h'
exclude 'wpi/iterator.h'
exclude 'wpi/iterator_range.h'
exclude 'wpi/ManagedStatic.h'
@@ -118,12 +117,16 @@ doxygen {
// json
exclude 'wpi/json.h'
// mpack
exclude 'wpi/mpack.h'
// units
exclude 'units/**'
}
case_sense_names false
extension_mapping 'inc=C++'
extract_all true
extract_static true
full_path_names true
generate_html true

View File

@@ -0,0 +1,37 @@
project(fieldImages)
include(CompileWarnings)
include(GenResources)
if (WITH_JAVA)
find_package(Java REQUIRED)
include(UseJava)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
file(GLOB_RECURSE JAVA_RESOURCES src/main/native/resources/*.json src/main/native/resources/*.png src/main/native/resources/*.jpg)
add_jar(field_images_jar SOURCES ${JAVA_SOURCES} RESOURCES NAMESPACE "edu/wpi/first/fields" ${JAVA_RESOURCES} OUTPUT_NAME fieldImages)
get_property(FIELD_IMAGES_JAR_FILE TARGET field_images_jar PROPERTY JAR_FILE)
install(FILES ${FIELD_IMAGES_JAR_FILE} DESTINATION "${java_lib_dest}")
set_property(TARGET field_images_jar PROPERTY FOLDER "java")
endif()
GENERATE_RESOURCES(src/main/native/resources/edu/wpi/first/fields generated/main/cpp FIELDS fields field_images_resources_src)
add_library(fieldImages ${field_images_resources_src})
set_target_properties(fieldImages PROPERTIES DEBUG_POSTFIX "d")
set_property(TARGET fieldImages PROPERTY FOLDER "libraries")
target_compile_features(fieldImages PUBLIC cxx_std_17)
if (MSVC)
target_compile_options(fieldImages PUBLIC /bigobj)
endif()
wpilib_target_warnings(fieldImages)
target_include_directories(fieldImages PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
$<INSTALL_INTERFACE:${include_dest}/fields>)

66
fieldImages/build.gradle Normal file
View File

@@ -0,0 +1,66 @@
import org.gradle.internal.os.OperatingSystem
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) {
apply plugin: 'cpp'
apply plugin: 'c'
apply plugin: 'java'
apply plugin: 'google-test-test-suite'
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
if (OperatingSystem.current().isWindows()) {
apply plugin: 'windows-resources'
}
ext {
nativeName = 'fieldImages'
}
apply from: "${rootDir}/shared/resources.gradle"
apply from: "${rootDir}/shared/config.gradle"
def generateTask = createGenerateResourcesTask('main', 'FIELDS', 'fields', project)
project(':').libraryBuild.dependsOn build
tasks.withType(CppCompile) {
dependsOn generateTask
}
sourceSets {
main {
resources {
srcDirs 'src/main/native/resources'
}
}
}
model {
components {
"${nativeName}"(NativeLibrarySpec) {
baseName = 'fieldImages'
sources {
cpp {
source {
srcDirs "$buildDir/generated/main/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/main/native/include'
}
}
if (OperatingSystem.current().isWindows()) {
rc {
source {
srcDirs 'src/main/native/win'
include '*.rc'
}
}
}
}
}
}
}
apply from: 'publish.gradle'
}

View File

@@ -0,0 +1,71 @@
apply plugin: 'maven-publish'
def baseArtifactId = 'fieldImages'
def artifactGroupId = 'edu.wpi.first.fieldImages'
def zipBaseName = '_GROUP_edu_wpi_first_field_images_ID_CLS'
def outputsFolder = file("$project.buildDir/outputs")
task cppSourcesZip(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = zipBaseName
classifier = "sources"
from(licenseFile) {
into '/'
}
from('src/main/native/cpp') {
into '/'
}
from("$buildDir/generated/cpp") {
into '/'
}
}
task cppHeadersZip(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = zipBaseName
classifier = "headers"
from(licenseFile) {
into '/'
}
ext.includeDirs = [
project.file('src/main/native/include')
]
ext.includeDirs.each {
from(it) {
into '/'
}
}
}
build.dependsOn cppHeadersZip
build.dependsOn cppSourcesZip
addTaskToCopyAllOutputs(cppHeadersZip)
addTaskToCopyAllOutputs(cppSourcesZip)
model {
publishing {
def wpilibCTaskList = createComponentZipTasks($.components, ['fieldImages'], zipBaseName, Zip, project, includeStandardZipFormat)
publications {
cpp(MavenPublication) {
wpilibCTaskList.each {
artifact it
}
artifact cppHeadersZip
artifact cppSourcesZip
artifactId = baseArtifactId
groupId artifactGroupId
version wpilibVersioning.version.get()
}
}
}
}

View File

@@ -0,0 +1,23 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package edu.wpi.fields;
public class FieldImages {
public static final String k2018PowerUpFieldConfig = "/edu/wpi/first/fields/2018-powerup.json";
public static final String k2019DeepSpaceFieldConfig =
"/edu/wpi/first/fields/2019-deepspace.json";
public static final String k2020InfiniteRechargeFieldConfig =
"/edu/wpi/first/fields/2020-infiniterecharge.json";
public static final String k2021InfiniteRechargeFieldConfig =
"/edu/wpi/first/fields/2021-infiniterecharge.json";
public static final String k2021BarrelFieldConfig =
"/edu/wpi/first/fields/2021-barrelracingpath.json";
public static final String k2021BounceFieldConfig = "/edu/wpi/first/fields/2021-bouncepath.json";
public static final String k2021GalacticSearchAFieldConfig =
"/edu/wpi/first/fields/2021-galacticsearcha.json";
public static final String k2021GalacticSearchBFieldConfig =
"/edu/wpi/first/fields/2021-galacticsearchb.json";
public static final String k2021SlalomFieldConfig = "/edu/wpi/first/fields/2021-slalompath.json";
}

View File

@@ -0,0 +1,12 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <string_view>
namespace fields {
std::string_view GetResource_2018_powerup_json();
std::string_view GetResource_2018_field_jpg();
} // namespace fields

View File

@@ -0,0 +1,12 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <string_view>
namespace fields {
std::string_view GetResource_2019_deepspace_json();
std::string_view GetResource_2019_field_jpg();
} // namespace fields

View File

@@ -0,0 +1,12 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <string_view>
namespace fields {
std::string_view GetResource_2020_infiniterecharge_json();
std::string_view GetResource_2020_field_png();
} // namespace fields

View File

@@ -0,0 +1,12 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <string_view>
namespace fields {
std::string_view GetResource_2021_barrelracingpath_json();
std::string_view GetResource_2021_barrel_png();
} // namespace fields

View File

@@ -0,0 +1,12 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <string_view>
namespace fields {
std::string_view GetResource_2021_bouncepath_json();
std::string_view GetResource_2021_bounce_png();
} // namespace fields

View File

@@ -0,0 +1,12 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <string_view>
namespace fields {
std::string_view GetResource_2021_galacticsearcha_json();
std::string_view GetResource_2021_galacticsearcha_png();
} // namespace fields

View File

@@ -0,0 +1,12 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <string_view>
namespace fields {
std::string_view GetResource_2021_galacticsearchb_json();
std::string_view GetResource_2021_galacticsearchb_png();
} // namespace fields

View File

@@ -0,0 +1,12 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <string_view>
namespace fields {
std::string_view GetResource_2021_field_png();
std::string_view GetResource_2021_infiniterecharge_json();
} // namespace fields

View File

@@ -0,0 +1,12 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <string_view>
namespace fields {
std::string_view GetResource_2021_slalompath_json();
std::string_view GetResource_2021_slalom_png();
} // namespace fields

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

View File

@@ -0,0 +1,10 @@
{
"game": "FIRST Power Up",
"field-image": "2018-field.jpg",
"field-corners": {
"top-left": [125, 20],
"bottom-right": [827, 370]
},
"field-size": [54, 27],
"field-unit": "feet"
}

View File

@@ -0,0 +1,10 @@
{
"game" : "Destination: Deep Space",
"field-image" : "2019-field.jpg",
"field-corners": {
"top-left" : [217, 40],
"bottom-right" : [1372, 615]
},
"field-size" : [54, 27],
"field-unit" : "foot"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 KiB

View File

@@ -0,0 +1,10 @@
{
"game" : "Infinite Recharge",
"field-image" : "2020-field.png",
"field-corners": {
"top-left" : [96, 25],
"bottom-right" : [1040, 514]
},
"field-size" : [52.4375, 26.9375],
"field-unit" : "foot"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -0,0 +1,10 @@
{
"game": "Barrel Racing Path",
"field-image": "2021-barrel.png",
"field-corners": {
"top-left": [20, 20],
"bottom-right": [780, 400]
},
"field-size": [30, 15],
"field-unit": "feet"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -0,0 +1,10 @@
{
"game": "Bounce Path",
"field-image": "2021-bounce.png",
"field-corners": {
"top-left": [20, 20],
"bottom-right": [780, 400]
},
"field-size": [30, 15],
"field-unit": "feet"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

@@ -0,0 +1,10 @@
{
"game": "Galactic Search A",
"field-image": "2021-galacticsearcha.png",
"field-corners": {
"top-left": [20, 20],
"bottom-right": [780, 400]
},
"field-size": [30, 15],
"field-unit": "feet"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -0,0 +1,10 @@
{
"game": "Galactic Search B",
"field-image": "2021-galacticsearchb.png",
"field-corners": {
"top-left": [20, 20],
"bottom-right": [780, 400]
},
"field-size": [30, 15],
"field-unit": "feet"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,10 @@
{
"game": "Infinite Recharge 2021",
"field-image": "2021-field.png",
"field-corners": {
"top-left": [127, 34],
"bottom-right": [1323, 649]
},
"field-size": [52.4375, 26.9375],
"field-unit": "foot"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -0,0 +1,10 @@
{
"game": "Slalom Path",
"field-image": "2021-slalom.png",
"field-corners": {
"top-left": [20, 20],
"bottom-right": [780, 400]
},
"field-size": [30, 15],
"field-unit": "feet"
}

View File

@@ -261,17 +261,17 @@ static DisplayUnits gDisplayUnits = kDisplayMeters;
static double ConvertDisplayLength(units::meter_t v) {
switch (gDisplayUnits) {
case kDisplayFeet:
return v.convert<units::feet>().to<double>();
return v.convert<units::feet>().value();
case kDisplayInches:
return v.convert<units::inches>().to<double>();
return v.convert<units::inches>().value();
case kDisplayMeters:
default:
return v.to<double>();
return v.value();
}
}
static double ConvertDisplayAngle(units::degree_t v) {
return v.to<double>();
return v.value();
}
static bool InputLength(const char* label, units::meter_t* v, double step = 0.0,

View File

@@ -94,9 +94,9 @@ void NTField2DModel::ObjectModel::UpdateNT() {
wpi::SmallVector<double, 9> arr;
for (auto&& pose : m_poses) {
auto& translation = pose.Translation();
arr.push_back(translation.X().to<double>());
arr.push_back(translation.Y().to<double>());
arr.push_back(pose.Rotation().Degrees().to<double>());
arr.push_back(translation.X().value());
arr.push_back(translation.Y().value());
arr.push_back(pose.Rotation().Degrees().value());
}
nt::SetEntryTypeValue(m_entry, nt::Value::MakeDoubleArray(arr));
} else {
@@ -107,13 +107,13 @@ void NTField2DModel::ObjectModel::UpdateNT() {
for (auto&& pose : m_poses) {
auto& translation = pose.Translation();
wpi::support::endian::write64be(
p, wpi::DoubleToBits(translation.X().to<double>()));
p, wpi::DoubleToBits(translation.X().value()));
p += 8;
wpi::support::endian::write64be(
p, wpi::DoubleToBits(translation.Y().to<double>()));
p, wpi::DoubleToBits(translation.Y().value()));
p += 8;
wpi::support::endian::write64be(
p, wpi::DoubleToBits(pose.Rotation().Degrees().to<double>()));
p, wpi::DoubleToBits(pose.Rotation().Degrees().value()));
p += 8;
}
nt::SetEntryTypeValue(m_entry,

View File

@@ -46,4 +46,14 @@ public class PowerDistributionJNI extends JNIWrapper {
public static native boolean getSwitchableChannel(int handle);
public static native void setSwitchableChannel(int handle, boolean enabled);
public static native double getVoltageNoError(int handle);
public static native double getChannelCurrentNoError(int handle, int channel);
public static native double getTotalCurrentNoError(int handle);
public static native boolean getSwitchableChannelNoError(int handle);
public static native void setSwitchableChannelNoError(int handle, boolean enabled);
}

View File

@@ -34,6 +34,7 @@ using namespace hal;
static std::unique_ptr<tGlobal> global;
static std::unique_ptr<tSysWatchdog> watchdog;
static uint64_t dsStartTime;
using namespace hal;
@@ -86,6 +87,11 @@ void ReleaseFPGAInterrupt(int32_t interruptNumber) {
&status);
global->strobeInterruptForceOnce(&status);
}
uint64_t GetDSInitializeTime() {
return dsStartTime;
}
} // namespace hal
extern "C" {
@@ -420,6 +426,11 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
HAL_InitializeDriverStation();
dsStartTime = HAL_GetFPGATime(&status);
if (status != 0) {
return false;
}
// Set WPI_Now to use FPGA timestamp
wpi::SetNowImpl([]() -> uint64_t {
int32_t status = 0;

View File

@@ -17,4 +17,5 @@ void SetLastErrorIndexOutOfRange(int32_t* status, std::string_view message,
void SetLastErrorPreviouslyAllocated(int32_t* status, std::string_view message,
int32_t channel,
std::string_view previousAllocation);
uint64_t GetDSInitializeTime();
} // namespace hal

View File

@@ -4,11 +4,14 @@
#include "hal/PowerDistribution.h"
#include <thread>
#include "CTREPDP.h"
#include "HALInternal.h"
#include "PortsInternal.h"
#include "REVPDH.h"
#include "hal/Errors.h"
#include "hal/HALBase.h"
#include "hal/handles/HandlesInternal.h"
using namespace hal;
@@ -19,7 +22,41 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
int32_t moduleNumber, HAL_PowerDistributionType type,
const char* allocationLocation, int32_t* status) {
if (type == HAL_PowerDistributionType::HAL_PowerDistributionType_kAutomatic) {
type = HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE;
if (moduleNumber != HAL_DEFAULT_POWER_DISTRIBUTION_MODULE) {
*status = PARAMETER_OUT_OF_RANGE;
hal::SetLastError(
status, "Automatic PowerDistributionType must have default module");
return HAL_kInvalidHandle;
}
uint64_t waitTime = hal::GetDSInitializeTime() + 400000;
// Ensure we have been alive for long enough to receive a few Power packets.
do {
uint64_t currentTime = HAL_GetFPGATime(status);
if (*status != 0) {
return HAL_kInvalidHandle;
}
if (currentTime >= waitTime) {
break;
}
std::this_thread::sleep_for(
std::chrono::microseconds(waitTime - currentTime));
} while (true);
// Try PDP first
auto pdpHandle = HAL_InitializePDP(0, allocationLocation, status);
if (pdpHandle != HAL_kInvalidHandle) {
*status = 0;
HAL_GetPDPVoltage(pdpHandle, status);
if (*status == 0 || *status == HAL_CAN_TIMEOUT) {
return static_cast<HAL_PowerDistributionHandle>(pdpHandle);
}
HAL_CleanPDP(pdpHandle);
}
*status = 0;
auto pdhHandle = HAL_REV_InitializePDH(1, allocationLocation, status);
return static_cast<HAL_PowerDistributionHandle>(pdhHandle);
}
if (type == HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE) {
@@ -27,7 +64,7 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
moduleNumber = 0;
}
return static_cast<HAL_PowerDistributionHandle>(
HAL_InitializePDP(moduleNumber, allocationLocation, status)); // TODO
HAL_InitializePDP(moduleNumber, allocationLocation, status));
} else {
if (moduleNumber == HAL_DEFAULT_POWER_DISTRIBUTION_MODULE) {
moduleNumber = 1;

View File

@@ -216,7 +216,8 @@ HAL_REVPHHandle HAL_InitializeREVPH(int32_t module,
hph->hcan = hcan;
hph->controlPeriod = kDefaultControlPeriod;
// TODO any other things
// Start closed-loop compressor control by starting solenoid state updates
HAL_REV_SendSolenoidsState(hph.get(), status);
return handle;
}
@@ -318,7 +319,7 @@ double HAL_GetREVPHAnalogPressure(HAL_REVPHHandle handle, int32_t channel,
return 0;
}
if (channel == 1) {
if (channel == 0) {
return PH_status0_analog_0_decode(status0.analog_0);
}
return PH_status0_analog_1_decode(status0.analog_1);

View File

@@ -83,7 +83,7 @@ HAL_SerialPortHandle HAL_InitializeSerialPortDirect(HAL_SerialPort port,
serialPort->portId = open(portName, O_RDWR | O_NOCTTY);
if (serialPort->portId < 0) {
*status = errno;
*status = -errno;
if (*status == EACCES) {
*status = HAL_CONSOLE_OUT_ENABLED_ERROR;
}
@@ -94,8 +94,20 @@ HAL_SerialPortHandle HAL_InitializeSerialPortDirect(HAL_SerialPort port,
std::memset(&serialPort->tty, 0, sizeof(serialPort->tty));
serialPort->baudRate = B9600;
cfsetospeed(&serialPort->tty, static_cast<speed_t>(serialPort->baudRate));
cfsetispeed(&serialPort->tty, static_cast<speed_t>(serialPort->baudRate));
if (cfsetospeed(&serialPort->tty,
static_cast<speed_t>(serialPort->baudRate)) != 0) {
*status = -errno;
close(serialPort->portId);
serialPortHandles->Free(handle);
return HAL_kInvalidHandle;
}
if (cfsetispeed(&serialPort->tty,
static_cast<speed_t>(serialPort->baudRate)) != 0) {
*status = -errno;
close(serialPort->portId);
serialPortHandles->Free(handle);
return HAL_kInvalidHandle;
}
serialPort->tty.c_cflag &= ~PARENB;
serialPort->tty.c_cflag &= ~CSTOPB;
@@ -115,9 +127,14 @@ HAL_SerialPortHandle HAL_InitializeSerialPortDirect(HAL_SerialPort port,
*/
serialPort->tty.c_oflag = ~OPOST;
tcflush(serialPort->portId, TCIOFLUSH);
if (tcflush(serialPort->portId, TCIOFLUSH) != 0) {
*status = -errno;
close(serialPort->portId);
serialPortHandles->Free(handle);
return HAL_kInvalidHandle;
}
if (tcsetattr(serialPort->portId, TCSANOW, &serialPort->tty) != 0) {
*status = errno;
*status = -errno;
close(serialPort->portId);
serialPortHandles->Free(handle);
return HAL_kInvalidHandle;

View File

@@ -292,4 +292,74 @@ Java_edu_wpi_first_hal_PowerDistributionJNI_getSwitchableChannel
return state;
}
/*
* Class: edu_wpi_first_hal_PowerDistributionJNI
* Method: getVoltageNoError
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_PowerDistributionJNI_getVoltageNoError
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
double voltage = HAL_GetPowerDistributionVoltage(handle, &status);
return voltage;
}
/*
* Class: edu_wpi_first_hal_PowerDistributionJNI
* Method: getChannelCurrentNoError
* Signature: (II)D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_PowerDistributionJNI_getChannelCurrentNoError
(JNIEnv* env, jclass, jint handle, jint channel)
{
int32_t status = 0;
double current =
HAL_GetPowerDistributionChannelCurrent(handle, channel, &status);
return current;
}
/*
* Class: edu_wpi_first_hal_PowerDistributionJNI
* Method: getTotalCurrentNoError
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_PowerDistributionJNI_getTotalCurrentNoError
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
double current = HAL_GetPowerDistributionTotalCurrent(handle, &status);
return current;
}
/*
* Class: edu_wpi_first_hal_PowerDistributionJNI
* Method: setSwitchableChannelNoError
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_PowerDistributionJNI_setSwitchableChannelNoError
(JNIEnv* env, jclass, jint handle, jboolean enabled)
{
int32_t status = 0;
HAL_SetPowerDistributionSwitchableChannel(handle, enabled, &status);
}
/*
* Class: edu_wpi_first_hal_PowerDistributionJNI
* Method: getSwitchableChannelNoError
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_PowerDistributionJNI_getSwitchableChannelNoError
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
auto state = HAL_GetPowerDistributionSwitchableChannel(handle, &status);
return state;
}
} // extern "C"

View File

@@ -156,7 +156,7 @@ int32_t HAL_GetJoystickAxisType(int32_t joystickNum, int32_t axis);
/**
* Set joystick outputs.
*
* @param joystickNum the joystick numer
* @param joystickNum the joystick number
* @param outputs bitmask of outputs, 1 for on 0 for off
* @param leftRumble the left rumble value (0-FFFF)
* @param rightRumble the right rumble value (0-FFFF)
@@ -241,7 +241,7 @@ void HAL_ObserveUserProgramStarting(void);
* Sets the disabled flag in the DS.
*
* This is used for the DS to ensure the robot is properly responding to its
* state request. Ensure this get called about every 50ms, or the robot will be
* state request. Ensure this gets called about every 50ms, or the robot will be
* disabled by the DS.
*/
void HAL_ObserveUserProgramDisabled(void);
@@ -250,7 +250,7 @@ void HAL_ObserveUserProgramDisabled(void);
* Sets the autonomous enabled flag in the DS.
*
* This is used for the DS to ensure the robot is properly responding to its
* state request. Ensure this get called about every 50ms, or the robot will be
* state request. Ensure this gets called about every 50ms, or the robot will be
* disabled by the DS.
*/
void HAL_ObserveUserProgramAutonomous(void);
@@ -259,7 +259,7 @@ void HAL_ObserveUserProgramAutonomous(void);
* Sets the teleoperated enabled flag in the DS.
*
* This is used for the DS to ensure the robot is properly responding to its
* state request. Ensure this get called about every 50ms, or the robot will be
* state request. Ensure this gets called about every 50ms, or the robot will be
* disabled by the DS.
*/
void HAL_ObserveUserProgramTeleop(void);
@@ -268,7 +268,7 @@ void HAL_ObserveUserProgramTeleop(void);
* Sets the test mode flag in the DS.
*
* This is used for the DS to ensure the robot is properly responding to its
* state request. Ensure this get called about every 50ms, or the robot will be
* state request. Ensure this gets called about every 50ms, or the robot will be
* disabled by the DS.
*/
void HAL_ObserveUserProgramTest(void);

View File

@@ -6,6 +6,8 @@
#include <stdint.h>
#include <wpi/Synchronization.h>
#include "hal/Types.h"
/* General Handle Data Layout
@@ -43,7 +45,7 @@ constexpr int16_t InvalidHandleIndex = -1;
*/
enum class HAL_HandleEnum {
Undefined = 0,
DIO = 1,
DIO = wpi::kHandleTypeHALBase,
Port = 2,
Notifier = 3,
Interrupt = 4,

View File

@@ -58,10 +58,11 @@ int32_t HALSIM_RegisterSimValueChangedCallback(HAL_SimValueHandle handle,
void HALSIM_CancelSimValueChangedCallback(int32_t uid);
/**
* Register a callback for HAL_SimValueReset(). The callback is called with
* the old value.
* Register a callback for HAL_SimValueReset(). The callback is called with the
* old value.
*
* @param handle simulated value handle
* @param param parameter for callback
* @param callback callback
* @param initialNotify ignored (present for consistency)
*/

View File

@@ -30,6 +30,19 @@ extern "C" {
HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
int32_t module, HAL_PowerDistributionType type,
const char* allocationLocation, int32_t* status) {
if (type == HAL_PowerDistributionType_kAutomatic) {
if (module != HAL_DEFAULT_POWER_DISTRIBUTION_MODULE) {
*status = PARAMETER_OUT_OF_RANGE;
hal::SetLastError(
status, "Automatic PowerDistributionType must have default module");
return HAL_kInvalidHandle;
}
// TODO Make this not matter
type = HAL_PowerDistributionType_kCTRE;
module = 0;
}
if (!HAL_CheckPowerDistributionModule(module, type)) {
*status = PARAMETER_OUT_OF_RANGE;
hal::SetLastError(status, fmt::format("Invalid pdp module {}", module));

View File

@@ -5,6 +5,8 @@
#ifndef NTCORE_HANDLE_H_
#define NTCORE_HANDLE_H_
#include <wpi/Synchronization.h>
#include "ntcore_c.h"
namespace nt {
@@ -17,7 +19,7 @@ namespace nt {
class Handle {
public:
enum Type {
kConnectionListener = 1,
kConnectionListener = wpi::kHandleTypeNTBase,
kConnectionListenerPoller,
kEntry,
kEntryListener,

View File

@@ -29,6 +29,7 @@ include 'wpilibjExamples'
include 'wpilibjIntegrationTests'
include 'wpilibj'
include 'crossConnIntegrationTests'
include 'fieldImages'
include 'glass'
include 'outlineviewer'
include 'simulation:gz_msgs'

View File

@@ -1,3 +1,5 @@
import groovy.io.FileType
ext.createGenerateResourcesTask = { name, prefix, namespace, project ->
def generatedOutputDir = file("$buildDir/generated/$name/cpp")
@@ -11,7 +13,7 @@ ext.createGenerateResourcesTask = { name, prefix, namespace, project ->
doLast {
generatedOutputDir.mkdirs()
inputDir.eachFile { inputFile ->
inputDir.eachFileRecurse (FileType.FILES) { inputFile ->
if (inputFile.name.startsWith('.')) return
def fileBytes = inputFile.bytes
def outputFile = file("$generatedOutputDir/${inputFile.name}.cpp")

View File

@@ -0,0 +1,130 @@
diff --git a/wpimath/src/main/native/include/drake/math/discrete_algebraic_riccati_equation.h b/wpimath/src/main/native/include/drake/math/discrete_algebraic_riccati_equation.h
index 5d7a316f3..dc08be95e 100644
--- a/wpimath/src/main/native/include/drake/math/discrete_algebraic_riccati_equation.h
+++ b/wpimath/src/main/native/include/drake/math/discrete_algebraic_riccati_equation.h
@@ -9,18 +9,19 @@
namespace drake {
namespace math {
-/// Computes the unique stabilizing solution X to the discrete-time algebraic
-/// Riccati equation:
-///
-/// AᵀXA X AᵀXB(BᵀXB + R)⁻¹BᵀXA + Q = 0
-///
-/// @throws std::exception if Q is not positive semi-definite.
-/// @throws std::exception if R is not positive definite.
-///
-/// Based on the Schur Vector approach outlined in this paper:
-/// "On the Numerical Solution of the Discrete-Time Algebraic Riccati Equation"
-/// by Thrasyvoulos Pappas, Alan J. Laub, and Nils R. Sandell
-///
+/**
+Computes the unique stabilizing solution X to the discrete-time algebraic
+Riccati equation:
+
+AᵀXA X AᵀXB(BᵀXB + R)⁻¹BᵀXA + Q = 0
+
+@throws std::exception if Q is not positive semi-definite.
+@throws std::exception if R is not positive definite.
+
+Based on the Schur Vector approach outlined in this paper:
+"On the Numerical Solution of the Discrete-Time Algebraic Riccati Equation"
+by Thrasyvoulos Pappas, Alan J. Laub, and Nils R. Sandell
+*/
WPILIB_DLLEXPORT
Eigen::MatrixXd DiscreteAlgebraicRiccatiEquation(
const Eigen::Ref<const Eigen::MatrixXd>& A,
@@ -28,49 +29,50 @@ Eigen::MatrixXd DiscreteAlgebraicRiccatiEquation(
const Eigen::Ref<const Eigen::MatrixXd>& Q,
const Eigen::Ref<const Eigen::MatrixXd>& R);
-/// Computes the unique stabilizing solution X to the discrete-time algebraic
-/// Riccati equation:
-///
-/// AᵀXA X (AᵀXB + N)(BᵀXB + R)⁻¹(BᵀXA + Nᵀ) + Q = 0
-///
-/// This is equivalent to solving the original DARE:
-///
-/// A₂ᵀXA₂ X A₂ᵀXB(BᵀXB + R)⁻¹BᵀXA₂ + Q₂ = 0
-///
-/// where A₂ and Q₂ are a change of variables:
-///
-/// A₂ = A BR⁻¹Nᵀ and Q₂ = Q NR⁻¹Nᵀ
-///
-/// This overload of the DARE is useful for finding the control law uₖ that
-/// minimizes the following cost function subject to xₖ₊₁ = Axₖ + Buₖ.
-///
-/// @verbatim
-/// ∞ [xₖ]ᵀ[Q N][xₖ]
-/// J = Σ [uₖ] [Nᵀ R][uₖ] ΔT
-/// k=0
-/// @endverbatim
-///
-/// This is a more general form of the following. The linear-quadratic regulator
-/// is the feedback control law uₖ that minimizes the following cost function
-/// subject to xₖ₊₁ = Axₖ + Buₖ:
-///
-/// @verbatim
-/// ∞
-/// J = Σ (xₖᵀQxₖ + uₖᵀRuₖ) ΔT
-/// k=0
-/// @endverbatim
-///
-/// This can be refactored as:
-///
-/// @verbatim
-/// ∞ [xₖ]ᵀ[Q 0][xₖ]
-/// J = Σ [uₖ] [0 R][uₖ] ΔT
-/// k=0
-/// @endverbatim
-///
-/// @throws std::runtime_error if Q NR⁻¹Nᵀ is not positive semi-definite.
-/// @throws std::runtime_error if R is not positive definite.
-///
+/**
+Computes the unique stabilizing solution X to the discrete-time algebraic
+Riccati equation:
+
+AᵀXA X (AᵀXB + N)(BᵀXB + R)⁻¹(BᵀXA + Nᵀ) + Q = 0
+
+This is equivalent to solving the original DARE:
+
+A₂ᵀXA₂ X A₂ᵀXB(BᵀXB + R)⁻¹BᵀXA₂ + Q₂ = 0
+
+where A₂ and Q₂ are a change of variables:
+
+A₂ = A BR⁻¹Nᵀ and Q₂ = Q NR⁻¹Nᵀ
+
+This overload of the DARE is useful for finding the control law uₖ that
+minimizes the following cost function subject to xₖ₊₁ = Axₖ + Buₖ.
+
+@verbatim
+ ∞ [xₖ]ᵀ[Q N][xₖ]
+J = Σ [uₖ] [Nᵀ R][uₖ] ΔT
+ k=0
+@endverbatim
+
+This is a more general form of the following. The linear-quadratic regulator
+is the feedback control law uₖ that minimizes the following cost function
+subject to xₖ₊₁ = Axₖ + Buₖ:
+
+@verbatim
+ ∞
+J = Σ (xₖᵀQxₖ + uₖᵀRuₖ) ΔT
+ k=0
+@endverbatim
+
+This can be refactored as:
+
+@verbatim
+ ∞ [xₖ]ᵀ[Q 0][xₖ]
+J = Σ [uₖ] [0 R][uₖ] ΔT
+ k=0
+@endverbatim
+
+@throws std::runtime_error if Q NR⁻¹Nᵀ is not positive semi-definite.
+@throws std::runtime_error if R is not positive definite.
+*/
WPILIB_DLLEXPORT
Eigen::MatrixXd DiscreteAlgebraicRiccatiEquation(
const Eigen::Ref<const Eigen::MatrixXd>& A,

View File

@@ -8,7 +8,7 @@ from upstream_utils import setup_upstream_repo, comment_out_invalid_includes, wa
def main():
root, repo = setup_upstream_repo("https://github.com/RobotLocomotion/drake",
"v0.34.0")
"v0.35.0")
wpimath = os.path.join(root, "wpimath")
# Delete old install
@@ -62,8 +62,9 @@ def main():
])
apply_patches(root, [
"upstream_utils/drake-replace-dense-with-core.patch",
"upstream_utils/drake-dllexport-dare.patch",
"upstream_utils/drake-replace-dense-with-core.patch"
"upstream_utils/drake-fix-doxygen.patch"
])

View File

@@ -26,6 +26,10 @@ void CommandBase::AddRequirements(wpi::SmallSet<Subsystem*, 4> requirements) {
m_requirements.insert(requirements.begin(), requirements.end());
}
void CommandBase::AddRequirements(Subsystem* requirement) {
m_requirements.insert(requirement);
}
wpi::SmallSet<Subsystem*, 4> CommandBase::GetRequirements() const {
return m_requirements;
}

View File

@@ -310,20 +310,20 @@ void MecanumControllerCommand::Execute() {
(rearRightSpeedSetpoint - m_prevSpeeds.rearRight) / dt);
auto frontLeftOutput = volt_t(m_frontLeftController->Calculate(
m_currentWheelSpeeds().frontLeft.to<double>(),
frontLeftSpeedSetpoint.to<double>())) +
m_currentWheelSpeeds().frontLeft.value(),
frontLeftSpeedSetpoint.value())) +
frontLeftFeedforward;
auto rearLeftOutput = volt_t(m_rearLeftController->Calculate(
m_currentWheelSpeeds().rearLeft.to<double>(),
rearLeftSpeedSetpoint.to<double>())) +
m_currentWheelSpeeds().rearLeft.value(),
rearLeftSpeedSetpoint.value())) +
rearLeftFeedforward;
auto frontRightOutput = volt_t(m_frontRightController->Calculate(
m_currentWheelSpeeds().frontRight.to<double>(),
frontRightSpeedSetpoint.to<double>())) +
m_currentWheelSpeeds().frontRight.value(),
frontRightSpeedSetpoint.value())) +
frontRightFeedforward;
auto rearRightOutput = volt_t(m_rearRightController->Calculate(
m_currentWheelSpeeds().rearRight.to<double>(),
rearRightSpeedSetpoint.to<double>())) +
m_currentWheelSpeeds().rearRight.value(),
rearRightSpeedSetpoint.value())) +
rearRightFeedforward;
m_outputVolts(frontLeftOutput, rearLeftOutput, frontRightOutput,

View File

@@ -126,15 +126,15 @@ void RamseteCommand::Execute() {
targetWheelSpeeds.right,
(targetWheelSpeeds.right - m_prevSpeeds.right) / dt);
auto leftOutput = volt_t(m_leftController->Calculate(
m_speeds().left.to<double>(),
targetWheelSpeeds.left.to<double>())) +
leftFeedforward;
auto leftOutput =
volt_t(m_leftController->Calculate(m_speeds().left.value(),
targetWheelSpeeds.left.value())) +
leftFeedforward;
auto rightOutput = volt_t(m_rightController->Calculate(
m_speeds().right.to<double>(),
targetWheelSpeeds.right.to<double>())) +
rightFeedforward;
auto rightOutput =
volt_t(m_rightController->Calculate(m_speeds().right.value(),
targetWheelSpeeds.right.value())) +
rightFeedforward;
m_outputVolts(leftOutput, rightOutput);
} else {

View File

@@ -24,21 +24,38 @@ class CommandBase : public Command,
public wpi::SendableHelper<CommandBase> {
public:
/**
* Adds the specified requirements to the command.
* Adds the specified Subsystem requirements to the command.
*
* @param requirements the requirements to add
* @param requirements the Subsystem requirements to add
*/
void AddRequirements(std::initializer_list<Subsystem*> requirements);
/**
* Adds the specified requirements to the command.
* Adds the specified Subsystem requirements to the command.
*
* @param requirements the requirements to add
* @param requirements the Subsystem requirements to add
*/
void AddRequirements(wpi::span<Subsystem* const> requirements);
/**
* Adds the specified Subsystem requirements to the command.
*
* @param requirements the Subsystem requirements to add
*/
void AddRequirements(wpi::SmallSet<Subsystem*, 4> requirements);
/**
* Adds the specified Subsystem requirement to the command.
*
* @param requirement the Subsystem requirement to add
*/
void AddRequirements(Subsystem* requirement);
/**
* Gets the Subsystem requirements of the command.
*
* @return the Command's Subsystem requirements
*/
wpi::SmallSet<Subsystem*, 4> GetRequirements() const override;
/**

View File

@@ -153,7 +153,7 @@ double PIDBase::GetSetpoint() const {
double PIDBase::GetDeltaSetpoint() const {
std::scoped_lock lock(m_thisMutex);
return (m_setpoint - m_prevSetpoint) / m_setpointTimer.Get().to<double>();
return (m_setpoint - m_prevSetpoint) / m_setpointTimer.Get().value();
}
double PIDBase::GetError() const {

View File

@@ -34,7 +34,7 @@ Command::Command(std::string_view name, units::second_t timeout) {
// We use -1.0 to indicate no timeout.
if (timeout < 0_s && timeout != -1_s) {
throw FRC_MakeError(err::ParameterOutOfRange, "timeout {} < 0 s",
timeout.to<double>());
timeout.value());
}
m_timeout = timeout;
@@ -177,7 +177,7 @@ int Command::GetID() const {
void Command::SetTimeout(units::second_t timeout) {
if (timeout < 0_s) {
throw FRC_MakeError(err::ParameterOutOfRange, "timeout {} < 0 s",
timeout.to<double>());
timeout.value());
} else {
m_timeout = timeout;
}

View File

@@ -38,7 +38,7 @@ void CommandGroup::AddSequential(Command* command, units::second_t timeout) {
}
if (timeout < 0_s) {
throw FRC_MakeError(err::ParameterOutOfRange, "timeout {} < 0 s",
timeout.to<double>());
timeout.value());
}
m_commands.emplace_back(command, CommandGroupEntry::kSequence_InSequence,
@@ -82,7 +82,7 @@ void CommandGroup::AddParallel(Command* command, units::second_t timeout) {
}
if (timeout < 0_s) {
throw FRC_MakeError(err::ParameterOutOfRange, "timeout {} < 0 s",
timeout.to<double>());
timeout.value());
}
m_commands.emplace_back(command, CommandGroupEntry::kSequence_BranchChild,

View File

@@ -9,7 +9,7 @@
using namespace frc;
WaitCommand::WaitCommand(units::second_t timeout)
: TimedCommand(fmt::format("Wait({})", timeout.to<double>()), timeout) {}
: TimedCommand(fmt::format("Wait({})", timeout.value()), timeout) {}
WaitCommand::WaitCommand(std::string_view name, units::second_t timeout)
: TimedCommand(name, timeout) {}

View File

@@ -93,7 +93,7 @@ double AnalogEncoder::GetDistancePerRotation() const {
}
double AnalogEncoder::GetDistance() const {
return Get().to<double>() * GetDistancePerRotation();
return Get().value() * GetDistancePerRotation();
}
void AnalogEncoder::Reset() {

View File

@@ -282,7 +282,7 @@ units::second_t Counter::GetPeriod() const {
void Counter::SetMaxPeriod(units::second_t maxPeriod) {
int32_t status = 0;
HAL_SetCounterMaxPeriod(m_counter, maxPeriod.to<double>(), &status);
HAL_SetCounterMaxPeriod(m_counter, maxPeriod.value(), &status);
FRC_CheckErrorStatus(status, "{}", "SetMaxPeriod");
}

View File

@@ -42,7 +42,7 @@ void DMA::SetPause(bool pause) {
void DMA::SetTimedTrigger(units::second_t seconds) {
int32_t status = 0;
HAL_SetDMATimedTrigger(dmaHandle, seconds.to<double>(), &status);
HAL_SetDMATimedTrigger(dmaHandle, seconds.value(), &status);
FRC_CheckErrorStatus(status, "{}", "SetTimedTrigger");
}

View File

@@ -112,7 +112,7 @@ double DutyCycleEncoder::GetDistancePerRotation() const {
}
double DutyCycleEncoder::GetDistance() const {
return Get().to<double>() * GetDistancePerRotation();
return Get().value() * GetDistancePerRotation();
}
int DutyCycleEncoder::GetFrequency() const {

View File

@@ -87,7 +87,7 @@ units::second_t Encoder::GetPeriod() const {
void Encoder::SetMaxPeriod(units::second_t maxPeriod) {
int32_t status = 0;
HAL_SetEncoderMaxPeriod(m_encoder, maxPeriod.to<double>(), &status);
HAL_SetEncoderMaxPeriod(m_encoder, maxPeriod.value(), &status);
FRC_CheckErrorStatus(status, "{}", "SetMaxPeriod");
}

View File

@@ -200,6 +200,5 @@ void IterativeRobotBase::LoopFunc() {
}
void IterativeRobotBase::PrintLoopOverrunMessage() {
FRC_ReportError(err::Error, "Loop time of {:.6f}s overrun",
m_period.to<double>());
FRC_ReportError(err::Error, "Loop time of {:.6f}s overrun", m_period.value());
}

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "frc/PneumaticsHub.h"
#include "frc/PneumaticHub.h"
#include <hal/REVPH.h>
#include <wpi/NullDeleter.h>
@@ -16,28 +16,27 @@
using namespace frc;
wpi::mutex PneumaticsHub::m_handleLock;
std::unique_ptr<wpi::DenseMap<int, std::weak_ptr<PneumaticsHub::DataStore>>>
PneumaticsHub::m_handleMap = nullptr;
wpi::mutex PneumaticHub::m_handleLock;
std::unique_ptr<wpi::DenseMap<int, std::weak_ptr<PneumaticHub::DataStore>>>
PneumaticHub::m_handleMap = nullptr;
// Always called under lock, so we can avoid the double lock from the magic
// static
std::weak_ptr<PneumaticsHub::DataStore>& PneumaticsHub::GetDataStore(
int module) {
std::weak_ptr<PneumaticHub::DataStore>& PneumaticHub::GetDataStore(int module) {
if (!m_handleMap) {
m_handleMap = std::make_unique<
wpi::DenseMap<int, std::weak_ptr<PneumaticsHub::DataStore>>>();
wpi::DenseMap<int, std::weak_ptr<PneumaticHub::DataStore>>>();
}
return (*m_handleMap)[module];
}
class PneumaticsHub::DataStore {
class PneumaticHub::DataStore {
public:
explicit DataStore(int module, const char* stackTrace) {
int32_t status = 0;
HAL_REVPHHandle handle = HAL_InitializeREVPH(module, stackTrace, &status);
FRC_CheckErrorStatus(status, "Module {}", module);
m_moduleObject = PneumaticsHub{handle, module};
m_moduleObject = PneumaticHub{handle, module};
m_moduleObject.m_dataStore =
std::shared_ptr<DataStore>{this, wpi::NullDeleter<DataStore>()};
}
@@ -48,17 +47,17 @@ class PneumaticsHub::DataStore {
DataStore& operator=(DataStore&&) = delete;
private:
friend class PneumaticsHub;
friend class PneumaticHub;
uint32_t m_reservedMask{0};
bool m_compressorReserved{false};
wpi::mutex m_reservedLock;
PneumaticsHub m_moduleObject{HAL_kInvalidHandle, 0};
PneumaticHub m_moduleObject{HAL_kInvalidHandle, 0};
};
PneumaticsHub::PneumaticsHub()
: PneumaticsHub{SensorUtil::GetDefaultREVPHModule()} {}
PneumaticHub::PneumaticHub()
: PneumaticHub{SensorUtil::GetDefaultREVPHModule()} {}
PneumaticsHub::PneumaticsHub(int module) {
PneumaticHub::PneumaticHub(int module) {
std::string stackTrace = wpi::GetStackTrace(1);
std::scoped_lock lock(m_handleLock);
auto& res = GetDataStore(module);
@@ -71,61 +70,61 @@ PneumaticsHub::PneumaticsHub(int module) {
m_module = module;
}
PneumaticsHub::PneumaticsHub(HAL_REVPHHandle handle, int module)
PneumaticHub::PneumaticHub(HAL_REVPHHandle handle, int module)
: m_handle{handle}, m_module{module} {}
bool PneumaticsHub::GetCompressor() const {
bool PneumaticHub::GetCompressor() const {
int32_t status = 0;
auto result = HAL_GetREVPHCompressor(m_handle, &status);
FRC_CheckErrorStatus(status, "Module {}", m_module);
return result;
}
void PneumaticsHub::SetClosedLoopControl(bool enabled) {
void PneumaticHub::SetClosedLoopControl(bool enabled) {
int32_t status = 0;
HAL_SetREVPHClosedLoopControl(m_handle, enabled, &status);
FRC_CheckErrorStatus(status, "Module {}", m_module);
}
bool PneumaticsHub::GetClosedLoopControl() const {
bool PneumaticHub::GetClosedLoopControl() const {
int32_t status = 0;
auto result = HAL_GetREVPHClosedLoopControl(m_handle, &status);
FRC_CheckErrorStatus(status, "Module {}", m_module);
return result;
}
bool PneumaticsHub::GetPressureSwitch() const {
bool PneumaticHub::GetPressureSwitch() const {
int32_t status = 0;
auto result = HAL_GetREVPHPressureSwitch(m_handle, &status);
FRC_CheckErrorStatus(status, "Module {}", m_module);
return result;
}
double PneumaticsHub::GetCompressorCurrent() const {
double PneumaticHub::GetCompressorCurrent() const {
int32_t status = 0;
auto result = HAL_GetREVPHCompressorCurrent(m_handle, &status);
FRC_CheckErrorStatus(status, "Module {}", m_module);
return result;
}
void PneumaticsHub::SetSolenoids(int mask, int values) {
void PneumaticHub::SetSolenoids(int mask, int values) {
int32_t status = 0;
HAL_SetREVPHSolenoids(m_handle, mask, values, &status);
FRC_CheckErrorStatus(status, "Module {}", m_module);
}
int PneumaticsHub::GetSolenoids() const {
int PneumaticHub::GetSolenoids() const {
int32_t status = 0;
auto result = HAL_GetREVPHSolenoids(m_handle, &status);
FRC_CheckErrorStatus(status, "Module {}", m_module);
return result;
}
int PneumaticsHub::GetModuleNumber() const {
int PneumaticHub::GetModuleNumber() const {
return m_module;
}
int PneumaticsHub::GetSolenoidDisabledList() const {
int PneumaticHub::GetSolenoidDisabledList() const {
return 0;
// TODO Fix me
// int32_t status = 0;
@@ -134,14 +133,14 @@ int PneumaticsHub::GetSolenoidDisabledList() const {
// return result;
}
void PneumaticsHub::FireOneShot(int index) {
void PneumaticHub::FireOneShot(int index) {
// TODO Fix me
// int32_t status = 0;
// HAL_FireREVPHOneShot(m_handle, index, &status);
// FRC_CheckErrorStatus(status, "Module {}", m_module);
}
void PneumaticsHub::SetOneShotDuration(int index, units::second_t duration) {
void PneumaticHub::SetOneShotDuration(int index, units::second_t duration) {
// TODO Fix me
// int32_t status = 0;
// units::millisecond_t millis = duration;
@@ -149,11 +148,11 @@ void PneumaticsHub::SetOneShotDuration(int index, units::second_t duration) {
// &status); FRC_CheckErrorStatus(status, "Module {}", m_module);
}
bool PneumaticsHub::CheckSolenoidChannel(int channel) const {
bool PneumaticHub::CheckSolenoidChannel(int channel) const {
return HAL_CheckREVPHSolenoidChannel(channel);
}
int PneumaticsHub::CheckAndReserveSolenoids(int mask) {
int PneumaticHub::CheckAndReserveSolenoids(int mask) {
std::scoped_lock lock{m_dataStore->m_reservedLock};
uint32_t uMask = static_cast<uint32_t>(mask);
if ((m_dataStore->m_reservedMask & uMask) != 0) {
@@ -163,12 +162,12 @@ int PneumaticsHub::CheckAndReserveSolenoids(int mask) {
return 0;
}
void PneumaticsHub::UnreserveSolenoids(int mask) {
void PneumaticHub::UnreserveSolenoids(int mask) {
std::scoped_lock lock{m_dataStore->m_reservedLock};
m_dataStore->m_reservedMask &= ~(static_cast<uint32_t>(mask));
}
bool PneumaticsHub::ReserveCompressor() {
bool PneumaticHub::ReserveCompressor() {
std::scoped_lock lock{m_dataStore->m_reservedLock};
if (m_dataStore->m_compressorReserved) {
return false;
@@ -177,26 +176,26 @@ bool PneumaticsHub::ReserveCompressor() {
return true;
}
void PneumaticsHub::UnreserveCompressor() {
void PneumaticHub::UnreserveCompressor() {
std::scoped_lock lock{m_dataStore->m_reservedLock};
m_dataStore->m_compressorReserved = false;
}
Solenoid PneumaticsHub::MakeSolenoid(int channel) {
Solenoid PneumaticHub::MakeSolenoid(int channel) {
return Solenoid{m_module, PneumaticsModuleType::REVPH, channel};
}
DoubleSolenoid PneumaticsHub::MakeDoubleSolenoid(int forwardChannel,
int reverseChannel) {
DoubleSolenoid PneumaticHub::MakeDoubleSolenoid(int forwardChannel,
int reverseChannel) {
return DoubleSolenoid{m_module, PneumaticsModuleType::REVPH, forwardChannel,
reverseChannel};
}
Compressor PneumaticsHub::MakeCompressor() {
Compressor PneumaticHub::MakeCompressor() {
return Compressor{m_module, PneumaticsModuleType::REVPH};
}
std::shared_ptr<PneumaticsBase> PneumaticsHub::GetForModule(int module) {
std::shared_ptr<PneumaticsBase> PneumaticHub::GetForModule(int module) {
std::string stackTrace = wpi::GetStackTrace(1);
std::scoped_lock lock(m_handleLock);
auto& res = GetDataStore(module);

View File

@@ -5,8 +5,8 @@
#include "frc/PneumaticsBase.h"
#include "frc/Errors.h"
#include "frc/PneumaticHub.h"
#include "frc/PneumaticsControlModule.h"
#include "frc/PneumaticsHub.h"
#include "frc/SensorUtil.h"
using namespace frc;
@@ -16,7 +16,7 @@ std::shared_ptr<PneumaticsBase> PneumaticsBase::GetForType(
if (moduleType == PneumaticsModuleType::CTREPCM) {
return PneumaticsControlModule::GetForModule(module);
} else if (moduleType == PneumaticsModuleType::REVPH) {
return PneumaticsHub::GetForModule(module);
return PneumaticHub::GetForModule(module);
}
throw FRC_MakeError(err::InvalidParameter, "{}", moduleType);
}

View File

@@ -132,15 +132,38 @@ void PowerDistribution::InitSendable(wpi::SendableBuilder& builder) {
int32_t status = 0;
int numChannels = HAL_GetPowerDistributionNumChannels(m_handle, &status);
FRC_ReportError(status, "Module {}", m_module);
// Use manual reads to avoid printing errors
for (int i = 0; i < numChannels; ++i) {
builder.AddDoubleProperty(
fmt::format("Chan{}", i), [=] { return GetCurrent(i); }, nullptr);
fmt::format("Chan{}", i),
[=] {
int32_t lStatus = 0;
return HAL_GetPowerDistributionChannelCurrent(m_handle, i, &lStatus);
},
nullptr);
}
builder.AddDoubleProperty(
"Voltage", [=] { return GetVoltage(); }, nullptr);
"Voltage",
[=] {
int32_t lStatus = 0;
return HAL_GetPowerDistributionVoltage(m_handle, &lStatus);
},
nullptr);
builder.AddDoubleProperty(
"TotalCurrent", [=] { return GetTotalCurrent(); }, nullptr);
"TotalCurrent",
[=] {
int32_t lStatus = 0;
return HAL_GetPowerDistributionTotalCurrent(m_handle, &lStatus);
},
nullptr);
builder.AddBooleanProperty(
"SwitchableChannel", [=] { return GetSwitchableChannel(); },
[=](bool value) { SetSwitchableChannel(value); });
"SwitchableChannel",
[=] {
int32_t lStatus = 0;
return HAL_GetPowerDistributionSwitchableChannel(m_handle, &lStatus);
},
[=](bool value) {
int32_t lStatus = 0;
HAL_SetPowerDistributionSwitchableChannel(m_handle, value, &lStatus);
});
}

View File

@@ -168,7 +168,7 @@ units::volt_t RobotController::GetBrownoutVoltage() {
void RobotController::SetBrownoutVoltage(units::volt_t brownoutVoltage) {
int32_t status = 0;
HAL_SetBrownoutVoltage(brownoutVoltage.to<double>(), &status);
HAL_SetBrownoutVoltage(brownoutVoltage.value(), &status);
FRC_CheckErrorStatus(status, "{}", "SetBrownoutVoltage");
}

View File

@@ -274,7 +274,7 @@ void SPI::SetAutoTransmitData(wpi::span<const uint8_t> dataToSend,
void SPI::StartAutoRate(units::second_t period) {
int32_t status = 0;
HAL_StartSPIAutoRate(m_port, period.to<double>(), &status);
HAL_StartSPIAutoRate(m_port, period.value(), &status);
FRC_CheckErrorStatus(status, "Port {}", m_port);
}
@@ -307,7 +307,7 @@ int SPI::ReadAutoReceivedData(uint32_t* buffer, int numToRead,
units::second_t timeout) {
int32_t status = 0;
int32_t val = HAL_ReadSPIAutoReceivedData(m_port, buffer, numToRead,
timeout.to<double>(), &status);
timeout.value(), &status);
FRC_CheckErrorStatus(status, "Port {}", m_port);
return val;
}

View File

@@ -124,7 +124,7 @@ int SerialPort::Write(std::string_view buffer) {
void SerialPort::SetTimeout(units::second_t timeout) {
int32_t status = 0;
HAL_SetSerialTimeout(m_portHandle, timeout.to<double>(), &status);
HAL_SetSerialTimeout(m_portHandle, timeout.value(), &status);
FRC_CheckErrorStatus(status, "{}", "SetTimeout");
}

View File

@@ -64,8 +64,8 @@ inline SynchronousInterrupt::WaitResult operator|(
SynchronousInterrupt::WaitResult SynchronousInterrupt::WaitForInterrupt(
units::second_t timeout, bool ignorePrevious) {
int32_t status = 0;
auto result = HAL_WaitForInterrupt(m_handle, timeout.to<double>(),
ignorePrevious, &status);
auto result =
HAL_WaitForInterrupt(m_handle, timeout.value(), ignorePrevious, &status);
auto rising =
((result & 0xFF) != 0) ? WaitResult::kRisingEdge : WaitResult::kTimeout;

View File

@@ -13,8 +13,7 @@
namespace frc {
void Wait(units::second_t seconds) {
std::this_thread::sleep_for(
std::chrono::duration<double>(seconds.to<double>()));
std::this_thread::sleep_for(std::chrono::duration<double>(seconds.value()));
}
units::second_t GetTime() {

View File

@@ -162,7 +162,7 @@ void Ultrasonic::SetEnabled(bool enable) {
void Ultrasonic::InitSendable(wpi::SendableBuilder& builder) {
builder.SetSmartDashboardType("Ultrasonic");
builder.AddDoubleProperty(
"Value", [=] { return units::inch_t{GetRange()}.to<double>(); }, nullptr);
"Value", [=] { return units::inch_t{GetRange()}.value(); }, nullptr);
}
void Ultrasonic::Initialize() {

View File

@@ -80,7 +80,7 @@ void Watchdog::Impl::UpdateAlarm() {
} else {
HAL_UpdateNotifierAlarm(
notifier,
static_cast<uint64_t>(m_watchdogs.top()->m_expirationTime.to<double>() *
static_cast<uint64_t>(m_watchdogs.top()->m_expirationTime.value() *
1e6),
&status);
}
@@ -114,7 +114,7 @@ void Watchdog::Impl::Main() {
watchdog->m_lastTimeoutPrintTime = now;
if (!watchdog->m_suppressTimeoutMessage) {
FRC_ReportError(warn::Warning, "Watchdog not fed within {:.6f}s",
watchdog->m_timeout.to<double>());
watchdog->m_timeout.value());
}
}

View File

@@ -42,6 +42,10 @@ int PWMMotorController::GetChannel() const {
return m_pwm.GetChannel();
}
void PWMMotorController::EnableDeadbandElimination(bool eliminateDeadband) {
m_pwm.EnableDeadbandElimination(eliminateDeadband);
}
PWMMotorController::PWMMotorController(std::string_view name, int channel)
: m_pwm(channel, false) {
wpi::SendableRegistry::AddLW(this, name, channel);

View File

@@ -16,9 +16,9 @@ ADXRS450_GyroSim::ADXRS450_GyroSim(const frc::ADXRS450_Gyro& gyro) {
}
void ADXRS450_GyroSim::SetAngle(units::degree_t angle) {
m_simAngle.Set(angle.to<double>());
m_simAngle.Set(angle.value());
}
void ADXRS450_GyroSim::SetRate(units::degrees_per_second_t rate) {
m_simRate.Set(rate.to<double>());
m_simRate.Set(rate.value());
}

View File

@@ -19,7 +19,7 @@ void AnalogEncoderSim::SetPosition(frc::Rotation2d angle) {
}
void AnalogEncoderSim::SetTurns(units::turn_t turns) {
m_positionSim.Set(turns.to<double>());
m_positionSim.Set(turns.value());
}
units::turn_t AnalogEncoderSim::GetTurns() {

View File

@@ -49,7 +49,7 @@ Eigen::Vector<double, 2> DifferentialDrivetrainSim::ClampInput(
void DifferentialDrivetrainSim::SetInputs(units::volt_t leftVoltage,
units::volt_t rightVoltage) {
m_u << leftVoltage.to<double>(), rightVoltage.to<double>();
m_u << leftVoltage.value(), rightVoltage.value();
m_u = ClampInput(m_u);
}
@@ -93,10 +93,10 @@ Pose2d DifferentialDrivetrainSim::GetPose() const {
units::ampere_t DifferentialDrivetrainSim::GetLeftCurrentDraw() const {
auto loadIleft =
m_motor.Current(units::radians_per_second_t(m_x(State::kLeftVelocity) *
m_currentGearing /
m_wheelRadius.to<double>()),
units::volt_t(m_u(0))) *
m_motor.Current(
units::radians_per_second_t(m_x(State::kLeftVelocity) *
m_currentGearing / m_wheelRadius.value()),
units::volt_t(m_u(0))) *
wpi::sgn(m_u(0));
return loadIleft;
@@ -104,10 +104,10 @@ units::ampere_t DifferentialDrivetrainSim::GetLeftCurrentDraw() const {
units::ampere_t DifferentialDrivetrainSim::GetRightCurrentDraw() const {
auto loadIRight =
m_motor.Current(units::radians_per_second_t(m_x(State::kRightVelocity) *
m_currentGearing /
m_wheelRadius.to<double>()),
units::volt_t(m_u(1))) *
m_motor.Current(
units::radians_per_second_t(m_x(State::kRightVelocity) *
m_currentGearing / m_wheelRadius.value()),
units::volt_t(m_u(1))) *
wpi::sgn(m_u(1));
return loadIRight;
@@ -122,9 +122,9 @@ void DifferentialDrivetrainSim::SetState(
}
void DifferentialDrivetrainSim::SetPose(const frc::Pose2d& pose) {
m_x(State::kX) = pose.X().to<double>();
m_x(State::kY) = pose.Y().to<double>();
m_x(State::kHeading) = pose.Rotation().Radians().to<double>();
m_x(State::kX) = pose.X().value();
m_x(State::kY) = pose.Y().value();
m_x(State::kHeading) = pose.Rotation().Radians().value();
m_x(State::kLeftPosition) = 0;
m_x(State::kRightPosition) = 0;
}
@@ -154,7 +154,7 @@ Eigen::Vector<double, 7> DifferentialDrivetrainSim::Dynamics(
xdot(1) = v * std::sin(x(State::kHeading));
xdot(2) =
((x(State::kRightVelocity) - x(State::kLeftVelocity)) / (2.0 * m_rb))
.to<double>();
.value();
xdot.block<4, 1>(3, 0) = A * x.block<4, 1>(3, 0) + B * u;
return xdot;
}

View File

@@ -17,7 +17,7 @@ DutyCycleEncoderSim::DutyCycleEncoderSim(const frc::DutyCycleEncoder& encoder) {
}
void DutyCycleEncoderSim::Set(units::turn_t turns) {
m_simPosition.Set(turns.to<double>());
m_simPosition.Set(turns.value());
}
void DutyCycleEncoderSim::SetDistance(double distance) {

View File

@@ -78,7 +78,7 @@ units::ampere_t ElevatorSim::GetCurrentDraw() const {
}
void ElevatorSim::SetInputVoltage(units::volt_t voltage) {
SetInput(Eigen::Vector<double, 1>{voltage.to<double>()});
SetInput(Eigen::Vector<double, 1>{voltage.value()});
}
Eigen::Vector<double, 2> ElevatorSim::UpdateX(
@@ -93,10 +93,10 @@ Eigen::Vector<double, 2> ElevatorSim::UpdateX(
currentXhat, u, dt);
// Check for collision after updating x-hat.
if (WouldHitLowerLimit(units::meter_t(updatedXhat(0)))) {
return Eigen::Vector<double, 2>{m_minHeight.to<double>(), 0.0};
return Eigen::Vector<double, 2>{m_minHeight.value(), 0.0};
}
if (WouldHitUpperLimit(units::meter_t(updatedXhat(0)))) {
return Eigen::Vector<double, 2>{m_maxHeight.to<double>(), 0.0};
return Eigen::Vector<double, 2>{m_maxHeight.value(), 0.0};
}
return updatedXhat;
}

View File

@@ -38,5 +38,5 @@ units::ampere_t FlywheelSim::GetCurrentDraw() const {
}
void FlywheelSim::SetInputVoltage(units::volt_t voltage) {
SetInput(Eigen::Vector<double, 1>{voltage.to<double>()});
SetInput(Eigen::Vector<double, 1>{voltage.value()});
}

View File

@@ -43,7 +43,7 @@ units::volt_t RoboRioSim::GetVInVoltage() {
}
void RoboRioSim::SetVInVoltage(units::volt_t vInVoltage) {
HALSIM_SetRoboRioVInVoltage(vInVoltage.to<double>());
HALSIM_SetRoboRioVInVoltage(vInVoltage.value());
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterVInCurrentCallback(
@@ -60,7 +60,7 @@ units::ampere_t RoboRioSim::GetVInCurrent() {
}
void RoboRioSim::SetVInCurrent(units::ampere_t vInCurrent) {
HALSIM_SetRoboRioVInCurrent(vInCurrent.to<double>());
HALSIM_SetRoboRioVInCurrent(vInCurrent.value());
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserVoltage6VCallback(
@@ -77,7 +77,7 @@ units::volt_t RoboRioSim::GetUserVoltage6V() {
}
void RoboRioSim::SetUserVoltage6V(units::volt_t userVoltage6V) {
HALSIM_SetRoboRioUserVoltage6V(userVoltage6V.to<double>());
HALSIM_SetRoboRioUserVoltage6V(userVoltage6V.value());
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserCurrent6VCallback(
@@ -94,7 +94,7 @@ units::ampere_t RoboRioSim::GetUserCurrent6V() {
}
void RoboRioSim::SetUserCurrent6V(units::ampere_t userCurrent6V) {
HALSIM_SetRoboRioUserCurrent6V(userCurrent6V.to<double>());
HALSIM_SetRoboRioUserCurrent6V(userCurrent6V.value());
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserActive6VCallback(
@@ -128,7 +128,7 @@ units::volt_t RoboRioSim::GetUserVoltage5V() {
}
void RoboRioSim::SetUserVoltage5V(units::volt_t userVoltage5V) {
HALSIM_SetRoboRioUserVoltage5V(userVoltage5V.to<double>());
HALSIM_SetRoboRioUserVoltage5V(userVoltage5V.value());
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserCurrent5VCallback(
@@ -145,7 +145,7 @@ units::ampere_t RoboRioSim::GetUserCurrent5V() {
}
void RoboRioSim::SetUserCurrent5V(units::ampere_t userCurrent5V) {
HALSIM_SetRoboRioUserCurrent5V(userCurrent5V.to<double>());
HALSIM_SetRoboRioUserCurrent5V(userCurrent5V.value());
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserActive5VCallback(
@@ -179,7 +179,7 @@ units::volt_t RoboRioSim::GetUserVoltage3V3() {
}
void RoboRioSim::SetUserVoltage3V3(units::volt_t userVoltage3V3) {
HALSIM_SetRoboRioUserVoltage3V3(userVoltage3V3.to<double>());
HALSIM_SetRoboRioUserVoltage3V3(userVoltage3V3.value());
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserCurrent3V3Callback(
@@ -196,7 +196,7 @@ units::ampere_t RoboRioSim::GetUserCurrent3V3() {
}
void RoboRioSim::SetUserCurrent3V3(units::ampere_t userCurrent3V3) {
HALSIM_SetRoboRioUserCurrent3V3(userCurrent3V3.to<double>());
HALSIM_SetRoboRioUserCurrent3V3(userCurrent3V3.value());
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserActive3V3Callback(
@@ -281,7 +281,7 @@ units::volt_t RoboRioSim::GetBrownoutVoltage() {
}
void RoboRioSim::SetBrownoutVoltage(units::volt_t vInVoltage) {
HALSIM_SetRoboRioBrownoutVoltage(vInVoltage.to<double>());
HALSIM_SetRoboRioBrownoutVoltage(vInVoltage.value());
}
void RoboRioSim::ResetData() {

View File

@@ -41,11 +41,11 @@ bool IsTimingPaused() {
}
void StepTiming(units::second_t delta) {
HALSIM_StepTiming(static_cast<uint64_t>(delta.to<double>() * 1e6));
HALSIM_StepTiming(static_cast<uint64_t>(delta.value() * 1e6));
}
void StepTimingAsync(units::second_t delta) {
HALSIM_StepTimingAsync(static_cast<uint64_t>(delta.to<double>() * 1e6));
HALSIM_StepTimingAsync(static_cast<uint64_t>(delta.value() * 1e6));
}
} // namespace frc::sim

View File

@@ -72,7 +72,7 @@ units::ampere_t SingleJointedArmSim::GetCurrentDraw() const {
}
void SingleJointedArmSim::SetInputVoltage(units::volt_t voltage) {
SetInput(Eigen::Vector<double, 1>{voltage.to<double>()});
SetInput(Eigen::Vector<double, 1>{voltage.value()});
}
Eigen::Vector<double, 2> SingleJointedArmSim::UpdateX(
@@ -96,7 +96,7 @@ Eigen::Vector<double, 2> SingleJointedArmSim::UpdateX(
xdot += Eigen::Vector<double, 2>{
0.0, (m_mass * m_r * -9.8 * 3.0 / (m_mass * m_r * m_r) *
std::cos(x(0)))
.template to<double>()};
.value()};
}
return xdot;
},
@@ -104,9 +104,9 @@ Eigen::Vector<double, 2> SingleJointedArmSim::UpdateX(
// Check for collisions.
if (WouldHitLowerLimit(units::radian_t(updatedXhat(0)))) {
return Eigen::Vector<double, 2>{m_minAngle.to<double>(), 0.0};
return Eigen::Vector<double, 2>{m_minAngle.value(), 0.0};
} else if (WouldHitUpperLimit(units::radian_t(updatedXhat(0)))) {
return Eigen::Vector<double, 2>{m_maxAngle.to<double>(), 0.0};
return Eigen::Vector<double, 2>{m_maxAngle.value(), 0.0};
}
return updatedXhat;
}

View File

@@ -20,5 +20,5 @@ void UltrasonicSim::SetRangeValid(bool isValid) {
}
void UltrasonicSim::SetRange(units::meter_t range) {
m_simRange.Set(range.to<double>());
m_simRange.Set(range.value());
}

View File

@@ -87,9 +87,9 @@ void FieldObject2d::UpdateEntry(bool setDefault) {
wpi::SmallVector<double, 9> arr;
for (auto&& pose : m_poses) {
auto& translation = pose.Translation();
arr.push_back(translation.X().to<double>());
arr.push_back(translation.Y().to<double>());
arr.push_back(pose.Rotation().Degrees().to<double>());
arr.push_back(translation.X().value());
arr.push_back(translation.Y().value());
arr.push_back(pose.Rotation().Degrees().value());
}
if (setDefault) {
m_entry.SetDefaultDoubleArray(arr);
@@ -104,13 +104,13 @@ void FieldObject2d::UpdateEntry(bool setDefault) {
for (auto&& pose : m_poses) {
auto& translation = pose.Translation();
wpi::support::endian::write64be(
p, wpi::DoubleToBits(translation.X().to<double>()));
p, wpi::DoubleToBits(translation.X().value()));
p += 8;
wpi::support::endian::write64be(
p, wpi::DoubleToBits(translation.Y().to<double>()));
p, wpi::DoubleToBits(translation.Y().value()));
p += 8;
wpi::support::endian::write64be(
p, wpi::DoubleToBits(pose.Rotation().Degrees().to<double>()));
p, wpi::DoubleToBits(pose.Rotation().Degrees().value()));
p += 8;
}
if (setDefault) {

View File

@@ -14,7 +14,7 @@ MechanismLigament2d::MechanismLigament2d(std::string_view name, double length,
const frc::Color8Bit& color)
: MechanismObject2d(name),
m_length{length},
m_angle{angle.to<double>()},
m_angle{angle.value()},
m_weight{lineWeight} {
SetColor(color);
}
@@ -40,7 +40,7 @@ void MechanismLigament2d::SetColor(const Color8Bit& color) {
void MechanismLigament2d::SetAngle(units::degree_t angle) {
std::scoped_lock lock(m_mutex);
m_angle = angle.to<double>();
m_angle = angle.value();
Flush();
}

View File

@@ -16,7 +16,7 @@
namespace frc {
/**
* Class for handling asynchronous interrupts.
* Class for handling asynchronous interrupts using a callback thread.
*
* <p> By default, interrupts will occur on rising edge. Callbacks are disabled
* by default, and Enable() must be called before they will occur.
@@ -24,7 +24,8 @@ namespace frc {
* <p> Both rising and falling edges can be indicated in one callback if both a
* rising and falling edge occurred since the previous callback.
*
* <p>Synchronous interrupts are handled by the SynchronousInterrupt class.
* <p>Synchronous (blocking) interrupts are handled by the SynchronousInterrupt
* class.
*/
class AsynchronousInterrupt {
public:
@@ -33,7 +34,12 @@ class AsynchronousInterrupt {
*
* <p> At construction, the interrupt will trigger on the rising edge.
*
* <p> The first bool in the callback is rising, the second is falling.
* <p> The first bool in the callback indicates the rising edge triggered the
* interrupt, the second bool is falling edge.
*
* @param source the DigitalSource the interrupts are triggered from
* @param callback the callback function to call when the interrupt is
* triggered
*/
AsynchronousInterrupt(DigitalSource& source,
std::function<void(bool, bool)> callback);
@@ -43,7 +49,12 @@ class AsynchronousInterrupt {
*
* <p> At construction, the interrupt will trigger on the rising edge.
*
* <p> The first bool in the callback is rising, the 2nd is falling.
* <p> The first bool in the callback indicates the rising edge triggered the
* interrupt, the second bool is falling edge.
*
* @param source the DigitalSource the interrupts are triggered from
* @param callback the callback function to call when the interrupt is
* triggered
*/
AsynchronousInterrupt(DigitalSource* source,
std::function<void(bool, bool)> callback);
@@ -53,7 +64,12 @@ class AsynchronousInterrupt {
*
* <p> At construction, the interrupt will trigger on the rising edge.
*
* <p> The first bool in the callback is rising, the 2nd is falling.
* <p> The first bool in the callback indicates the rising edge triggered the
* interrupt, the second bool is falling edge.
*
* @param source the DigitalSource the interrupts are triggered from
* @param callback the callback function to call when the interrupt is
* triggered
*/
AsynchronousInterrupt(std::shared_ptr<DigitalSource> source,
std::function<void(bool, bool)> callback);
@@ -63,7 +79,10 @@ class AsynchronousInterrupt {
*
* <p> At construction, the interrupt will trigger on the rising edge.
*
* <p> The first bool in the callback is rising, the 2nd is falling.
* @param source the DigitalSource the interrupts are triggered from
* @param f the callback function to call when the interrupt is triggered
* @param arg the first argument, interrupt was triggered on rising edge
* @param args the remaing arguments, interrupt was triggered on falling edge
*/
template <typename Callable, typename Arg, typename... Args>
AsynchronousInterrupt(DigitalSource& source, Callable&& f, Arg&& arg,
@@ -77,7 +96,10 @@ class AsynchronousInterrupt {
*
* <p> At construction, the interrupt will trigger on the rising edge.
*
* <p> The first bool in the callback is rising, the 2nd is falling.
* @param source the DigitalSource the interrupts are triggered from
* @param f the callback function to call when the interrupt is triggered
* @param arg the first argument, interrupt was triggered on rising edge
* @param args the remaing arguments, interrupt was triggered on falling edge
*/
template <typename Callable, typename Arg, typename... Args>
AsynchronousInterrupt(DigitalSource* source, Callable&& f, Arg&& arg,
@@ -91,7 +113,10 @@ class AsynchronousInterrupt {
*
* <p> At construction, the interrupt will trigger on the rising edge.
*
* <p> The first bool in the callback is rising, the 2nd is falling.
* @param source the DigitalSource the interrupts are triggered from
* @param f the callback function to call when the interrupt is triggered
* @param arg the first argument, interrupt was triggered on rising edge
* @param args the remaing arguments, interrupt was triggered on falling edge
*/
template <typename Callable, typename Arg, typename... Args>
AsynchronousInterrupt(std::shared_ptr<DigitalSource> source, Callable&& f,
@@ -127,7 +152,7 @@ class AsynchronousInterrupt {
* <p>This function does not require the interrupt to be enabled to work.
*
* <p>This only works if rising edge was configured using SetInterruptEdges.
* @return the timestamp in seconds relative to getFPGATime
* @return the timestamp in seconds relative to GetFPGATime
*/
units::second_t GetRisingTimestamp();
@@ -137,7 +162,7 @@ class AsynchronousInterrupt {
* <p>This function does not require the interrupt to be enabled to work.
*
* <p>This only works if falling edge was configured using SetInterruptEdges.
* @return the timestamp in seconds relative to getFPGATime
* @return the timestamp in seconds relative to GetFPGATime
*/
units::second_t GetFallingTimestamp();

View File

@@ -27,8 +27,8 @@ class DMASample : public HAL_DMASample {
DMAReadStatus Update(const DMA* dma, units::second_t timeout,
int32_t* remaining, int32_t* status) {
return static_cast<DMAReadStatus>(HAL_ReadDMA(
dma->dmaHandle, this, timeout.to<double>(), remaining, status));
return static_cast<DMAReadStatus>(
HAL_ReadDMA(dma->dmaHandle, this, timeout.value(), remaining, status));
}
uint64_t GetTime() const { return timeStamp; }

View File

@@ -87,10 +87,11 @@ inline void ReportError(int32_t status, const char* fileName, int lineNumber,
* instead.
*
* @param[out] status error code
* @param[in] message error message details
* @param[in] fileName source file name
* @param[in] lineNumber source line number
* @param[in] funcName source function name
* @param[in] format error message format
* @param[in] args error message format args
* @return runtime error object
*/
[[nodiscard]] RuntimeError MakeErrorV(int32_t status, const char* fileName,

View File

@@ -13,12 +13,12 @@
#include "PneumaticsBase.h"
namespace frc {
class PneumaticsHub : public PneumaticsBase {
class PneumaticHub : public PneumaticsBase {
public:
PneumaticsHub();
explicit PneumaticsHub(int module);
PneumaticHub();
explicit PneumaticHub(int module);
~PneumaticsHub() override = default;
~PneumaticHub() override = default;
bool GetCompressor() const override;
@@ -61,7 +61,7 @@ class PneumaticsHub : public PneumaticsBase {
class DataStore;
friend class DataStore;
friend class PneumaticsBase;
PneumaticsHub(HAL_REVPHHandle handle, int module);
PneumaticHub(HAL_REVPHHandle handle, int module);
static std::shared_ptr<PneumaticsBase> GetForModule(int module);

View File

@@ -11,6 +11,8 @@ namespace frc {
/**
* Interface for speed controlling devices.
*
* @deprecated Use MotorController.
*/
class WPI_DEPRECATED("use MotorController") SpeedController {
public:

View File

@@ -15,6 +15,11 @@
namespace frc {
/**
* Allows multiple SpeedController objects to be linked together.
*
* @deprecated Use MotorControllerGroup.
*/
class WPI_DEPRECATED("use MotorControllerGroup") SpeedControllerGroup
: public wpi::Sendable,
public MotorController,

View File

@@ -13,7 +13,7 @@ namespace frc {
class DigitalSource;
/**
* Class for handling ssynchronous interrupts.
* Class for handling synchronous (blocking) interrupts.
*
* <p> By default, interrupts will occur on rising edge.
*
@@ -30,16 +30,22 @@ class SynchronousInterrupt {
/**
* Construct a Synchronous Interrupt from a Digital Source.
*
* @param source the DigitalSource the interrupts are triggered from
*/
explicit SynchronousInterrupt(DigitalSource& source);
/**
* Construct a Synchronous Interrupt from a Digital Source.
*
* @param source the DigitalSource the interrupts are triggered from
*/
explicit SynchronousInterrupt(DigitalSource* source);
/**
* Construct a Synchronous Interrupt from a Digital Source.
*
* @param source the DigitalSource the interrupts are triggered from
*/
explicit SynchronousInterrupt(std::shared_ptr<DigitalSource> source);
@@ -72,6 +78,8 @@ class SynchronousInterrupt {
/**
* Get the timestamp (relative to FPGA Time) of the last rising edge.
*
* @return the timestamp in seconds relative to getFPGATime
*/
units::second_t GetRisingTimestamp();

View File

@@ -138,8 +138,7 @@ class DifferentialDrive : public RobotDriveBase,
*
* The rotation argument controls the curvature of the robot's path rather
* than its rate of heading change. This makes the robot more controllable at
* high speeds. Also handles the robot's quick turn functionality - "quick
* turn" overrides constant-curvature turning for turn-in-place maneuvers.
* high speeds.
*
* @param xSpeed The robot's speed along the X axis [-1.0..1.0].
* Forward is positive.
@@ -181,8 +180,7 @@ class DifferentialDrive : public RobotDriveBase,
*
* The rotation argument controls the curvature of the robot's path rather
* than its rate of heading change. This makes the robot more controllable at
* high speeds. Also handles the robot's quick turn functionality - "quick
* turn" overrides constant-curvature turning for turn-in-place maneuvers.
* high speeds.
*
* @param xSpeed The robot's speed along the X axis [-1.0..1.0].
* Forward is positive.

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