Robot Documentations/Guides
Go to Target and Speak
This guide shows how to send the robot to a specific target and, once it arrives, make it say a short message. The example uses curl from a bash script.
Prerequisites:
- The robot API is reachable, e.g., http://192.168.1.100:5000
- curl and jq are installed on your machine
- A target already exists (replace the example UID as needed)
#!/usr/bin/env bash
set -euo pipefail
# Configuration
ROBOT_URL="${ROBOT_URL:-http://192.168.1.100:5000}"
TARGET_NAME=${TARGET_NAME:-target_01}
TARGET_UID=${TARGET_UID:-site_floor_${TARGET_NAME}}
command -v jq >/dev/null 2>&1 || { echo "jq is required (sudo apt install jq)"; exit 1; }
echo "=================================================="
echo "Robot goes to target and speaks"
echo "=================================================="
echo "[1/3] Sending task to go to target: ${TARGET_NAME} (${TARGET_UID})"
create_task_resp=$(curl -sS -X POST "${ROBOT_URL}/api/v1/tasks" \
-H 'Content-Type: application/json' \
-d "{\
\"type\": \"TABLE_SERVICE\",\
\"target_uid\": \"${TARGET_UID}\",\
\"activate\": true,\
\"payload\": [true, false, false, false]\
}")
success=$(echo "$create_task_resp" | jq -r '.success // empty')
message=$(echo "$create_task_resp" | jq -r '.message // empty')
if [ "$success" != "true" ]; then
echo "✗ Failed to create task: ${message}"
exit 1
fi
echo "✓ ${message}"
echo
echo "[2/3] Waiting until the robot reaches the target (state: AtTheService)"
echo "(Press Ctrl+C to abort)"
while :; do
status_resp=$(curl -sS "${ROBOT_URL}/api/v1/status")
current_state=$(echo "$status_resp" | jq -r '.current_state // empty')
echo " - current_state: ${current_state}"
if [ "$current_state" = "AtTheService" ]; then
break
fi
sleep 2
done
echo
echo "[3/3] Speaking via UI API"
speech_resp=$(curl -sS -X POST "${ROBOT_URL}/api/v1/ui/speech" \
-H 'Content-Type: application/json' \
-d '{
"lang": "en",
"text": "Hello world! I have reached the target."
}')
speech_ok=$(echo "$speech_resp" | jq -r '.success // empty')
if [ "$speech_ok" = "true" ]; then
echo "✓ Speech sent successfully"
else
echo "✗ Speech failed: $(echo "$speech_resp" | jq -r '.message // .')"
fi
echo
echo "=================================================="
echo "All done!"
echo "=================================================="Notes:
- You can override ROBOT_URL, TARGET_NAME, and TARGET_UID via environment variables.
- The script waits until current_state equals AtTheService before sending the speech command.