mavlink / mavros

MAVLink to ROS gateway with proxy for Ground Control Station
Other
902 stars 993 forks source link

Topics can echo data with "ros2 topic echo" but not with "rclpy or rclcpp" #1601

Open hexray-newbee opened 3 years ago

hexray-newbee commented 3 years ago

Issue details

ros2 topic echo /mavros/mavros/raw/fix will echo NavSatFix. But, the following sample code cannot sub data.

# refer: https://docs.ros.org/en/foxy/Tutorials/Writing-A-Simple-Py-Publisher-And-Subscriber.html#write-the-subscriber-node
import rclpy
from rclpy.node import Node

from sensor_msgs.msg import NavSatFix

class MinimalSubscriber(Node):

    def __init__(self):
        super().__init__('minimal_subscriber')
        self.subscription = self.create_subscription(
            NavSatFix,
            '/mavros/mavros/raw/fix',
            self.listener_callback,
            10)
        self.subscription  # prevent unused variable warning

    def listener_callback(self, msg):
        self.get_logger().info('I heard: "%f"' % msg.altitude)

def main(args=None):
    rclpy.init(args=args)

    minimal_subscriber = MinimalSubscriber()

    rclpy.spin(minimal_subscriber)

    # Destroy the node explicitly
    # (optional - otherwise it will be done automatically
    # when the garbage collector destroys the node object)
    minimal_subscriber.destroy_node()
    rclpy.shutdown()

if __name__ == '__main__':
    main()

MAVROS version and platform

Mavros: 2.0.3 ROS: Foxy Ubuntu: 20.04.2 (docker pull ros:foxy)

Autopilot type and version

[x] ArduPilot [ ] PX4

Version: 4.1.0-beta3

Node logs

