[Unit]
Description=SaltyBot Here4 GPS DroneCAN Bridge (bd-p47c)
Documentation=https://gitea.vayrette.com/seb/saltylab-firmware/issues/bd-p47c
# Requires package: saltybot_dronecan_gps (merged in bd-p47c → PR #728)
# Requires: can0 at 1 Mbps (set by can-bringup.service)
#
# Publishes:
#   /gps/fix           NavSatFix               5 Hz   → navsat_transform EKF
#   /gps/velocity      TwistWithCovarianceStamped 5 Hz
#   /here4/fix         NavSatFix               5 Hz   (alias)
#   /here4/imu         Imu                    50 Hz
#   /here4/mag         MagneticField          10 Hz
#   /here4/baro        FluidPressure          10 Hz
#   /here4/status      String JSON             1 Hz   (node health, fix quality)
#   /here4/node_id     Int32                  once   (auto-discovered DroneCAN ID)
#
# Subscribes:
#   /rtcm              ByteMultiArray          on demand  (RTCM corrections)
#   /rtcm_hex          String                  on demand  (hex fallback)
After=network-online.target can-bringup.service
Requires=can-bringup.service
# If can-bringup stops (CANable2 unplugged), stop this service too
BindsTo=can-bringup.service

[Service]
Type=simple
User=orin
Group=dialout

Environment="ROS_DOMAIN_ID=42"
Environment="ROS_DISTRO=humble"
Environment="SALTYBOT_WS=/opt/saltybot/jetson/ros2_ws/install"

ExecStart=/opt/saltybot/scripts/ros2-launch.sh \
    saltybot_dronecan_gps here4.launch.py

Restart=on-failure
RestartSec=5s
StartLimitInterval=60s
StartLimitBurst=5

TimeoutStartSec=30s
TimeoutStopSec=10s

StandardOutput=journal
StandardError=journal
SyslogIdentifier=saltybot-here4

[Install]
WantedBy=saltybot.target
