Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
hold_repeat_command_mapping.hpp
Go to the documentation of this file.
1/*****************************************************************************/
2/********** !!! WARNING: CODE GENERATED BY TAPROOT. DO NOT EDIT !!! **********/
3/*****************************************************************************/
4
5/*
6 * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington <robomstr@uw.edu>
7 *
8 * This file is part of Taproot.
9 *
10 * Taproot is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * Taproot is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with Taproot. If not, see <https://www.gnu.org/licenses/>.
22 */
23
24#ifndef TAPROOT_HOLD_REPEAT_COMMAND_MAPPING_HPP_
25#define TAPROOT_HOLD_REPEAT_COMMAND_MAPPING_HPP_
26
27#include "command_mapping.hpp"
28
29namespace tap
30{
31namespace control
32{
33class Command;
34class RemoteMapState;
35
48{
49public:
65 const std::vector<Command *> cmds,
66 const RemoteMapState &rms,
68 int maxTimesToSchedule = -1)
69 : CommandMapping(drivers, cmds, rms),
70 held(false),
74 {
75 }
76
80 ~HoldRepeatCommandMapping() override = default;
81
82 void executeCommandMapping(const RemoteMapState &currState) override;
83
85 inline mockable void setMaxTimesToSchedule(int maxTimes) { maxTimesToSchedule = maxTimes; }
86
87protected:
88 bool held;
91 std::vector<int> rescheduleCounts;
92
93 inline void incrementRescheduleCount(int cmdIndex)
94 {
95 if (maxTimesToSchedule != -1)
96 {
97 rescheduleCounts[cmdIndex] += 1;
98 }
99 }
100
101 inline bool okToScheduleCommand(int cmdIndex) const
102 {
103 return (maxTimesToSchedule == -1) || (rescheduleCounts[cmdIndex] < maxTimesToSchedule);
104 }
105}; // class HoldRepeatCommandMapping
106} // namespace control
107} // namespace tap
108
109#endif // TAPROOT_HOLD_REPEAT_COMMAND_MAPPING_HPP_
Definition drivers.hpp:70
Definition command_mapping.hpp:48
Drivers * drivers
Definition command_mapping.hpp:117
std::vector< Command * > mappedCommands
Definition command_mapping.hpp:115
Definition hold_repeat_command_mapping.hpp:48
void incrementRescheduleCount(int cmdIndex)
Definition hold_repeat_command_mapping.hpp:93
bool okToScheduleCommand(int cmdIndex) const
Definition hold_repeat_command_mapping.hpp:101
bool held
Definition hold_repeat_command_mapping.hpp:88
std::vector< int > rescheduleCounts
Definition hold_repeat_command_mapping.hpp:91
void executeCommandMapping(const RemoteMapState &currState) override
Definition hold_repeat_command_mapping.cpp:32
~HoldRepeatCommandMapping() override=default
bool endCommandsWhenNotHeld
Definition hold_repeat_command_mapping.hpp:89
mockable void setMaxTimesToSchedule(int maxTimes)
Set the maximum times each of commands should be re-scheduled.
Definition hold_repeat_command_mapping.hpp:85
int maxTimesToSchedule
Definition hold_repeat_command_mapping.hpp:90
HoldRepeatCommandMapping(Drivers *drivers, const std::vector< Command * > cmds, const RemoteMapState &rms, bool endCommandsWhenNotHeld, int maxTimesToSchedule=-1)
Definition hold_repeat_command_mapping.hpp:63
Definition remote_map_state.hpp:56
Definition ballistics.cpp:29
#define mockable
Wrap class functions that are not already virtual in this function if you wish to mock them.
Definition util_macros.hpp:38