[INFO] [launch]: All log files can be found below /root/.ros/log/2021-08-04-07-35-09-268724-0ed951b0de46-19250
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [mavros_node-1]: process started with pid [19252]
[mavros_node-1] [INFO] [1628062509.325559163] [mavros]: Starting mavros_node container
[mavros_node-1] [INFO] [1628062509.325624314] [mavros]: FCU URL: udp://:12345@
[mavros_node-1] [INFO] [1628062509.325634029] [mavros]: GCS URL: 
[mavros_node-1] [INFO] [1628062509.325640487] [mavros]: UAS Prefix: /uas1
[mavros_node-1] [INFO] [1628062509.325646294] [mavros]: Starting mavros router node
[mavros_node-1] [WARN] [1628062509.325670581] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.328972878] [mavros]: Built-in SIMD instructions: SSE, SSE2
[mavros_node-1] [INFO] [1628062509.329007862] [mavros]: Built-in MAVLink package version: 2021.6.6
[mavros_node-1] [INFO] [1628062509.329016146] [mavros]: Known MAVLink dialects: common ardupilotmega ASLUAV all development icarous matrixpilot paparazzi standard uAvionix ualberta
[mavros_node-1] [INFO] [1628062509.329023377] [mavros]: MAVROS Router started
[mavros_node-1] [INFO] [1628062509.329105785] [mavros]: Requested to add endpoint: type: 0, url: udp://:12345@
[mavros_node-1] [INFO] [1628062509.329323999] [mavros]: Endpoint link[1000] created
[mavros_node-1] [INFO] [1628062509.330503342] [mavros]: link[1000] opened successfully
[mavros_node-1] [INFO] [1628062509.330593319] [mavros]: Requested to add endpoint: type: 2, url: /uas1
[mavros_node-1] [INFO] [1628062509.330692360] [mavros]: Endpoint link[1001] created
[mavros_node-1] [INFO] [1628062509.331962747] [mavros]: link[1001] opened successfully
[mavros_node-1] [INFO] [1628062509.332013548] [mavros]: Starting mavros uas node
[mavros_node-1] [WARN] [1628062509.332042017] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.392989091] [mavros]: link[1000] detected remote address 1.1
[mavros_node-1] [INFO] [1628062509.454643991] [mavros]: UAS Executor started
[mavros_node-1] [INFO] [1628062509.487585575] [mavros]: Plugin actuator_control created
[mavros_node-1] [INFO] [1628062509.488069457] [mavros]: Plugin actuator_control added to executor
[mavros_node-1] [INFO] [1628062509.488120097] [mavros]: Plugin actuator_control initialized
[mavros_node-1] [WARN] [1628062509.488422668] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.494921970] [mavros]: Plugin altitude created
[mavros_node-1] [INFO] [1628062509.495208067] [mavros]: Plugin altitude added to executor
[mavros_node-1] [INFO] [1628062509.495261169] [mavros]: Plugin altitude initialized
[mavros_node-1] [WARN] [1628062509.495618591] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.506636280] [mavros]: Plugin command created
[mavros_node-1] [INFO] [1628062509.506884107] [mavros]: Plugin command added to executor
[mavros_node-1] [INFO] [1628062509.506935196] [mavros]: Plugin command initialized
[mavros_node-1] [WARN] [1628062509.507264497] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.521070877] [mavros]: Plugin ftp created
[mavros_node-1] [INFO] [1628062509.521278943] [mavros]: Plugin ftp added to executor
[mavros_node-1] [INFO] [1628062509.521351852] [mavros]: Plugin ftp initialized
[mavros_node-1] [WARN] [1628062509.521633012] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.530190605] [mavros]: Plugin geofence created
[mavros_node-1] [INFO] [1628062509.530661025] [mavros]: Plugin geofence added to executor
[mavros_node-1] [INFO] [1628062509.530701961] [mavros]: Plugin geofence initialized
[mavros_node-1] [WARN] [1628062509.530972646] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.541573072] [mavros]: Plugin global_position created
[mavros_node-1] [INFO] [1628062509.541857107] [mavros]: Plugin global_position added to executor
[mavros_node-1] [INFO] [1628062509.541889729] [mavros]: Plugin global_position initialized
[mavros_node-1] [WARN] [1628062509.542072582] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.546995393] [mavros]: Plugin home_position created
[mavros_node-1] [INFO] [1628062509.547158724] [mavros]: Plugin home_position added to executor
[mavros_node-1] [INFO] [1628062509.547182078] [mavros]: Plugin home_position initialized
[mavros_node-1] [WARN] [1628062509.547342538] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.554162506] [mavros]: Plugin imu created
[mavros_node-1] [INFO] [1628062509.554527781] [mavros]: Plugin imu added to executor
[mavros_node-1] [INFO] [1628062509.554559912] [mavros]: Plugin imu initialized
[mavros_node-1] [WARN] [1628062509.554754424] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.561485277] [mavros]: Plugin local_position created
[mavros_node-1] [INFO] [1628062509.561686460] [mavros]: Plugin local_position added to executor
[mavros_node-1] [INFO] [1628062509.561709883] [mavros]: Plugin local_position initialized
[mavros_node-1] [WARN] [1628062509.561891258] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.567187282] [mavros]: Plugin manual_control created
[mavros_node-1] [INFO] [1628062509.567348263] [mavros]: Plugin manual_control added to executor
[mavros_node-1] [INFO] [1628062509.567374962] [mavros]: Plugin manual_control initialized
[mavros_node-1] [WARN] [1628062509.567619652] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.574476417] [mavros]: Plugin param created
[mavros_node-1] [INFO] [1628062509.574667716] [mavros]: Plugin param added to executor
[mavros_node-1] [INFO] [1628062509.574697677] [mavros]: Plugin param initialized
[mavros_node-1] [WARN] [1628062509.574897943] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.580764296] [mavros]: Plugin rallypoint created
[mavros_node-1] [INFO] [1628062509.580934848] [mavros]: Plugin rallypoint added to executor
[mavros_node-1] [INFO] [1628062509.580955515] [mavros]: Plugin rallypoint initialized
[mavros_node-1] [WARN] [1628062509.581146642] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.587392245] [mavros]: Plugin rc_io created
[mavros_node-1] [INFO] [1628062509.587619866] [mavros]: Plugin rc_io added to executor
[mavros_node-1] [INFO] [1628062509.587644787] [mavros]: Plugin rc_io initialized
[mavros_node-1] [WARN] [1628062509.587849083] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.593373770] [mavros]: Plugin setpoint_accel created
[mavros_node-1] [INFO] [1628062509.593412788] [mavros]: Plugin setpoint_accel added to executor
[mavros_node-1] [INFO] [1628062509.593427957] [mavros]: Plugin setpoint_accel initialized
[mavros_node-1] [WARN] [1628062509.593618346] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.601204437] [mavros]: Plugin setpoint_attitude created
[mavros_node-1] [INFO] [1628062509.601242226] [mavros]: Plugin setpoint_attitude added to executor
[mavros_node-1] [INFO] [1628062509.601256558] [mavros]: Plugin setpoint_attitude initialized
[mavros_node-1] [WARN] [1628062509.601426579] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.609007985] [mavros]: Plugin setpoint_position created
[mavros_node-1] [INFO] [1628062509.609055307] [mavros]: Plugin setpoint_position added to executor
[mavros_node-1] [INFO] [1628062509.609078166] [mavros]: Plugin setpoint_position initialized
[mavros_node-1] [WARN] [1628062509.609278980] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.618389253] [mavros]: Plugin setpoint_raw created
[mavros_node-1] [INFO] [1628062509.618656903] [mavros]: Plugin setpoint_raw added to executor
[mavros_node-1] [INFO] [1628062509.618681331] [mavros]: Plugin setpoint_raw initialized
[mavros_node-1] [WARN] [1628062509.618904348] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.626172005] [mavros]: Plugin setpoint_trajectory created
[mavros_node-1] [INFO] [1628062509.626218918] [mavros]: Plugin setpoint_trajectory added to executor
[mavros_node-1] [INFO] [1628062509.626242236] [mavros]: Plugin setpoint_trajectory initialized
[mavros_node-1] [WARN] [1628062509.626468496] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.633120776] [mavros]: Plugin setpoint_velocity created
[mavros_node-1] [INFO] [1628062509.633176534] [mavros]: Plugin setpoint_velocity added to executor
[mavros_node-1] [INFO] [1628062509.633200854] [mavros]: Plugin setpoint_velocity initialized
[mavros_node-1] [WARN] [1628062509.633412641] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.646950940] [mavros]: Plugin sys_status created
[mavros_node-1] [INFO] [1628062509.647477052] [mavros]: Plugin sys_status added to executor
[mavros_node-1] [INFO] [1628062509.647506561] [mavros]: Plugin sys_status initialized
[mavros_node-1] [WARN] [1628062509.647704978] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.653751671] [mavros.mavros]: TM: Timesync mode: MAVLINK
[mavros_node-1] [INFO] [1628062509.656608403] [mavros]: Plugin sys_time created
[mavros_node-1] [INFO] [1628062509.656792471] [mavros]: Plugin sys_time added to executor
[mavros_node-1] [INFO] [1628062509.656812466] [mavros]: Plugin sys_time initialized
[mavros_node-1] [WARN] [1628062509.657020454] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.667277627] [mavros]: Plugin waypoint created
[mavros_node-1] [INFO] [1628062509.667536859] [mavros]: Plugin waypoint added to executor
[mavros_node-1] [INFO] [1628062509.667560561] [mavros]: Plugin waypoint initialized
[mavros_node-1] [WARN] [1628062509.667746109] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[mavros_node-1] [INFO] [1628062509.674097535] [mavros]: Plugin wind_estimation created
[mavros_node-1] [INFO] [1628062509.674306276] [mavros]: Plugin wind_estimation added to executor
[mavros_node-1] [INFO] [1628062509.674332137] [mavros]: Plugin wind_estimation initialized
[mavros_node-1] [INFO] [1628062509.675956853] [mavros]: Built-in SIMD instructions: SSE, SSE2
[mavros_node-1] [INFO] [1628062509.675984431] [mavros]: Built-in MAVLink package version: 2021.6.6
[mavros_node-1] [INFO] [1628062509.675992785] [mavros]: Known MAVLink dialects: common ardupilotmega ASLUAV all development icarous matrixpilot paparazzi standard uAvionix ualberta
[mavros_node-1] [INFO] [1628062509.676000161] [mavros]: MAVROS UAS via /uas1 started. MY ID 1.191, TARGET ID 1.1
[mavros_node-1] [INFO] [1628062509.784333137] [mavros]: CON: Got HEARTBEAT, connected. FCU: ArduPilot
[mavros_node-1] [INFO] [1628062509.784516373] [mavros.mavros]: WP: detected enable_partial_push: 1
[mavros_node-1] [INFO] [1628062509.896965538] [mavros.mavros]: RC_CHANNELS message detected!
[mavros_node-1] [INFO] [1628062509.897126505] [mavros.mavros]: IMU: Raw IMU message used.
[mavros_node-1] [INFO] [1628062510.639796583] [mavros]: link[1001] detected remote address 1.191
[mavros_node-1] [INFO] [1628062519.784550914] [mavros.mavros]: HP: requesting home position
[mavros_node-1] [INFO] [1628062519.789758634] [mavros.mavros]: FCU: ArduCopter V4.1.0-beta3 (609a65e4)
[mavros_node-1] [INFO] [1628062519.791842188] [mavros.mavros]: FCU: bf8638f586374072a0d0ca21f7d3b018
[mavros_node-1] [INFO] [1628062519.792427159] [mavros.mavros]: FCU: Frame: QUAD/PLUS
[mavros_node-1] [INFO] [1628062520.346491365] [mavros.mavros]: PR: parameters list received
[mavros_node-1] [INFO] [1628062524.786288082] [mavros.mavros]: WP: mission received
[mavros_node-1] [INFO] [1628062529.788571573] [mavros.mavros]: RP: mission received
[mavros_node-1] [INFO] [1628062534.790093972] [mavros.mavros]: GF: mission received

