Skip to content

Commit a4cc473

Browse files
committed
Added operator== to pwm_array
1 parent c452e89 commit a4cc473

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Command.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
#pragma once
1+
#ifndef COMMAND_HPP
2+
#define COMMAND_HPP
23
#include <vector>
34
#include <chrono>
45

56
// A command is a simple instruction to the vehicle
67
// Commands will be combined in sequencing to create more complex instructions
78

9+
810
enum Direction {Forwards, Backwards};
911

1012
struct force_array{
@@ -14,6 +16,15 @@ struct pwm_array {
1416
int pwm_signals[8];
1517
};
1618

19+
bool inline operator==(const pwm_array& lhs, const pwm_array& rhs) {
20+
for (int i = 0; i < 8; i++) {
21+
if (lhs.pwm_signals[i] != rhs.pwm_signals[i]) {
22+
return false;
23+
}
24+
}
25+
return true;
26+
}
27+
1728
struct CommandComponent {
1829
pwm_array thruster_pwms; // PWM values for each thruster
1930
std::chrono::milliseconds duration; // Duration of the command in milliseconds
@@ -29,3 +40,5 @@ struct Sequence {
2940
std::vector<Command> commands;
3041
};
3142

43+
#endif
44+

0 commit comments

Comments
 (0)