38 lines
1.6 KiB
Bash
38 lines
1.6 KiB
Bash
#!/usr/bin/env bash
|
||
# 在已有 ROS master + MAVROS(已连飞控)的前提下启动 flight_intent 伴飞桥节点。
|
||
# 若希望一键连 MAVROS:用同目录 run_flight_bridge_with_mavros.sh
|
||
#
|
||
# 用法(在 voice_drone_assistant 根目录):
|
||
# bash scripts/run_flight_intent_bridge_ros1.sh
|
||
# bash scripts/run_flight_intent_bridge_ros1.sh my_bridge # 节点名前缀(anonymous 仍会加后缀)
|
||
#
|
||
# 另开终端发意图(示例降落,默认订阅全局 /input):
|
||
# rostopic pub -1 /input std_msgs/String \
|
||
# "{data: '{\"is_flight_intent\":true,\"version\":1,\"actions\":[{\"type\":\"land\",\"args\":{}}],\"summary\":\"降\"}'}"
|
||
#
|
||
# 若改了 ~input_topic:rosnode info <节点名> 查看订阅话题
|
||
#
|
||
# 环境变量(与 run_flight_bridge_with_mavros.sh 一致,未设置时给默认值):
|
||
# ROS_MASTER_URI 默认 http://127.0.0.1:11311
|
||
# ROS_HOSTNAME 默认 127.0.0.1
|
||
# 注意:这些只在「本脚本进程」里生效;另开终端调试 rostopic/rosservice 时须自行 source noetic 并 export 相同 URI,或与跑 roscore 的机器一致。
|
||
|
||
set -euo pipefail
|
||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||
cd "$ROOT"
|
||
|
||
if [[ ! -f /opt/ros/noetic/setup.bash ]]; then
|
||
echo "未找到 /opt/ros/noetic/setup.bash(当前桥仅支持 ROS1 Noetic)" >&2
|
||
exit 2
|
||
fi
|
||
|
||
# shellcheck source=/dev/null
|
||
source /opt/ros/noetic/setup.bash
|
||
|
||
export ROS_MASTER_URI="${ROS_MASTER_URI:-http://127.0.0.1:11311}"
|
||
export ROS_HOSTNAME="${ROS_HOSTNAME:-127.0.0.1}"
|
||
|
||
export PYTHONPATH="${PYTHONPATH}:${ROOT}"
|
||
|
||
exec python3 -m voice_drone.flight_bridge.ros1_node "$@"
|