Diagnostics

header:
  stamp:
    sec: 1628064241
    nanosec: 328174672
  frame_id: ''
status:
- level: "\0"
  name: 'mavros: MAVROS Router'
  message: ok
  hardware_id: none
  values:
  - key: Endpoints
    value: '2'
  - key: Messages routed
    value: '191083'
  - key: Messages sent
    value: '191083'
  - key: Messages dropped
    value: '0'
- level: "\0"
  name: 'mavros: endpoint 1000: udp://:12345@'
  message: ok
  hardware_id: none
  values:
  - key: Received packets
    value: '59830'
  - key: Dropped packets
    value: '0'
  - key: Buffer overruns
    value: '0'
  - key: Parse errors
    value: '0'
  - key: Rx sequence number
    value: '121'
  - key: Tx sequence number
    value: '0'
  - key: Rx total bytes
    value: '6544074'
  - key: Tx total bytes
    value: '4623'
  - key: Rx speed
    value: inf
  - key: Tx speed
    value: -nan
  - key: Remotes count
    value: '3'
  - key: Remote [0]
    value: '0.0'
  - key: Remote [1]
    value: '1.0'
  - key: Remote [2]
    value: '1.1'
- level: "\0"
  name: 'mavros: endpoint 1001: /uas1'
  message: ok
  hardware_id: none
  values:
  - key: Remotes count
    value: '3'
  - key: Remote [0]
    value: '0.0'
  - key: Remote [1]
    value: '1.0'
  - key: Remote [2]
    value: '1.191'
