agenticros 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,13 +3,19 @@
3
3
  #
4
4
  # What this does:
5
5
  # 1. Sources ROS2 + the agenticros workspace
6
- # 2. Launches the RealSense camera in the background (logs to /tmp)
6
+ # 2. Launches the RealSense camera in the background (logs to /tmp) unless skipped
7
7
  # 3. Builds the @agenticros/claude-code MCP server
8
- # 4. Starts the robot's motor controller via `robotics start motors`
8
+ # 4. Optionally starts the robot's motor controller via `robotics start motors`
9
+ # when the robotics CLI is installed (skipped quietly otherwise — many users
10
+ # run their own ROS motor controller)
9
11
  #
10
12
  # After this finishes, launch Claude Code from the repo root. The MCP server
11
13
  # is auto-started by .mcp.json over stdio — nothing else to run on this host.
12
14
  #
15
+ # Environment (set by `agenticros up real`):
16
+ # AGENTICROS_NO_CAMERA=1 skip RealSense launch
17
+ # AGENTICROS_NO_MOTORS=1 skip robotics motor controller
18
+ #
13
19
  # Usage: ./scripts/start_demo.sh [jazzy|humble]
14
20
 
15
21
  set -e
@@ -20,36 +26,37 @@ CAMERA_LOG=/tmp/agenticros-camera.log
20
26
  CAMERA_PID_FILE=/tmp/agenticros-camera.pid
21
27
  source "$REPO_ROOT/scripts/lib/agenticros-banner.sh"
22
28
 
