修复了rosbag录制服务崩溃的bug

This commit is contained in:
2026-09-17 16:34:27 +08:00
parent c3613d9e41
commit 9b2279f2d2
2 changed files with 18 additions and 14 deletions
+10 -10
View File
@@ -66,19 +66,19 @@ start_bag_recorder() {
echo "Rosbag log: ${BAG_LOG_FILE}"
: > "${BAG_LOG_FILE}"
setsid bash -lc "
setsid env WS_DIR="${WS_DIR}" bash -lc '
set -euo pipefail
set +u
source '${WS_DIR}/install/setup.bash'
source "${WS_DIR}/install/setup.bash"
set -u
while true; do
start_time=\\\$(date +%Y%m%d_%H%M%S)
output=/tmp/lbot_arm_\\${start_time}.mcap
echo \"Starting rosbag: \\${output}\"
start_time=$(date +%Y%m%d_%H%M%S)
output=/tmp/lbot_arm_${start_time}.mcap
echo "Starting rosbag: ${output}"
set +e
timeout 3600 ros2 bag record \
--storage mcap \
--output \"\\${output}\" \
--output "${output}" \
--polling-interval 2 \
--include-unpublished-topics \
--disable-keyboard-controls \
@@ -92,13 +92,13 @@ start_bag_recorder() {
--services \
/robot1/left_arm/move_joint \
/robot1/right_arm/move_joint
rc=\\$?
rc=$?
set -e
if [[ \\${rc} -ne 124 ]]; then
exit \\${rc}
if [[ ${rc} -ne 124 ]]; then
exit ${rc}
fi
done
" >> "${BAG_LOG_FILE}" 2>&1 &
' >> "${BAG_LOG_FILE}" 2>&1 &
local pid=$!
local pgid