---
header:
  stamp:
    sec: 1628064241
    nanosec: 334260431
  frame_id: ''
status:
- level: "\0"
  name: 'mavros: MAVROS UAS'
  message: connected
  hardware_id: uas:///uas1
  values: []
- level: "\0"
  name: 'mavros: GPS'
  message: 3D fix
  hardware_id: uas:///uas1
  values:
  - key: Satellites visible
    value: '10'
  - key: Fix type
    value: '6'
  - key: EPH (m)
    value: '1.21'
  - key: EPV (m)
    value: '2.00'
- level: "\0"
  name: 'mavros: System'
  message: Normal
  hardware_id: uas:///uas1
  values:
  - key: Sensor present
    value: '0x5371FC2F'
  - key: Sensor enabled
    value: '0x5261FC2F'
  - key: Sensor health
    value: '0x5371FC2F'
  - key: 3D gyro
    value: Ok
  - key: 3D accelerometer
    value: Ok
  - key: 3D magnetometer
    value: Ok
  - key: absolute pressure
    value: Ok
  - key: GPS
    value: Ok
  - key: 3D angular rate control
    value: Ok
  - key: attitude stabilization
    value: Ok
  - key: yaw position
    value: Ok
  - key: z/altitude control
    value: Ok
  - key: x/y position control
    value: Ok
  - key: motor outputs / control
    value: Ok
  - key: rc receiver
    value: Ok
  - key: AHRS subsystem health
    value: Ok
  - key: Terrain subsystem health
    value: Ok
  - key: Battery
    value: Ok
  - key: pre-arm check status. Always healthy when armed
    value: Ok
  - key: propulsion (actuator, esc, motor or propellor)
    value: Ok
  - key: CPU Load (%)
    value: '0.0'
  - key: Drop rate (%)
    value: '0.0'
  - key: Errors comm
    value: '0'
  - key: 'Errors count #1'
    value: '0'
  - key: 'Errors count #2'
    value: '0'
  - key: 'Errors count #3'
    value: '0'
  - key: 'Errors count #4'
    value: '0'
- level: "\0"
  name: 'mavros: Battery'
  message: Normal
  hardware_id: uas:///uas1
  values:
  - key: Voltage
    value: '12.59'
  - key: Current
    value: '0.0'
  - key: Remaining
    value: '0.0'
- level: "\0"
  name: 'mavros: Heartbeat'
  message: Normal
  hardware_id: uas:///uas1
  values:
  - key: Heartbeats since startup
    value: '1732'
  - key: Frequency (Hz)
    value: '0.999999'
  - key: Vehicle type
    value: Quadrotor
  - key: Autopilot type
    value: ArduPilot
  - key: Mode
    value: GUIDED
  - key: System status
    value: STANDBY
---

Check ID

No executable found
vooon commented 3 years ago

Do you sure of that double /mavros/mavros? Could you please list nodes? Btw sometimes i sees problems with topics/services, but don't know why they are happening. Maybe it's on DDS layer, maybe i done something wrong in C++ part.

dayjaby commented 3 years ago

