Skip to content

Commit c1e042b

Browse files
authored
Merge pull request #145 from nasa/OCEANWATER-700_activate_comms_action
PLEXIL support for ActivateComms action
2 parents bed8b35 + 934cf03 commit c1e042b

13 files changed

+101
-55
lines changed

ow_plexil/src/plans/ActivateComms.plp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// The Notices and Disclaimers for Ocean Worlds Autonomy Testbed for Exploration
2+
// Research and Simulation can be found in README.md in the root directory of
3+
// this repository.
4+
5+
// Stubbed uplink or downlink that issues the given message an invoke
6+
// a dummy communications action, which only applies an additional
7+
// power draw for the given duration.
8+
9+
#include "ow-interface.h"
10+
11+
ActivateComms:
12+
{
13+
In String Message;
14+
// NOTE: "Duration" is a PLEXIL keyword and cannot be used here.
15+
In Real DurationSecs;
16+
17+
log_info (Message, "...");
18+
SynchronousCommand activate_comms (DurationSecs);
19+
log_info ("Uplink/Downlink complete.");
20+
}

ow_plexil/src/plans/CollectAndTransfer.plp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Real Lookup CollectAndTransferTimeout;
1111
LibraryAction ImageSampleSite();
1212
LibraryAction Stub(In String desc);
1313
LibraryAction Image(In String desc);
14-
LibraryAction Downlink();
1514
LibraryAction GetInfoIfCrash(In String CheckpointName,
1615
In Boolean IgnoreCrash,
1716
InOut Boolean Crashed,
@@ -100,7 +99,8 @@ CollectAndTransfer:
10099
DownlinkSampleImage:
101100
{
102101
SkipCondition LastComplete >= 4;
103-
LibraryCall Downlink();
102+
LibraryCall ActivateComms (Message = "Downlinking sample image",
103+
DurationSecs = 3);
104104
Wait 1;
105105
set_checkpoint(OurName,true,Lookup(ToString(4,"_",CollectMore)));
106106
SynchronousCommand flush_checkpoints();

ow_plexil/src/plans/Downlink.plp

Lines changed: 0 additions & 12 deletions
This file was deleted.

ow_plexil/src/plans/DownlinkImage.plp

Lines changed: 0 additions & 12 deletions
This file was deleted.

ow_plexil/src/plans/EuropaMission.plp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ LibraryAction ImageLandingSite(In String InstanceName,
2525
LibraryAction InterogateSurface;
2626
LibraryAction GetTrenchTarget;
2727
LibraryAction Excavation;
28-
LibraryAction Downlink;
2928
LibraryAction Image (In String desc);
3029
LibraryAction IdentifySampleTarget (InOut Real X,
3130
InOut Real Y,
@@ -212,7 +211,8 @@ EuropaMission: Concurrence
212211
GroundPos = ground_pos,
213212
Parallel = parallel);
214213
LibraryCall Image(desc="trench");
215-
LibraryCall Downlink;
214+
LibraryCall ActivateComms (Message = "Downlinking trench image",
215+
DurationSecs = 3);
216216

217217
LibraryCall CollectAndTransfer(IgnoreCrash = false,
218218
InstanceName="MissionSol1",

ow_plexil/src/plans/GetTrenchTarget.plp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,40 @@
77
// interpretation of the Europa Lander reference mission, and serves mainly as a
88
// PLEXIL example.
99

10-
Real Lookup time;
10+
#include "ow-interface.h"
11+
12+
//Real Lookup time;
1113
Real Lookup TrenchTargetTimeout;
1214
Boolean Lookup TrenchIdentified;
13-
LibraryAction DownlinkImage();
1415
LibraryAction Stub(In String desc);
15-
Command log_error (...);
1616

1717
GetTrenchTarget:
1818
{
19-
Real Time;
20-
Time = Lookup(time);
19+
// Real Time;
2120

22-
// TODO: invoke comms, reset on failure.
23-
LibraryCall DownlinkImage();
21+
LibraryCall ActivateComms (Message = "Downlinking workspace images",
22+
DurationSecs = 5);
2423

2524
Try {
2625
GetInfoFromGround:
2726
{
2827
Integer numAttempts = 0;
2928
RepeatCondition AttemptGround.outcome == FAILURE;
3029
InvariantCondition numAttempts <= 1;
31-
Time = Lookup(time);
30+
// Time = Lookup(time);
3231
AttemptGround:
3332
{
34-
InvariantCondition
35-
Time < (AttemptGround.EXECUTING.START +
36-
Lookup(TrenchTargetTimeout));
33+
InvariantCondition (Lookup(time) < (AttemptGround.EXECUTING.START +
34+
Lookup(TrenchTargetTimeout)));
3735
EndCondition Lookup(TrenchIdentified);
38-
LibraryCall Stub(desc="Getting trench target from ground");
36+
LibraryCall ActivateComms (Message = "Uplinking sample target location",
37+
DurationSecs = 2);
3938
numAttempts = numAttempts + 1;
4039
}
4140
}
4241
GetTrenchTargetOnboard:
4342
{
44-
LibraryCall Stub(desc="Getting trench target onboard");
43+
LibraryCall Stub(desc="Computing sample target location onboard");
4544
}
46-
log_error ("Failed to get trench target!");
4745
}
4846
}

ow_plexil/src/plans/SampleAnalysis.plp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66

77
#include "ow-interface.h"
88

9-
LibraryAction Downlink();
10-
119
SampleAnalysis:
1210
{
1311
In Integer inst_id;
1412

1513
log_info ("PLEXIL Stub: Analyzing sample using instrument ", inst_id, "...");
1614

17-
LibraryCall Downlink();
15+
LibraryCall ActivateComms (Message = "Downlinking sample analysis",
16+
DurationSecs = 2);
1817
}

ow_plexil/src/plans/TestActions.plp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ TestActions: UncheckedSequence
1313
Real GP = -0.155; // Ground position
1414
log_info ("Beginning action test...");
1515

16+
17+
LibraryCall ActivateComms (Message = "Testing ActivateComms",
18+
DurationSecs = 2);
19+
1620
LibraryCall ArmUnstow();
1721

1822
LibraryCall ArmMoveCartesian (Frame = BASE_FRAME,

ow_plexil/src/plans/ow-commands.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Command camera_set_exposure (Real seconds);
6262
Command dock_ingest_sample();
6363
Command light_set_intensity (String side, // "left" or "right"
6464
Real intensity); // 0.0 to 1.0. 0 is off.
65+
Command activate_comms(Real duration_secs);
6566

6667
// Simulate fault commands. See TestSimulatedFaults.plp for example
6768
// usage. The value of 'probability' must be in the range [0..1].

ow_plexil/src/plans/ow-interface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ LibraryAction CameraSetExposure (In Real Seconds);
3737

3838
LibraryAction DockIngestSample ();
3939

40+
LibraryAction ActivateComms (In String Message, In Real DurationSecs);
41+
4042
LibraryAction GuardedMove (In Real X,
4143
In Real Y,
4244
In Real Z,

ow_plexil/src/plexil-adapter/OwAdapter.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@ static void dock_ingest_sample (Command* cmd, AdapterExecInterface* intf)
241241
acknowledge_command_sent(*cr);
242242
}
243243

244+
static void activate_comms (Command* cmd, AdapterExecInterface* intf)
245+
{
246+
double duration;
247+
const vector<Value>& args = cmd->getArgValues();
248+
args[0].getValue (duration);
249+
unique_ptr<CommandRecord>& cr = new_command_record(cmd, intf);
250+
OwInterface::instance()->activateComms(duration, g_cmd_id);
251+
acknowledge_command_sent(*cr);
252+
}
253+
244254
static void light_set_intensity (Command* cmd, AdapterExecInterface* intf)
245255
{
246256
bool valid_args = true;
@@ -308,13 +318,16 @@ bool OwAdapter::initialize (AdapterConfiguration* config)
308318
LanderAdapter::s_interface = OwInterface::instance();
309319

310320
// Commands
311-
config->registerCommandHandlerFunction("grind", grind);
312-
config->registerCommandHandlerFunction("guarded_move", guarded_move);
321+
config->registerCommandHandlerFunction("activate_comms", activate_comms);
313322
config->registerCommandHandlerFunction("arm_move_joints", arm_move_joints);
314323
config->registerCommandHandlerFunction("arm_move_joints_guarded",
315-
arm_move_joints_guarded);
324+
arm_move_joints_guarded);
325+
config->registerCommandHandlerFunction("camera_set_exposure",
326+
camera_set_exposure);
316327
config->registerCommandHandlerFunction("dock_ingest_sample",
317328
dock_ingest_sample);
329+
config->registerCommandHandlerFunction("grind", grind);
330+
config->registerCommandHandlerFunction("guarded_move", guarded_move);
318331
config->registerCommandHandlerFunction("pan", pan);
319332
config->registerCommandHandlerFunction("tilt", tilt);
320333
config->registerCommandHandlerFunction("scoop_circular", scoop_circular);
@@ -323,8 +336,6 @@ bool OwAdapter::initialize (AdapterConfiguration* config)
323336
pan_tilt_cartesian);
324337
config->registerCommandHandlerFunction("identify_sample_location",
325338
identify_sample_location);
326-
config->registerCommandHandlerFunction("camera_set_exposure",
327-
camera_set_exposure);
328339
config->registerCommandHandlerFunction("light_set_intensity",
329340
light_set_intensity);
330341
// Note: the following two are simulation utilities and not valid

ow_plexil/src/plexil-adapter/OwInterface.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const string Name_ArmMoveJoints = "ArmMoveJoints";
4848
const string Name_ArmMoveJointsGuarded = "ArmMoveJointsGuarded";
4949
const string Name_CameraSetExposure = "CameraSetExposure";
5050
const string Name_Ingest = "DockIngestSample";
51+
const string Name_ActivateComms = "ActivateComms";
5152
const string Name_Grind = "TaskGrind";
5253
const string Name_GuardedMove = "GuardedMove";
5354
const string Name_IdentifySampleLocation = "IdentifySampleLocation";
@@ -60,6 +61,7 @@ const string Name_Tilt = "Tilt";
6061
const string Name_TaskDiscardSample = "TaskDiscardSample";
6162

6263
static vector<string> LanderOpNames = {
64+
Name_ActivateComms,
6365
Name_ArmFindSurface,
6466
Name_GuardedMove,
6567
Name_ArmMoveJoints,
@@ -278,16 +280,17 @@ void OwInterface::initialize()
278280

279281
// Initialize action clients
280282

283+
m_activateCommsClient =
284+
make_unique<ActivateCommsActionClient>(Name_ActivateComms, true);
281285
m_armFindSurfaceClient =
282286
make_unique<ArmFindSurfaceActionClient>(Name_ArmFindSurface, true);
283-
m_guardedMoveClient =
284-
make_unique<GuardedMoveActionClient>(Name_GuardedMove, true);
285287
m_armMoveJointsClient =
286288
make_unique<ArmMoveJointsActionClient>(Name_ArmMoveJoints, true);
287289
m_armMoveJointsGuardedClient =
288-
make_unique<ArmMoveJointsGuardedActionClient>(Name_ArmMoveJointsGuarded,
289-
true);
290+
make_unique<ArmMoveJointsGuardedActionClient>(Name_ArmMoveJointsGuarded, true);
290291
m_grindClient = make_unique<TaskGrindActionClient>(Name_Grind, true);
292+
m_guardedMoveClient =
293+
make_unique<GuardedMoveActionClient>(Name_GuardedMove, true);
291294
m_scoopCircularClient =
292295
make_unique<TaskScoopCircularActionClient>(Name_TaskScoopCircular, true);
293296
m_scoopLinearClient =
@@ -328,6 +331,7 @@ void OwInterface::initialize()
328331
subscribe("/joint_states", QueueSize,
329332
&OwInterface::jointStatesCallback, this)));
330333

334+
connectActionServer (m_activateCommsClient, Name_ActivateComms);
331335
connectActionServer (m_armFindSurfaceClient, Name_ArmFindSurface);
332336
connectActionServer (m_armMoveJointsClient, Name_ArmMoveJoints);
333337
connectActionServer (m_armMoveJointsGuardedClient, Name_ArmMoveJointsGuarded);
@@ -486,6 +490,32 @@ void OwInterface::dockIngestSampleAction (int id)
486490
default_action_done_cb<DockIngestSampleResultConstPtr> (Name_Ingest));
487491
}
488492

493+
void OwInterface::activateComms (double duration, int id)
494+
{
495+
if (! markOperationRunning (Name_ActivateComms, id)) return;
496+
thread action_thread (&OwInterface::activateCommsAction, this, duration, id);
497+
action_thread.detach();
498+
}
499+
500+
void OwInterface::activateCommsAction (double duration, int id)
501+
{
502+
ActivateCommsGoal goal;
503+
goal.duration = duration;
504+
505+
ROS_INFO ("Starting ActivateComms()");
506+
507+
runAction<actionlib::SimpleActionClient<ActivateCommsAction>,
508+
ActivateCommsGoal,
509+
ActivateCommsResultConstPtr,
510+
ActivateCommsFeedbackConstPtr>
511+
(Name_ActivateComms, m_activateCommsClient, goal, id,
512+
default_action_active_cb (Name_ActivateComms),
513+
default_action_feedback_cb<ActivateCommsFeedbackConstPtr> (
514+
Name_ActivateComms),
515+
default_action_done_cb<ActivateCommsResultConstPtr> (
516+
Name_ActivateComms));
517+
}
518+
489519
void OwInterface::scoopLinear (int frame, bool relative,
490520
double x, double y, double z,
491521
double depth, double length, int id)

ow_plexil/src/plexil-adapter/OwInterface.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ using TaskDiscardSampleActionClient =
5656

5757
#include <ow_lander/GuardedMoveAction.h>
5858
#include <ow_lander/DockIngestSampleAction.h>
59+
#include <ow_lander/ActivateCommsAction.h>
5960
#include <ow_lander/TiltAction.h>
6061
#include <ow_lander/PanAction.h>
6162

@@ -65,7 +66,8 @@ using PanActionClient = actionlib::SimpleActionClient<ow_lander::PanAction>;
6566
using TiltActionClient = actionlib::SimpleActionClient<ow_lander::TiltAction>;
6667
using DockIngestSampleActionClient =
6768
actionlib::SimpleActionClient<ow_lander::DockIngestSampleAction>;
68-
69+
using ActivateCommsActionClient =
70+
actionlib::SimpleActionClient<ow_lander::ActivateCommsAction>;
6971

7072
// Telemetry
7173
#include <owl_msgs/ArmEndEffectorForceTorque.h>
@@ -112,6 +114,7 @@ class OwInterface : public LanderInterface
112114
void panTiltCartesian (int frame, double x, double y, double z, int id);
113115
void cameraSetExposure (double exposure_secs, int id);
114116
void dockIngestSample (int id);
117+
void activateComms (double duration, int id);
115118
void scoopLinear (int frame, bool relative, double x, double y, double z,
116119
double depth, double length, int id);
117120
void scoopCircular (int frame, bool relative, double x, double y, double z,
@@ -182,6 +185,7 @@ class OwInterface : public LanderInterface
182185
double depth, bool parallel, int id);
183186
void cameraSetExposureAction (double exposure_secs, int id);
184187
void dockIngestSampleAction (int id);
188+
void activateCommsAction (double duration, int id);
185189
void lightSetIntensityAction (const std::string& side, double intensity, int id);
186190
void jointStatesCallback (const sensor_msgs::JointState::ConstPtr&);
187191
void antennaOp (const std::string& opname, double degrees,
@@ -230,6 +234,7 @@ class OwInterface : public LanderInterface
230234
std::unique_ptr<TaskScoopLinearActionClient> m_scoopLinearClient;
231235
std::unique_ptr<CameraSetExposureActionClient> m_cameraSetExposureClient;
232236
std::unique_ptr<DockIngestSampleActionClient> m_dockIngestSampleClient;
237+
std::unique_ptr<ActivateCommsActionClient> m_activateCommsClient;
233238
std::unique_ptr<LightSetIntensityActionClient> m_lightSetIntensityClient;
234239
std::unique_ptr<IdentifySampleLocationActionClient> m_identifySampleLocationClient;
235240
std::unique_ptr<TaskDiscardSampleActionClient> m_taskDiscardSampleClient;

0 commit comments

Comments
 (0)