Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help with mavros rc in #1959

Open
naorwaiss opened this issue Jun 14, 2024 · 0 comments
Open

help with mavros rc in #1959

naorwaiss opened this issue Jun 14, 2024 · 0 comments

Comments

@naorwaiss
Copy link

hi i try to do some operation with mavros ros2
hardware - i am connect telem 433 of holybro to linux computer with joystick and try to run this node and script(add at the end):

  1. mavros node:
    ros2 run mavros mavros_node --ros-args -p fcu_url:=/dev/ttyUSB0:57600 -p gcs_url:=udp://@192.168.1.142:14550 -p sysid:=1
  2. joy node
    3)script (at the end)

i try with another widows computer to connect via udp and check if i get radio at the radio calibartion and i dont get any information

i try to run this script at px4 with sitl and get data about the controller

the script:

import rclpy
from rclpy.node import Node
from sensor_msgs.msg import Joy
from mavros_msgs.msg import OverrideRCIn  # Ensure this is the correct message type
import time

class RCOverrideNode(Node):
    def __init__(self):
        super().__init__('rc_override_node')
        self.publisher_ = self.create_publisher(OverrideRCIn, '/mavros/rc/override', 10)  # Update the publisher to OverrideRCIn
        self.joy_subscription = self.create_subscription(
            Joy,
            '/joy',
            self.joy_callback,
            10
        )
        self.joy_subscription  # prevent unused variable warning

        # Call reset_parameters once at startup
        self.reset_parameters()

    def reset_parameters(self):
        # Set all channels to 65535 at the start to indicate no override
        rc_override = OverrideRCIn()
        rc_override.channels = [65535] * 12  # Assuming 12 channels
        self.publisher_.publish(rc_override)
        self.get_logger().info('RC Override parameters reset to 65535')
        time.sleep(2)
        rc_override.channels = [0] * 12  # Assuming 12 channels
        self.publisher_.publish(rc_override)
        self.get_logger().info('RC Override parameters reset to 0')

    def joy_callback(self, msg):
        rc_override = OverrideRCIn()  # Create an instance of OverrideRCIn

        # Map joystick axes/buttons to RC channels
        rc_override.channels = [
            self.scale_value(msg.axes[0], -1.0, 1.0, 1000, 2000),  # Roll (Ch1)
            self.scale_value(msg.axes[1], -1.0, 1.0, 1000, 2000),  # Pitch (Ch2)
            self.scale_value(msg.axes[2], -1.0, 1.0, 1000, 2000),  # Throttle (Ch3)
            self.scale_value(msg.axes[3], -1.0, 1.0, 1000, 2000)   # Yaw (Ch4)
        ]

        # Debug statements
        self.get_logger().info(f'Joy axes: {msg.axes}')
        self.get_logger().info(f'RC Override: {rc_override.channels}')

        # Publish the RC override message
        self.publisher_.publish(rc_override)

    @staticmethod
    def scale_value(value, src_min, src_max, dst_min, dst_max):
        # Scale value from source range to destination range
        src_range = src_max - src_min
        dst_range = dst_max - dst_min
        scaled_value = ((value - src_min) * dst_range) / src_range + dst_min
        return int(scaled_value)

def main(args=None):
    rclpy.init(args=args)
    node = RCOverrideNode()
    rclpy.spin(node)
    node.destroy_node()
    rclpy.shutdown()

if __name__ == '__main__':
    main()

i think i got some problem with the callibration of my fc

thanks for the help

Mavros: 2.7.0
ROS: iron
Ubuntu: 22.04

Autopilot type and version

[ X ] ArduPilot
[ ] PX4

Version: 4.4.0

Diagnostics

header:
  stamp:
    sec: 1718367553
    nanosec: 449656643
  frame_id: ''
status:
- level: "\0"
  name: 'mavros: MAVROS UAS'
  message: connected
  hardware_id: uas:///uas1
  values: []