I have also the problem of this /mavros/mavros topics being created:

mavros/actuator_control
/mavros/altitude
/mavros/battery
/mavros/estimator_status
/mavros/extended_state
/mavros/global_position/global
/mavros/home_position/home
/mavros/landing_target/raw
/mavros/local_position/pose
/mavros/mavros/accel
/mavros/mavros/attitude
/mavros/mavros/cmd_vel
/mavros/mavros/cmd_vel_unstamped
/mavros/mavros/compass_hdg
/mavros/mavros/control
/mavros/mavros/data
/mavros/mavros/data_raw
/mavros/mavros/desired
/mavros/mavros/diff_pressure
/mavros/mavros/event
/mavros/mavros/fences
/mavros/mavros/global
/mavros/mavros/global_to_local
...

ros2 echo works:

$ ros2 topic echo /mavros/state
header:
  stamp:
    sec: 1629378205
    nanosec: 686848266
  frame_id: ''
connected: true
armed: false
guided: true
manual_input: false
mode: AUTO.LOITER
system_status: 3
---

even for the /mavros/mavros topics:

ros2 topic echo /mavros/mavros/raw/fix
header:
  stamp:
    sec: 1629378235
    nanosec: 371334293
  frame_id: base_link
status:
  status: 0
  service: 1
latitude: 47.3977419
longitude: 8.545594
altitude: 535.0689155639569
position_covariance:
- 1.0
- 0.0
- 0.0
- 0.0
- 1.0
- 0.0
- 0.0
- 0.0
- 1.0
position_covariance_type: 2
---

Node list looks like

$ ros2 node list
WARNING: Be aware that are nodes in the graph that share an exact name, this can have unintended side effects.
/camera_plugin
/gazebo
/mavros
/mavros
/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
/mavros/mavros
vooon commented 3 years ago

@dayjaby that's looks like there some trouble with sub-nodes of plugins because usual path would look like /<uas-node-name>/<plugin-node-name>/<some-topic>, e.g. /mavros/global_position/global -> UAS's name is mavros, Plugin name is global_position, and published topic is global.

vooon commented 3 years ago

@dayjaby here is example from by build:

