Skip to content

Commit dcd397e

Browse files
authored
[xrp] Update XRP for new SparkFun RP2350 Board (#7880)
Enables servos 3 and 4 usage on the new XRP board.
1 parent 1efaaef commit dcd397e

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

simulation/halsim_xrp/src/main/native/cpp/XRP.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ void XRP::HandleServoSimValueChanged(const wpi::json& data) {
142142
deviceId = 4;
143143
} else if (data["device"] == "servo2") {
144144
deviceId = 5;
145+
} else if (data["device"] == "servo3") {
146+
deviceId = 6;
147+
} else if (data["device"] == "servo4") {
148+
deviceId = 7;
145149
}
146150

147151
if (deviceId != -1 && servoData.find("<position") != servoData.end()) {

xrpVendordep/src/main/java/edu/wpi/first/wpilibj/xrp/XRPServo.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class XRPServo {
2121

2222
private static void checkDeviceAllocation(int deviceNum) {
2323
if (!s_simDeviceNameMap.containsKey(deviceNum)) {
24-
throw new IllegalArgumentException("Invalid XRPServo device number. Should be 4-5");
24+
throw new IllegalArgumentException("Invalid XRPServo device number. Should be 4-7");
2525
}
2626

2727
if (s_registeredDevices.contains(deviceNum)) {
@@ -34,6 +34,8 @@ private static void checkDeviceAllocation(int deviceNum) {
3434
static {
3535
s_simDeviceNameMap.put(4, "servo1");
3636
s_simDeviceNameMap.put(5, "servo2");
37+
s_simDeviceNameMap.put(6, "servo3");
38+
s_simDeviceNameMap.put(7, "servo4");
3739
}
3840

3941
private final SimDouble m_simPosition;

xrpVendordep/src/main/native/cpp/xrp/XRPServo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
using namespace frc;
1717

18-
std::map<int, std::string> XRPServo::s_simDeviceMap = {{4, "servo1"},
19-
{5, "servo2"}};
18+
std::map<int, std::string> XRPServo::s_simDeviceMap = {
19+
{4, "servo1"}, {5, "servo2"}, {6, "servo3"}, {7, "servo4"}};
2020

2121
std::set<int> XRPServo::s_registeredDevices = {};
2222

0 commit comments

Comments
 (0)