|
1 | 1 | #!/bin/bash |
2 | 2 | # Create fault-monitoring trigger for moveit pick-and-place demo |
3 | 3 | # Alerts on any fault change reported by the manipulation monitor |
4 | | -set -eu |
5 | | -SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" |
6 | | -# shellcheck disable=SC1091 |
7 | | -source "${SCRIPT_DIR}/../../lib/triggers-api.sh" |
8 | | - |
9 | | -ENTITY_TYPE="apps" |
| 4 | +export ENTITY_TYPE="apps" |
10 | 5 | # Uses ROS node name (underscore) - must match reporting_sources in FaultEvent |
11 | | -ENTITY_ID="manipulation_monitor" |
12 | | - |
13 | | -# Check for existing active trigger |
14 | | -existing=$(find_active_trigger "$ENTITY_TYPE" "$ENTITY_ID") |
15 | | -if [ -n "$existing" ]; then |
16 | | - echo "Active trigger already exists: ${existing}" |
17 | | - echo "Run ./watch-triggers.sh to connect, or delete it first:" |
18 | | - echo " curl -X DELETE ${GATEWAY_URL}/api/v1/${ENTITY_TYPE}/${ENTITY_ID}/triggers/${existing}" |
19 | | - exit 0 |
20 | | -fi |
21 | | - |
22 | | -echo "Setting up fault trigger for ${ENTITY_TYPE}/${ENTITY_ID}..." |
23 | | -echo "" |
24 | | - |
25 | | -result=$(create_fault_trigger "$ENTITY_TYPE" "$ENTITY_ID") |
26 | | -trigger_id=$(echo "$result" | jq -r '.id') |
27 | | - |
28 | | -if [ -z "$trigger_id" ] || [ "$trigger_id" = "null" ]; then |
29 | | - echo "Failed to parse trigger response." >&2 |
30 | | - echo "$result" >&2 |
31 | | - exit 1 |
32 | | -fi |
33 | | - |
34 | | -status=$(echo "$result" | jq -r '.status') |
35 | | -event_source=$(echo "$result" | jq -r '.event_source') |
36 | | - |
37 | | -echo "Trigger created successfully!" |
38 | | -echo " ID: ${trigger_id}" |
39 | | -echo " Status: ${status}" |
40 | | -echo " Events: ${GATEWAY_URL}${event_source}" |
41 | | -echo "" |
42 | | -echo "To watch for events:" |
43 | | -echo " ./watch-triggers.sh ${trigger_id}" |
44 | | -echo "" |
45 | | -echo "Then inject a fault in another terminal:" |
46 | | -echo " ./inject-planning-failure.sh" |
| 6 | +export ENTITY_ID="manipulation_monitor" |
| 7 | +export INJECT_HINT="./inject-planning-failure.sh" |
| 8 | +# shellcheck disable=SC1091 |
| 9 | +source "$(cd "$(dirname "$0")" && pwd)/../../lib/setup-trigger.sh" |
0 commit comments