root@c169f39972ff:/# ros2 node list
/mavros
/mavros/actuator_control
/mavros/adsb
/mavros/altitude
/mavros/cmd
/mavros/ftp
/mavros/geofence
/mavros/global_position
/mavros/home_position
/mavros/imu
/mavros/landing_target
/mavros/local_position
/mavros/manual_control
/mavros/mission
/mavros/param
/mavros/rallypoint
/mavros/rc
/mavros/setpoint_accel
/mavros/setpoint_attitude
/mavros/setpoint_position
/mavros/setpoint_raw
/mavros/setpoint_trajectory
/mavros/setpoint_velocity
/mavros/sys
/mavros/tdr_radio
/mavros/time
/mavros/wind
/mavros_node
/mavros_router
/transform_listener_impl_55cee143bf80
root@c169f39972ff:/# ros2 topic list -v
Published topics:
 * /diagnostics [diagnostic_msgs/msg/DiagnosticArray] 2 publishers
 * /mavros/adsb/vehicle [mavros_msgs/msg/ADSBVehicle] 1 publisher
 * /mavros/altitude [mavros_msgs/msg/Altitude] 1 publisher
 * /mavros/battery [sensor_msgs/msg/BatteryState] 1 publisher
 * /mavros/estimator_status [mavros_msgs/msg/EstimatorStatus] 1 publisher
 * /mavros/extended_state [mavros_msgs/msg/ExtendedState] 1 publisher
 * /mavros/geofence/fences [mavros_msgs/msg/WaypointList] 1 publisher
 * /mavros/global_position/compass_hdg [std_msgs/msg/Float64] 1 publisher
 * /mavros/global_position/global [sensor_msgs/msg/NavSatFix] 1 publisher
 * /mavros/global_position/gp_lp_offset [geometry_msgs/msg/PoseStamped] 1 publisher
 * /mavros/global_position/gp_origin [geographic_msgs/msg/GeoPointStamped] 1 publisher
 * /mavros/global_position/local [nav_msgs/msg/Odometry] 1 publisher
 * /mavros/global_position/raw/fix [sensor_msgs/msg/NavSatFix] 1 publisher
 * /mavros/global_position/raw/gps_vel [geometry_msgs/msg/TwistStamped] 1 publisher
 * /mavros/global_position/raw/satellites [std_msgs/msg/UInt32] 1 publisher
 * /mavros/global_position/rel_alt [std_msgs/msg/Float64] 1 publisher
 * /mavros/home_position/home [mavros_msgs/msg/HomePosition] 1 publisher
 * /mavros/imu/data [sensor_msgs/msg/Imu] 1 publisher
 * /mavros/imu/data_raw [sensor_msgs/msg/Imu] 1 publisher
 * /mavros/imu/diff_pressure [sensor_msgs/msg/FluidPressure] 1 publisher
 * /mavros/imu/mag [sensor_msgs/msg/MagneticField] 1 publisher
 * /mavros/imu/static_pressure [sensor_msgs/msg/FluidPressure] 1 publisher
 * /mavros/imu/temperature_baro [sensor_msgs/msg/Temperature] 1 publisher
 * /mavros/imu/temperature_imu [sensor_msgs/msg/Temperature] 1 publisher
 * /mavros/local_position/accel [geometry_msgs/msg/AccelWithCovarianceStamped] 1 publisher
 * /mavros/local_position/odom [nav_msgs/msg/Odometry] 1 publisher
 * /mavros/local_position/pose [geometry_msgs/msg/PoseStamped] 1 publisher
 * /mavros/local_position/pose_cov [geometry_msgs/msg/PoseWithCovarianceStamped] 1 publisher
 * /mavros/local_position/velocity_body [geometry_msgs/msg/TwistStamped] 1 publisher
 * /mavros/local_position/velocity_body_cov [geometry_msgs/msg/TwistWithCovarianceStamped] 1 publisher
 * /mavros/local_position/velocity_local [geometry_msgs/msg/TwistStamped] 1 publisher
 * /mavros/lt_marker [geometry_msgs/msg/Vector3Stamped] 1 publisher
 * /mavros/manual_control/control [mavros_msgs/msg/ManualControl] 1 publisher
 * /mavros/mission/reached [mavros_msgs/msg/WaypointReached] 1 publisher
 * /mavros/mission/waypoints [mavros_msgs/msg/WaypointList] 1 publisher
 * /mavros/param/event [mavros_msgs/msg/ParamEvent] 1 publisher
 * /mavros/pose_in [geometry_msgs/msg/PoseStamped] 1 publisher
 * /mavros/radio_status [mavros_msgs/msg/RadioStatus] 1 publisher
 * /mavros/rallypoint/rallypoints [mavros_msgs/msg/WaypointList] 1 publisher
 * /mavros/rc/in [mavros_msgs/msg/RCIn] 1 publisher
 * /mavros/rc/out [mavros_msgs/msg/RCOut] 1 publisher
 * /mavros/setpoint_raw/target_attitude [mavros_msgs/msg/AttitudeTarget] 1 publisher
 * /mavros/setpoint_raw/target_global [mavros_msgs/msg/GlobalPositionTarget] 1 publisher
 * /mavros/setpoint_raw/target_local [mavros_msgs/msg/PositionTarget] 1 publisher
 * /mavros/setpoint_trajectory/desired [nav_msgs/msg/Path] 1 publisher
 * /mavros/state [mavros_msgs/msg/State] 1 publisher
 * /mavros/statustext/recv [mavros_msgs/msg/StatusText] 1 publisher
 * /mavros/target_actuator_control [mavros_msgs/msg/ActuatorControl] 1 publisher
 * /mavros/time_reference [sensor_msgs/msg/TimeReference] 1 publisher
 * /mavros/timesync_status [mavros_msgs/msg/TimesyncStatus] 1 publisher
 * /mavros/wind_estimation [geometry_msgs/msg/TwistWithCovarianceStamped] 1 publisher
 * /parameter_events [rcl_interfaces/msg/ParameterEvent] 30 publishers
 * /rosout [rcl_interfaces/msg/Log] 31 publishers
 * /tf [tf2_msgs/msg/TFMessage] 1 publisher
 * /tf_static [tf2_msgs/msg/TFMessage] 1 publisher
 * /uas1/mavlink_sink [mavros_msgs/msg/Mavlink] 1 publisher
 * /uas1/mavlink_source [mavros_msgs/msg/Mavlink] 1 publisher

