Skip to content

Commit 5cdfa61

Browse files
committed
added GearboxProto.java, adjusted DCMotorProto.java
1 parent 46869f6 commit 5cdfa61

2 files changed

Lines changed: 42 additions & 2 deletions

File tree

wpimath/src/main/java/org/wpilib/math/system/proto/DCMotorProto.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ public DCMotor unpack(ProtobufDCMotor msg) {
3232
msg.getStallTorque(),
3333
msg.getStallCurrent(),
3434
msg.getFreeCurrent(),
35-
msg.getFreeSpeed(),
36-
1);
35+
msg.getFreeSpeed());
3736
}
3837

3938
@Override
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package org.wpilib.math.system.proto;
6+
7+
import org.wpilib.math.proto.ProtobufGearbox;
8+
import org.wpilib.math.system.DCMotor;
9+
import org.wpilib.math.system.Gearbox;
10+
import org.wpilib.util.protobuf.Protobuf;
11+
import us.hebi.quickbuf.Descriptors.Descriptor;
12+
13+
public class GearboxProto implements Protobuf<Gearbox, ProtobufGearbox> {
14+
@Override
15+
public Class<Gearbox> getTypeClass() {
16+
return Gearbox.class;
17+
}
18+
19+
@Override
20+
public Descriptor getDescriptor() {
21+
return ProtobufGearbox.getDescriptor();
22+
}
23+
24+
@Override
25+
public ProtobufGearbox createMessage() {
26+
return ProtobufGearbox.newInstance();
27+
}
28+
29+
@Override
30+
public Gearbox unpack(ProtobufGearbox msg) {
31+
return new Gearbox(
32+
DCMotor.proto.unpack(msg.getMotor()), msg.getNumMotors(), msg.getReduction());
33+
}
34+
35+
@Override
36+
public void pack(ProtobufGearbox msg, Gearbox value) {
37+
DCMotor.proto.pack(msg.getMutableMotor(), value.motor);
38+
msg.setNumMotors(value.numMotors);
39+
msg.setReduction(value.reduction);
40+
}
41+
}

0 commit comments

Comments
 (0)