NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
command_repo.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 
20 #ifndef JSONLOADER_COMMAND_REPO_H_
21 #define JSONLOADER_COMMAND_REPO_H_
22 
23 #include <jsonloader/command.h>
24 
25 #include <string>
26 
27 namespace jsonloader {
28 
29 // Command names
30 constexpr char kCmdDock[] = "dock";
31 constexpr char kCmdUndock[] = "undock";
32 constexpr char kCmdPerch[] = "perch";
33 constexpr char kCmdUnperch[] = "unperch";
34 constexpr char kCmdPause[] = "pausePlan";
35 constexpr char kCmdArmPanTilt[] = "armPanAndTilt";
36 constexpr char kCmdStationKeep[] = "stationKeep";
37 constexpr char kCmdWait[] = "wait";
38 constexpr char kCmdPayloadOn[] = "payloadOn";
39 constexpr char kCmdPowerOn[] = "powerOnItem";
40 constexpr char kCmdPayloadOff[] = "payloadOff";
41 constexpr char kCmdPowerOff[] = "powerOffItem";
42 constexpr char kCmdStartGuest[] = "startGuestScience";
43 constexpr char kCmdStopGuest[] = "stopGuestScience";
44 constexpr char kCmdGuestCmd[] = "guestScience";
45 constexpr char kCmdCustomGuest[] = "customGuestScience";
46 constexpr char kCmdGripper[] = "gripperControl";
47 constexpr char kCmdFlashlight[] = "setFlashlightBrightness";
48 constexpr char kCmdIdleProp[] = "idlePropulsion";
49 constexpr char kCmdSetCamera[] = "setCamera";
50 constexpr char kCmdStreamCamera[] = "setCameraStreaming";
51 constexpr char kCmdRecordCamera[] = "setCameraRecording";
52 constexpr char kCmdInitBias[] = "initializeBias";
53 constexpr char kCmdChkObstacles[] = "setCheckObstacles";
54 constexpr char kCmdChkZones[] = "setCheckZones";
55 constexpr char kCmdSetHolonomic[] = "setHolonomicMode";
56 constexpr char kCmdSetPlanner[] = "setPlanner";
57 constexpr char kCmdTelemRate[] = "setTelemetryRate";
58 constexpr char kCmdSwitchLocal[] = "switchLocalization";
59 constexpr char kCmdStartRecord[] = "startRecording";
60 constexpr char kCmdStopRecord[] = "stopRecording";
61 constexpr char kCmdEnableAstrobeeIntercomms[] = "enableAstrobeeIntercomms";
62 
63 class DockCommand : public Command {
64  public:
65  explicit DockCommand(Json::Value const& obj);
66 
67  int berth_number() const noexcept;
68 
69  private:
70  int berth_number_;
71 };
72 
73 class UndockCommand : public Command {
74  public:
75  explicit UndockCommand(Json::Value const& obj);
76 };
77 
78 class PerchCommand : public Command {
79  public:
80  explicit PerchCommand(Json::Value const& obj);
81 };
82 
83 class UnperchCommand : public Command {
84  public:
85  explicit UnperchCommand(Json::Value const& obj);
86 };
87 
88 class PauseCommand : public Command {
89  public:
90  explicit PauseCommand(Json::Value const& obj);
91 };
92 
93 // This is also the "Wait" command, but backwards compatibility dictates
94 // we keep it as it is.
95 class StationKeepCommand : public Command {
96  public:
97  explicit StationKeepCommand(Json::Value const& obj);
98 
99  float duration() const noexcept;
100 
101  private:
102  float duration_;
103 };
104 
106  public:
107  explicit ArmPanAndTiltCommand(Json::Value const& obj);
108 
109  float pan() const noexcept;
110  float tilt() const noexcept;
111  std::string const& which() const noexcept;
112 
113  private:
114  float pan_;
115  float tilt_;
116  std::string which_;
117 };
118 
119 class GripperCommand : public Command {
120  public:
121  explicit GripperCommand(Json::Value const& obj);
122 
123  bool open() const noexcept;
124 
125  private:
126  bool open_;
127 };
128 
129 // In plans this is called "PayloadOn"/"PayloadOff", but will be changed to
130 // match the RAPID command soon, which is powerOnItem/powerOffItem (for now)
131 class PowerItemCommand : public Command {
132  public:
133  explicit PowerItemCommand(Json::Value const& obj);
134 
135  std::string const& which() const noexcept;
136  int id() const noexcept;
137 
138  private:
139  std::string which_;
140 };
141 
142 class GuestScienceCommand : public Command {
143  public:
144  explicit GuestScienceCommand(Json::Value const& obj);
145 
146  std::string const& apk() const noexcept;
147 
148  private:
149  std::string apk_;
150 };
151 
153  public:
154  explicit CustomGuestScienceCommand(Json::Value const& obj);
155 
156  std::string const& apk() const noexcept;
157  std::string const& command() const noexcept;
158 
159  private:
160  std::string apk_;
161  std::string command_;
162 };
163 
164 class FlashlightCommand : public Command {
165  public:
166  explicit FlashlightCommand(Json::Value const& obj);
167 
168  std::string const& which() const noexcept;
169  float brightness() const noexcept;
170 
171  private:
172  std::string which_;
173  float brightness_;
174 };
175 
177  public:
178  explicit IdlePropulsionCommand(Json::Value const& obj);
179 };
180 
181 class CameraCommand : public Command {
182  public:
183  explicit CameraCommand(Json::Value const& obj);
184 
185  std::string const& camera() const noexcept;
186 
187  private:
188  std::string camera_;
189 };
190 
192  public:
193  explicit SetCameraCommand(Json::Value const& obj);
194 
195  std::string const& mode() const noexcept;
196  float frame_rate() const noexcept;
197  float bandwidth() const noexcept;
198  std::string const& resolution() const noexcept;
199 
200  private:
201  std::string mode_;
202  float frame_rate_;
203  float bandwidth_;
204  std::string resolution_;
205 };
206 
208  public:
209  explicit RecordCameraCommand(Json::Value const& obj);
210 
211  bool record() const noexcept;
212 
213  private:
214  bool record_;
215 };
216 
218  public:
219  explicit StreamCameraCommand(Json::Value const& obj);
220 
221  bool stream() const noexcept;
222 
223  private:
224  bool stream_;
225 };
226 
228  public:
229  explicit InitializeBiasCommand(Json::Value const& obj);
230 };
231 
233  public:
234  explicit SetCheckObstaclesCommand(Json::Value const& obj);
235 
236  bool checkObstacles() const noexcept;
237 
238  private:
239  bool checkObstacles_;
240 };
241 
243  public:
244  explicit SetCheckZonesCommand(Json::Value const& obj);
245 
246  bool checkZones() const noexcept;
247 
248  private:
249  bool checkZones_;
250 };
251 
253  public:
254  explicit SetHolonomicModeCommand(Json::Value const& obj);
255 
256  bool enableHolonomic() const noexcept;
257 
258  private:
259  bool enableHolonomic_;
260 };
261 
262 class SetPlannerCommand : public Command {
263  public:
264  explicit SetPlannerCommand(Json::Value const& obj);
265 
266  std::string const& planner() const noexcept;
267 
268  private:
269  std::string planner_;
270 };
271 
273  public:
274  explicit SetTelemetryRateCommand(Json::Value const& obj);
275 
276  std::string const& telemetryName() const noexcept;
277  float rate() const noexcept;
278 
279  private:
280  std::string telemetryName_;
281  float rate_;
282 };
283 
285  public:
286  explicit SwitchLocalizationCommand(Json::Value const& obj);
287 
288  std::string const& mode() const noexcept;
289 
290  private:
291  std::string mode_;
292 };
293 
295  public:
296  explicit StartRecordingCommand(Json::Value const& obj);
297 
298  std::string const& description() const noexcept;
299 
300  private:
301  std::string description_;
302 };
303 
305  public:
306  explicit StopRecordingCommand(Json::Value const& obj);
307 };
308 
310  public:
311  explicit EnableAstrobeeIntercommsCommand(Json::Value const& obj);
312 };
313 
314 } // end namespace jsonloader
315 
316 #endif // JSONLOADER_COMMAND_REPO_H_
jsonloader::DockCommand::berth_number
int berth_number() const noexcept
Definition: command_repo.cc:212
jsonloader::EnableAstrobeeIntercommsCommand::EnableAstrobeeIntercommsCommand
EnableAstrobeeIntercommsCommand(Json::Value const &obj)
Definition: command_repo.cc:578
jsonloader::SetCheckObstaclesCommand::SetCheckObstaclesCommand
SetCheckObstaclesCommand(Json::Value const &obj)
Definition: command_repo.cc:456
jsonloader::kCmdStopGuest
constexpr char kCmdStopGuest[]
Definition: command_repo.h:43
jsonloader::StartRecordingCommand
Definition: command_repo.h:294
jsonloader::FlashlightCommand::which
std::string const & which() const noexcept
Definition: command_repo.cc:360
jsonloader::kCmdPowerOff
constexpr char kCmdPowerOff[]
Definition: command_repo.h:41
jsonloader::StopRecordingCommand::StopRecordingCommand
StopRecordingCommand(Json::Value const &obj)
Definition: command_repo.cc:573
jsonloader::kCmdChkObstacles
constexpr char kCmdChkObstacles[]
Definition: command_repo.h:53
jsonloader::kCmdIdleProp
constexpr char kCmdIdleProp[]
Definition: command_repo.h:48
jsonloader::kCmdRecordCamera
constexpr char kCmdRecordCamera[]
Definition: command_repo.h:51
jsonloader::DockCommand
Definition: command_repo.h:63
jsonloader::FlashlightCommand::brightness
float brightness() const noexcept
Definition: command_repo.cc:364
jsonloader::PowerItemCommand::which
std::string const & which() const noexcept
Definition: command_repo.cc:306
jsonloader::IdlePropulsionCommand
Definition: command_repo.h:176
jsonloader::PerchCommand::PerchCommand
PerchCommand(Json::Value const &obj)
Definition: command_repo.cc:221
jsonloader::kCmdPause
constexpr char kCmdPause[]
Definition: command_repo.h:34
jsonloader::kCmdSetHolonomic
constexpr char kCmdSetHolonomic[]
Definition: command_repo.h:55
jsonloader::GripperCommand::GripperCommand
GripperCommand(Json::Value const &obj)
Definition: command_repo.cc:262
jsonloader::SetHolonomicModeCommand::enableHolonomic
bool enableHolonomic() const noexcept
Definition: command_repo.cc:500
jsonloader::DockCommand::DockCommand
DockCommand(Json::Value const &obj)
Definition: command_repo.cc:200
jsonloader::kCmdGuestCmd
constexpr char kCmdGuestCmd[]
Definition: command_repo.h:44
jsonloader::SwitchLocalizationCommand
Definition: command_repo.h:284
jsonloader::UnperchCommand
Definition: command_repo.h:83
jsonloader::kCmdStopRecord
constexpr char kCmdStopRecord[]
Definition: command_repo.h:60
jsonloader::PowerItemCommand
Definition: command_repo.h:131
jsonloader::kCmdChkZones
constexpr char kCmdChkZones[]
Definition: command_repo.h:54
jsonloader::kCmdStationKeep
constexpr char kCmdStationKeep[]
Definition: command_repo.h:36
jsonloader::SetPlannerCommand
Definition: command_repo.h:262
jsonloader::StationKeepCommand::StationKeepCommand
StationKeepCommand(Json::Value const &obj)
Definition: command_repo.cc:278
jsonloader::kCmdSwitchLocal
constexpr char kCmdSwitchLocal[]
Definition: command_repo.h:58
jsonloader::StartRecordingCommand::StartRecordingCommand
StartRecordingCommand(Json::Value const &obj)
Definition: command_repo.cc:557
jsonloader::kCmdUndock
constexpr char kCmdUndock[]
Definition: command_repo.h:31
jsonloader::StreamCameraCommand::stream
bool stream() const noexcept
Definition: command_repo.cc:447
jsonloader::PauseCommand
Definition: command_repo.h:88
jsonloader::kCmdSetPlanner
constexpr char kCmdSetPlanner[]
Definition: command_repo.h:56
jsonloader::PowerItemCommand::PowerItemCommand
PowerItemCommand(Json::Value const &obj)
Definition: command_repo.cc:294
jsonloader::SetTelemetryRateCommand
Definition: command_repo.h:272
jsonloader::SetCameraCommand::frame_rate
float frame_rate() const noexcept
Definition: command_repo.cc:407
jsonloader::SetPlannerCommand::SetPlannerCommand
SetPlannerCommand(Json::Value const &obj)
Definition: command_repo.cc:504
jsonloader::kCmdCustomGuest
constexpr char kCmdCustomGuest[]
Definition: command_repo.h:45
jsonloader::kCmdPerch
constexpr char kCmdPerch[]
Definition: command_repo.h:32
jsonloader::SetTelemetryRateCommand::telemetryName
std::string const & telemetryName() const noexcept
Definition: command_repo.cc:533
jsonloader::FlashlightCommand::FlashlightCommand
FlashlightCommand(Json::Value const &obj)
Definition: command_repo.cc:347
jsonloader
Definition: command.h:28
jsonloader::SetCheckZonesCommand
Definition: command_repo.h:242
jsonloader::RecordCameraCommand::RecordCameraCommand
RecordCameraCommand(Json::Value const &obj)
Definition: command_repo.cc:419
command.h
jsonloader::GuestScienceCommand::apk
std::string const & apk() const noexcept
Definition: command_repo.cc:322
jsonloader::kCmdInitBias
constexpr char kCmdInitBias[]
Definition: command_repo.h:52
jsonloader::kCmdTelemRate
constexpr char kCmdTelemRate[]
Definition: command_repo.h:57
gpio::Value
Value
Definition: GPIO.h:42
jsonloader::SetCameraCommand::SetCameraCommand
SetCameraCommand(Json::Value const &obj)
Definition: command_repo.cc:387
jsonloader::SwitchLocalizationCommand::mode
std::string const & mode() const noexcept
Definition: command_repo.cc:553
jsonloader::SetTelemetryRateCommand::rate
float rate() const noexcept
Definition: command_repo.cc:537
jsonloader::PauseCommand::PauseCommand
PauseCommand(Json::Value const &obj)
Definition: command_repo.cc:231
jsonloader::SetHolonomicModeCommand
Definition: command_repo.h:252
jsonloader::StopRecordingCommand
Definition: command_repo.h:304
jsonloader::PowerItemCommand::id
int id() const noexcept
jsonloader::GuestScienceCommand::GuestScienceCommand
GuestScienceCommand(Json::Value const &obj)
Definition: command_repo.cc:310
jsonloader::CustomGuestScienceCommand::CustomGuestScienceCommand
CustomGuestScienceCommand(Json::Value const &obj)
Definition: command_repo.cc:326
jsonloader::kCmdFlashlight
constexpr char kCmdFlashlight[]
Definition: command_repo.h:47
jsonloader::kCmdPayloadOn
constexpr char kCmdPayloadOn[]
Definition: command_repo.h:38
jsonloader::ArmPanAndTiltCommand
Definition: command_repo.h:105
jsonloader::FlashlightCommand
Definition: command_repo.h:164
jsonloader::EnableAstrobeeIntercommsCommand
Definition: command_repo.h:309
jsonloader::Command
Definition: command.h:30
jsonloader::SetPlannerCommand::planner
std::string const & planner() const noexcept
Definition: command_repo.cc:516
jsonloader::ArmPanAndTiltCommand::tilt
float tilt() const noexcept
Definition: command_repo.cc:254
jsonloader::SetHolonomicModeCommand::SetHolonomicModeCommand
SetHolonomicModeCommand(Json::Value const &obj)
Definition: command_repo.cc:488
jsonloader::UndockCommand::UndockCommand
UndockCommand(Json::Value const &obj)
Definition: command_repo.cc:216
jsonloader::SetCameraCommand::resolution
std::string const & resolution() const noexcept
Definition: command_repo.cc:415
jsonloader::RecordCameraCommand
Definition: command_repo.h:207
jsonloader::SetCameraCommand
Definition: command_repo.h:191
jsonloader::SetCameraCommand::mode
std::string const & mode() const noexcept
Definition: command_repo.cc:403
jsonloader::kCmdStartRecord
constexpr char kCmdStartRecord[]
Definition: command_repo.h:59
jsonloader::RecordCameraCommand::record
bool record() const noexcept
Definition: command_repo.cc:431
jsonloader::SetCheckObstaclesCommand
Definition: command_repo.h:232
jsonloader::kCmdArmPanTilt
constexpr char kCmdArmPanTilt[]
Definition: command_repo.h:35
jsonloader::ArmPanAndTiltCommand::ArmPanAndTiltCommand
ArmPanAndTiltCommand(Json::Value const &obj)
Definition: command_repo.cc:236
jsonloader::CustomGuestScienceCommand::command
std::string const & command() const noexcept
Definition: command_repo.cc:343
jsonloader::kCmdPayloadOff
constexpr char kCmdPayloadOff[]
Definition: command_repo.h:40
jsonloader::CustomGuestScienceCommand
Definition: command_repo.h:152
jsonloader::CustomGuestScienceCommand::apk
std::string const & apk() const noexcept
Definition: command_repo.cc:339
jsonloader::GuestScienceCommand
Definition: command_repo.h:142
jsonloader::kCmdDock
constexpr char kCmdDock[]
Definition: command_repo.h:30
jsonloader::GripperCommand
Definition: command_repo.h:119
jsonloader::kCmdGripper
constexpr char kCmdGripper[]
Definition: command_repo.h:46
jsonloader::CameraCommand::camera
std::string const & camera() const noexcept
Definition: command_repo.cc:383
jsonloader::IdlePropulsionCommand::IdlePropulsionCommand
IdlePropulsionCommand(Json::Value const &obj)
Definition: command_repo.cc:368
jsonloader::CameraCommand
Definition: command_repo.h:181
jsonloader::kCmdStartGuest
constexpr char kCmdStartGuest[]
Definition: command_repo.h:42
jsonloader::kCmdSetCamera
constexpr char kCmdSetCamera[]
Definition: command_repo.h:49
jsonloader::SetTelemetryRateCommand::SetTelemetryRateCommand
SetTelemetryRateCommand(Json::Value const &obj)
Definition: command_repo.cc:520
jsonloader::StationKeepCommand::duration
float duration() const noexcept
Definition: command_repo.cc:290
jsonloader::SetCheckZonesCommand::checkZones
bool checkZones() const noexcept
Definition: command_repo.cc:484
jsonloader::kCmdWait
constexpr char kCmdWait[]
Definition: command_repo.h:37
jsonloader::GripperCommand::open
bool open() const noexcept
Definition: command_repo.cc:274
jsonloader::kCmdUnperch
constexpr char kCmdUnperch[]
Definition: command_repo.h:33
jsonloader::ArmPanAndTiltCommand::pan
float pan() const noexcept
Definition: command_repo.cc:250
jsonloader::SetCameraCommand::bandwidth
float bandwidth() const noexcept
Definition: command_repo.cc:411
jsonloader::StationKeepCommand
Definition: command_repo.h:95
jsonloader::InitializeBiasCommand::InitializeBiasCommand
InitializeBiasCommand(Json::Value const &obj)
Definition: command_repo.cc:451
jsonloader::StartRecordingCommand::description
std::string const & description() const noexcept
Definition: command_repo.cc:569
jsonloader::SetCheckObstaclesCommand::checkObstacles
bool checkObstacles() const noexcept
Definition: command_repo.cc:468
jsonloader::SwitchLocalizationCommand::SwitchLocalizationCommand
SwitchLocalizationCommand(Json::Value const &obj)
Definition: command_repo.cc:541
jsonloader::ArmPanAndTiltCommand::which
std::string const & which() const noexcept
Definition: command_repo.cc:258
jsonloader::UndockCommand
Definition: command_repo.h:73
jsonloader::kCmdStreamCamera
constexpr char kCmdStreamCamera[]
Definition: command_repo.h:50
jsonloader::CameraCommand::CameraCommand
CameraCommand(Json::Value const &obj)
Definition: command_repo.cc:373
jsonloader::InitializeBiasCommand
Definition: command_repo.h:227
jsonloader::StreamCameraCommand
Definition: command_repo.h:217
jsonloader::PerchCommand
Definition: command_repo.h:78
jsonloader::UnperchCommand::UnperchCommand
UnperchCommand(Json::Value const &obj)
Definition: command_repo.cc:226
jsonloader::kCmdPowerOn
constexpr char kCmdPowerOn[]
Definition: command_repo.h:39
jsonloader::StreamCameraCommand::StreamCameraCommand
StreamCameraCommand(Json::Value const &obj)
Definition: command_repo.cc:435
jsonloader::SetCheckZonesCommand::SetCheckZonesCommand
SetCheckZonesCommand(Json::Value const &obj)
Definition: command_repo.cc:472
jsonloader::kCmdEnableAstrobeeIntercomms
constexpr char kCmdEnableAstrobeeIntercomms[]
Definition: command_repo.h:61