Subscribed topics:
 * /mavros/actuator_control [mavros_msgs/msg/ActuatorControl] 1 subscriber
 * /mavros/adsb/send [mavros_msgs/msg/ADSBVehicle] 1 subscriber
 * /mavros/global_position/global [sensor_msgs/msg/NavSatFix] 1 subscriber
 * /mavros/global_position/set_gp_origin [geographic_msgs/msg/GeoPointStamped] 1 subscriber
 * /mavros/home_position/home [mavros_msgs/msg/HomePosition] 1 subscriber
 * /mavros/home_position/set [mavros_msgs/msg/HomePosition] 1 subscriber
 * /mavros/landing_target/pose [geometry_msgs/msg/PoseStamped] 1 subscriber
 * /mavros/local_position/pose [geometry_msgs/msg/PoseStamped] 1 subscriber
 * /mavros/manual_control/send [mavros_msgs/msg/ManualControl] 1 subscriber
 * /mavros/rc/override [mavros_msgs/msg/OverrideRCIn] 1 subscriber
 * /mavros/setpoint_accel/accel [geometry_msgs/msg/Vector3Stamped] 1 subscriber
 * /mavros/setpoint_attitude/cmd_vel [geometry_msgs/msg/TwistStamped] 1 subscriber
 * /mavros/setpoint_attitude/thrust [mavros_msgs/msg/Thrust] 1 subscriber
 * /mavros/setpoint_position/global [geographic_msgs/msg/GeoPoseStamped] 1 subscriber
 * /mavros/setpoint_position/global_to_local [geographic_msgs/msg/GeoPoseStamped] 1 subscriber
 * /mavros/setpoint_position/local [geometry_msgs/msg/PoseStamped] 1 subscriber
 * /mavros/setpoint_raw/attitude [mavros_msgs/msg/AttitudeTarget] 1 subscriber
 * /mavros/setpoint_raw/global [mavros_msgs/msg/GlobalPositionTarget] 1 subscriber
 * /mavros/setpoint_raw/local [mavros_msgs/msg/PositionTarget] 1 subscriber
 * /mavros/setpoint_trajectory/local [trajectory_msgs/msg/MultiDOFJointTrajectory] 1 subscriber
 * /mavros/setpoint_velocity/cmd_vel [geometry_msgs/msg/TwistStamped] 1 subscriber
 * /mavros/setpoint_velocity/cmd_vel_unstamped [geometry_msgs/msg/Twist] 1 subscriber
 * /mavros/statustext/send [mavros_msgs/msg/StatusText] 1 subscriber
 * /parameter_events [rcl_interfaces/msg/ParameterEvent] 30 subscribers
 * /tf [tf2_msgs/msg/TFMessage] 1 subscriber
 * /tf_static [tf2_msgs/msg/TFMessage] 1 subscriber
 * /uas1/mavlink_sink [mavros_msgs/msg/Mavlink] 1 subscriber
 * /uas1/mavlink_source [mavros_msgs/msg/Mavlink] 1 subscriber
dayjaby commented 3 years ago

Are you on ros2 galactic or foxy [[ I use foxy ]]

vooon commented 3 years ago

@dayjaby galactic, but foxy should be exactly same.

aa-calvo commented 3 years ago

I am running ROS2 in a Jetson Nano, connected to a Kakute F7 flight controller. I was able to start the mavros_node and echo the /mavros/state, but some of the topics are not publishing data. I currently need at least:

/mavros/global_position/rel_alt
/mavros/rc/in
/mavros/global_position/local

I also tried calling the set rate service, but I never get a response:

ros2 service call /mavros/set_stream_rate mavros_msgs/srv/StreamRate "{stream_id: 0, message_rate: 30, on_off: true}"

I am not sure if this is a problem with the node configuration, the actual nodes, or ROS2 in general. Any suggestions are welcomed and I am willing to give them a try, but for now I think I'll have to revert to ROS1.

This was my build process:

wstool init src
rosinstall_generator --rosdistro foxy mavlink | tee /tmp/mavros.rosinstall
rosinstall_generator --upstream mavros geographic_msgs eigen_stl_containers angles diagnostic_updater | tee -a /tmp/mavros.rosinstall
wstool merge -t src /tmp/mavros.rosinstall
wstool update -t src -j4
rosdep install --from-paths src --ignore-src -y
sudo ./src/mavros/mavros/scripts/install_geographiclib_datasets.sh
colcon build
esharet commented 3 years ago

Your subscriber should work with the same QoS as it's publisher. For example, if you are trying to subscribe to the topic /mavros/global_position/raw/fix:

from mavros.base import SENSOR_QOS

self.global_position_sub = self.create_subscription(mavros.global_position.NavSatFix, '/mavros/global_position/raw/fix', self.global_position_cb, qos_profile=SENSOR_QOS)

def global_position_cb(self, topic):
        # self.get_logger().info("x %f: y: %f, z: %f" % (topic.latitude, topic.longitude, topic.altitude))
        pass

It is working for me with ros2 foxy, ubuntu 20.04.

weicong96 commented 2 years ago

Hi can i check if there is an updated solution for setting set_stream_rate and having no response on MAVROS ros2 foxy? I am facing same issue as described in one of the replies above:

I am running ROS2 in a Jetson Nano, connected to a Kakute F7 flight controller. I was able to start the mavros_node and echo the /mavros/state, but some of the topics are not publishing data. I currently need at least:

