forked from wpilibsuite/allwpilib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
609894f
commit ba6fe12
Showing
2 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 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. | ||
|
||
#include <wpi/protobuf/Protobuf.h> | ||
|
||
#include "frc/system/plant/DCMotor.h" | ||
#include "plant.pb.h" | ||
|
||
int main(int arc, char** argv) { | ||
const frc::DCMotor kExpectedData = frc::DCMotor{units::volt_t{1.91}, | ||
units::newton_meter_t{19.1}, | ||
units::ampere_t{1.74}, | ||
units::ampere_t{2.29}, | ||
units::radians_per_second_t{2.2}, | ||
2}; | ||
google::protobuf::Arena arena; | ||
google::protobuf::Message* proto = wpi::Protobuf<frc::DCMotor>::New(&arena); | ||
wpi::PackProtobuf(proto, kExpectedData); | ||
frc::DCMotor unpacked_data = wpi::UnpackProtobuf<frc::DCMotor>(*proto); | ||
|
||
if (unpacked_data.nominalVoltage.value() != kExpectedData.nominalVoltage.value()) { | ||
return 1; | ||
} | ||
return 0; | ||
} |