23
- agenticros_banner
24
- echo "Starting AgenticROS Claude Code demo"
25
- echo ""
29
+ start_realsense_camera() {
30
+ echo "==> Starting RealSense camera (logs: $CAMERA_LOG)"
31
+ if [[ -f "$CAMERA_PID_FILE" ]] && kill -0 "$(cat "$CAMERA_PID_FILE")" 2>/dev/null; then
32
+ echo " Already running (pid $(cat "$CAMERA_PID_FILE")) — skipping"
33
+ return 0
34
+ fi
35
+ if pgrep -f "realsense2_camera_node" >/dev/null; then
36
+ # Camera node from a prior session is still running but our pidfile is gone.
37
+ # Re-adopt it so `agenticros down` can find and stop it (turning off the IR
38
+ # projector). We point the pidfile at the actual node, not a launch parent,
39
+ # because that's what's holding the USB device.
40
+ local existing_pid
41
+ existing_pid=$(pgrep -f "realsense2_camera_node" | head -n 1)
42
+ echo "$existing_pid" >"$CAMERA_PID_FILE"
43
+ echo " Detected an existing realsense2_camera_node (pid $existing_pid) — adopted into $CAMERA_PID_FILE"
44
+ return 0
45
+ fi
26
46
 
27
- echo "==> Sourcing ROS2 ($ROS_DISTRO) and agenticros workspace"
28
- source "/opt/ros/$ROS_DISTRO/setup.bash"
29
- if [[ -f "$REPO_ROOT/ros2_ws/install/setup.bash" ]]; then
30
- source "$REPO_ROOT/ros2_ws/install/setup.bash"
31
- else
32
- echo " (ros2_ws is not built — run: cd ros2_ws && colcon build --symlink-install)"
33
- fi
47
+ if ! ros2 pkg prefix realsense2_camera &>/dev/null; then
48
+ echo " WARN: ros-${ROS_DISTRO}-realsense2-camera is not installed." >&2
49
+ echo " Install with: sudo apt-get install -y ros-${ROS_DISTRO}-realsense2-camera" >&2
50
+ echo " Continuing without camera — start your own camera node or re-run after installing the package."
51
+ return 0
52
+ fi
34
53
 
35
- echo "==> Starting RealSense camera (logs: $CAMERA_LOG)"
36
- if [[ -f "$CAMERA_PID_FILE" ]] && kill -0 "$(cat "$CAMERA_PID_FILE")" 2>/dev/null; then
37
- echo " Already running (pid $(cat "$CAMERA_PID_FILE")) — skipping"
38
- elif pgrep -f "realsense2_camera_node" >/dev/null; then
39
- # Camera node from a prior session is still running but our pidfile is gone.
40
- # Re-adopt it so `agenticros down` can find and stop it (turning off the IR
41
- # projector). We point the pidfile at the actual node, not a launch parent,
42
- # because that's what's holding the USB device.
43
- existing_pid=$(pgrep -f "realsense2_camera_node" | head -n 1)
44
- echo "$existing_pid" >"$CAMERA_PID_FILE"
45
- echo " Detected an existing realsense2_camera_node (pid $existing_pid) — adopted into $CAMERA_PID_FILE"
46
- else
47
54
  nohup ros2 launch realsense2_camera rs_launch.py >"$CAMERA_LOG" 2>&1 &
48
55
  # $! is the `ros2 launch` parent; the actual camera node is a child that
49
56
  # comes up a moment later. Wait briefly so we can record the node's PID
50
57
  # (what holds the USB / projector) instead of the parent's.
51
- launch_pid=$!
52
- node_pid=""
58
+ local launch_pid=$!
59
+ local node_pid=""
53
60
  for _ in 1 2 3 4 5 6 7 8 9 10; do
54
61
  node_pid=$(pgrep -f "realsense2_camera_node" | head -n 1 || true)
55
62
  [[ -n "$node_pid" ]] && break
@@ -62,8 +69,50 @@ else
62
69
  # Fallback: launch parent. `agenticros down` also pkills by name, so
63
70
  # this still gets cleaned up even if we miss the node PID.
64
71
  echo "$launch_pid" >"$CAMERA_PID_FILE"
65
- echo " Started (launch pid $launch_pid — node not yet visible; pkill fallback will clean up)"
72
+ echo " Started (launch pid $launch_pid — node not yet visible; check $CAMERA_LOG if tools see no image)"
73
+ fi
74
+ }
75
+
76
+ start_motor_controller() {
77
+ if [[ "${AGENTICROS_NO_MOTORS:-}" == "1" ]]; then
78
+ echo "==> Skipping motor controller (AGENTICROS_NO_MOTORS=1)"
79
+ return 0
80
+ fi
81
+
82
+ echo "==> Motor controller"
83
+ if ! command -v robotics >/dev/null 2>&1; then
84
+ echo " Skipping: 'robotics' CLI not installed."
85
+ echo " Using your own ROS motor controller is fine — AgenticROS publishes to /<namespace>/cmd_vel."
86
+ return 0
87
+ fi
88
+
89
+ echo " Running: robotics start motors"
90
+ set +e
91
+ robotics start motors
92
+ local rc=$?
93
+ set -e
94
+ if [[ $rc -ne 0 ]]; then
95
+ echo " WARN: robotics start motors exited $rc — continuing." >&2
96
+ echo " You may already have your own ROS motor controller running." >&2
66
97
  fi
98
+ }
99
+
100
+ agenticros_banner
101
+ echo "Starting AgenticROS Claude Code demo"
102
+ echo ""
103
+
104
+ echo "==> Sourcing ROS2 ($ROS_DISTRO) and agenticros workspace"
105
+ source "/opt/ros/$ROS_DISTRO/setup.bash"
106
+ if [[ -f "$REPO_ROOT/ros2_ws/install/setup.bash" ]]; then
107
+ source "$REPO_ROOT/ros2_ws/install/setup.bash"
108
+ else
109
+ echo " (ros2_ws is not built — run: cd ros2_ws && colcon build --symlink-install)"
110
+ fi
111
+
112
+ if [[ "${AGENTICROS_NO_CAMERA:-}" == "1" ]]; then
113
+ echo "==> Skipping RealSense camera (AGENTICROS_NO_CAMERA=1)"
114
+ else
115
+ start_realsense_camera
67
116
  fi
68
117
 
69
118
  echo "==> Building TypeScript workspace (@agenticros/core, ros-camera, claude-code, ...)"
@@ -81,9 +130,10 @@ if ! pnpm --filter '...@agenticros/claude-code' --workspace-concurrency=1 build;
81
130
  exit 2
82
131
  fi
83
132
 
84
- echo "==> Starting motor controller (robotics start motors)"
85
- robotics start motors
133
+ start_motor_controller
86
134
 
87
135
  echo ""
88
136
  echo "Demo ready. Launch Claude Code from $REPO_ROOT — .mcp.json starts the MCP server."
89
- echo "Stop the camera with: kill \$(cat $CAMERA_PID_FILE)"
137
+ if [[ -f "$CAMERA_PID_FILE" ]]; then
138
+ echo "Stop the camera with: kill \$(cat $CAMERA_PID_FILE) (or: agenticros down)"
139
+ fi