/mavros/global_position/rel_alt
/mavros/rc/in
/mavros/global_position/local

I also tried calling the set rate service, but I never get a response:

ros2 service call /mavros/set_stream_rate mavros_msgs/srv/StreamRate "{stream_id: 0, message_rate: 30, on_off: true}"

Details: Operating System: Ubuntu 20.04 Package: ros-foxy-mavros 2.0.3 On top of that I'm also seeing "No satellites found" in my /diagnostics output.

I have the same QOS for the subscribers.

Added more details after some experiements: I am currently using ardupilot's SITL Tool to act as a simulated fcu. Results from trying to isolate the cause:

1st experiment: Run SITL process, then run mavros node to listen to it and dont receive get any data for /mavros/* topics except for /mavros/state, unable to connect via Mission Planner after terminating mavros node.

2nd experiment: Run SITL process, run Mission Planner to connect to it and i can get GPS Fix in the UI then disconnect from it. Run mavros again, able to recevie published topics, including /mavros/global_position/global. /diagnostics says "3D Fix" with 10 satellites visible.

Connection URLs: gcs_url: udp://@localhost (didnt try connecting to it) fcu_url: tcp://localhost:5760

I should also add that I am running with Docker images, with the subscriber for telemetry and mavros in different images. However, I am currently thinking that's not the issue as i am able to get topic subscription values when they are setup correct(as in 2nd experiment)

"set_stream_rate" call still hangs for me in the above 2 attempts. Is there something i can do to set the get messages started streaming?

vooon commented 2 years ago

Hi folks, @dayjaby , @weicong96 , @hexray-newbee , @aa-calvo Can you please try current ros2 master? I do not get silent messages anymore, but don't really know what is changed. If all ok, i'm going to release 2.1 as i don't really want to leave broken version in repos.

Rainerino commented 2 years ago

Hi folks, @dayjaby , @weicong96 , @hexray-newbee , @aa-calvo Can you please try current ros2 master? I do not get silent messages anymore, but don't really know what is changed. If all ok, i'm going to release 2.1 as i don't really want to leave broken version in repos.

I just test with the current mavros/ros2 branch, encountered the same problem. My node list look just like https://github.com/mavlink/mavros/issues/1601#issuecomment-901898300 (ocean of mavros/mavros), and I can't subscribe to any nodes but can echo them with roscli. (I think sometimes some of the nodes are missing for some reason). On my rqt_graph, most of the nodes are missing.

MAVROS version and platform Mavros: 2.1.0 ROS: Foxy focal OS: Pop-OS 20.04 5.15.15

Autopilot type and version [x] ArduPilot 4.1.2 [x] PX4 v1.12.3 (both on sitl)

mavros.launch.py


from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    return LaunchDescription([
       Node(
            package='mavros',
            executable='mavros_node',
            name='mavros',
            output='log',
            emulate_tty=True,
            # respawn=False,
            # respawn_delay=1,
            parameters=[
                {'fcu_url': 'udp://:14550@'}
            ]
        )
    ])

subscriber call:

     self.subscription = self.create_subscription(
            mavros.global_position.NavSatFix,
            '/mavros/global_position/raw/fix',
            self.listener_callback,
            qos_profile=SENSOR_QOS)
        self.subscription  # prevent unused variable warning

Any pointers would be greatly appreciated!

clydemcqueen commented 2 years ago

In your launch file, commend out the name='mavros' line.

This is used to override the node name, but the mavros_node executable actually launches many nodes, so all of them will end up with the same name.

Student865 commented 1 year ago

Hello, have you sovled the problem? I'm also using mavros with ROS2 foxy. I can only subscribe the topic "/mavros/state", but other topics such as "/mavros/local_position/pose" and "/mavros/altitude" cannot be subscribed. I can use "ros2 topic echo" to get these topics, and I use "rqt_graph" and find that my node is really subscribing these topics. Besides, I found that if I start the node with launch file, there will be a lot of topics named "/mavros/mavros" and "/mavros/mavros/xxxxx", but if I start using "ros2 run", the topics' name will be "mavros/xxxxx".

vooon commented 1 year ago

@Student865 unfortunately not exactly fixed as it still unclear why it's happening. But on newer releases of ros2 seems not happening. Foxy also EOLed, so i suggest you to upgrade.

clydemcqueen commented 1 year ago

Have you checked to make sure that your nodes are subscribing with the correct reliability setting? A lot of mavros topics are published "best_effort". If the reliability setting doesn't match, the messages will not be received.

+1 to upgrading to a supported version of ROS2, the ros2 tooling has been improved, which also might help.