- level: "\x02"
  name: 'mavros: GPS'
  message: No satellites
  hardware_id: uas:///uas1
  values:
  - key: Satellites visible
    value: '0'
  - key: Fix type
    value: '0'
  - key: EPH (m)
    value: Unknown
  - key: EPV (m)
    value: Unknown
- level: "\x01"
  name: 'mavros: Mount'
  message: Can not diagnose in this targeting mode
  hardware_id: uas:///uas1
  values:
  - key: Mode
    value: '255'
- level: "\x02"
  name: 'mavros: System'
  message: Sensor health
  hardware_id: uas:///uas1
  values:
  - key: Sensor present
    value: '0x5330FC0F'
  - key: Sensor enabled
    value: '0x52209C0F'
  - key: Sensor health
    value: '0x43109C0B'
  - key: 3D gyro
    value: Ok
  - key: 3D accelerometer
    value: Ok
  - key: 3D magnetometer
    value: Fail
  - key: absolute pressure
    value: Ok
  - key: 3D angular rate control
    value: Ok
  - key: attitude stabilization
    value: Ok
  - key: yaw position
    value: Ok
  - key: motor outputs / control
    value: Ok
  - key: AHRS subsystem health
    value: Fail
  - key: Battery
    value: Ok
  - key: pre-arm check status. Always healthy when armed
    value: Fail
  - key: propulsion (actuator, esc, motor or propellor)
    value: Ok
  - key: CPU Load (%)
    value: '31.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.40'
  - key: Current
    value: '-0.1'
  - key: Remaining
    value: '99.0'
- level: "\0"
  name: 'mavros: Heartbeat'
  message: Normal
  hardware_id: uas:///uas1
  values:
  - key: Heartbeats since startup
    value: '106'
  - key: Frequency (Hz)
    value: '1.000003'
  - key: Vehicle type
    value: Quadrotor
  - key: Autopilot type
    value: ArduPilot
  - key: Mode
    value: STABILIZE
  - key: System status
    value: STANDBY
- level: "\0"
  name: 'mavros: 3DR Radio'
  message: Normal
  hardware_id: uas:///uas1
  values:
  - key: RSSI
    value: '145'
  - key: RSSI (dBm)
    value: '-50.7'
  - key: Remote RSSI
    value: '141'
  - key: Remote RSSI (dBm)
    value: '-52.8'
  - key: Tx buffer (%)
    value: '100'
  - key: Noice level
    value: '56'
  - key: Remote noice level
    value: '65'
  - key: Rx errors
    value: '5'
  - key: Fixed
    value: '0'
---
header:
  stamp:
    sec: 1718367554
    nanosec: 443034005
  frame_id: ''
status:
- level: "\0"
  name: 'mavros_router: MAVROS Router'
  message: ok
  hardware_id: none
  values:
  - key: Endpoints
    value: '3'
  - key: Messages routed
    value: '5015'
  - key: Messages sent
    value: '9944'
  - key: Messages dropped
    value: '0'
- level: "\0"
  name: 'mavros_router: endpoint 1000: /dev/ttyUSB0:57600'
  message: ok
  hardware_id: none
  values:
  - key: Received packets
    value: '4591'
  - key: Dropped packets
    value: '0'
  - key: Buffer overruns
    value: '0'
  - key: Parse errors
    value: '0'
  - key: Rx sequence number
    value: '71'
  - key: Tx sequence number
    value: '0'
  - key: Rx total bytes
    value: '140357'
  - key: Tx total bytes
    value: '7877'
  - key: Rx speed
    value: '1605.000000'
  - key: Tx speed
    value: '59.000000'
  - key: Remotes count
    value: '5'
  - key: Remote [0]
    value: '0.0'
  - key: Remote [1]
    value: '1.0'
  - key: Remote [2]
    value: '1.1'
  - key: Remote [3]
    value: '51.0'
  - key: Remote [4]
    value: '51.68'
- level: "\0"
  name: 'mavros_router: endpoint 1001: udp://@192.168.1.142:14550'
  message: ok
  hardware_id: none
  values:
  - key: Received packets
    value: '292'
  - key: Dropped packets
    value: '0'
  - key: Buffer overruns
    value: '0'
  - key: Parse errors
    value: '0'
  - key: Rx sequence number
    value: '246'
  - key: Tx sequence number
    value: '0'
  - key: Rx total bytes
    value: '5640'
  - key: Tx total bytes
    value: '142842'
  - key: Rx speed
    value: '38.000000'
  - key: Tx speed
    value: '1636.000000'
  - key: Remotes count
    value: '3'
  - key: Remote [0]
    value: '0.0'
  - key: Remote [1]
    value: '255.0'
  - key: Remote [2]
    value: '255.190'
- level: "\0"
  name: 'mavros_router: endpoint 1002: /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: 1718367554
    nanosec: 449808470
  frame_id: ''
status:
- level: "\0"
  name: 'mavros: MAVROS UAS'
  message: connected
  hardware_id: uas:///uas1
  values: []
- level: "\x02"
  name: 'mavros: GPS'
  message: No satellites
  hardware_id: uas:///uas1
  values:
  - key: Satellites visible
    value: '0'
  - key: Fix type
    value: '0'
  - key: EPH (m)
    value: Unknown
  - key: EPV (m)
    value: Unknown
- level: "\x01"
  name: 'mavros: Mount'
  message: Can not diagnose in this targeting mode
  hardware_id: uas:///uas1
  values:
  - key: Mode
    value: '255'
- level: "\x02"
  name: 'mavros: System'
  message: Sensor health
  hardware_id: uas:///uas1
  values:
  - key: Sensor present
    value: '0x5330FC0F'
  - key: Sensor enabled
    value: '0x52209C0F'
  - key: Sensor health
    value: '0x43109C0B'
  - key: 3D gyro
    value: Ok
  - key: 3D accelerometer
    value: Ok
  - key: 3D magnetometer
    value: Fail
  - key: absolute pressure
    value: Ok
  - key: 3D angular rate control
    value: Ok
  - key: attitude stabilization
    value: Ok
  - key: yaw position
    value: Ok
  - key: motor outputs / control
    value: Ok
  - key: AHRS subsystem health
    value: Fail
  - key: Battery
    value: Ok
  - key: pre-arm check status. Always healthy when armed
    value: Fail
  - key: propulsion (actuator, esc, motor or propellor)
    value: Ok
  - key: CPU Load (%)
    value: '31.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.40'
  - key: Current
    value: '-0.1'
  - key: Remaining
    value: '99.0'
- level: "\0"
  name: 'mavros: Heartbeat'
  message: Normal
  hardware_id: uas:///uas1
  values:
  - key: Heartbeats since startup
    value: '107'
  - key: Frequency (Hz)
    value: '0.999982'
  - key: Vehicle type
    value: Quadrotor
  - key: Autopilot type
    value: ArduPilot
  - key: Mode
    value: STABILIZE
  - key: System status
    value: STANDBY
- level: "\0"
  name: 'mavros: 3DR Radio'
  message: Normal
  hardware_id: uas:///uas1
  values:
  - key: RSSI
    value: '136'
  - key: RSSI (dBm)
    value: '-55.4'
  - key: Remote RSSI
    value: '142'
  - key: Remote RSSI (dBm)
    value: '-52.3'
  - key: Tx buffer (%)
    value: '100'
  - key: Noice level
    value: '57'
  - key: Remote noice level
    value: '65'
  - key: Rx errors
    value: '5'
  - key: Fixed
    value: '0'
---

Check ID

---
header:
  stamp:
    sec: 1718367767
    nanosec: 147378560
  frame_id: ''
connected: true
armed: false
guided: false
manual_input: true
mode: STABILIZE
system_status: 3
---
header:
  stamp:
    sec: 1718367768
    nanosec: 206044287
  frame_id: ''
connected: true
armed: false
guided: false
manual_input: true
mode: STABILIZE
system_status: 3
---

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant