Hello , we are trying to manage and run our T200 thrusters manually by those codes but there seems to be an error. We are using pixhawk and sending codes by jetson using the pymavlink commands to the t200 thrusters and we are expecting to have full manual control them, but no matter what pwm we pick in the last line set_rc_channel_pwm(5,1650)
the speed never changes
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import argparse
import cv2
import cv2 as CV #if you are using python2 you must add it, otherwise you'll gel warning.
import time
import threading
from pymavlink import mavutil
mode = 'MANUAL'
#Try: ['MANUAL', 'CIRCLE', 'STABILIZE', 'TRAINING', 'ACRO', 'FBWA', 'FBWB', 'CRUISE', 'AUTOTUNE', 'AUTO', 'RTL', 'LOITER', 'TAKEOFF', 'AVOID_ADSB', 'GUIDED', 'INITIALISING', 'QSTABILIZE', 'QHOVER', 'QLOITER', 'QLAND', 'QRTL', 'QAUTOTUNE', 'QACRO', 'THERMAL']
master = mavutil.mavlink_connection( # aracin baglantisi
'/dev/ttyACM0',
baud=115200)
#master = "mavutil.mavlink_connection('udpin:192.168.2.2:14550')" #if it is going to be controlled on computer
def set_rc_channel_pwm(id, pwm=1500):
if id < 1:
print("Channel does not exist.")
return
if id < 9: # communication with ardusub
rc_channel_values = [65535 for _ in range(8)]
rc_channel_values[id - 1] = pwm
master.mav.rc_channels_override_send(
master.target_system,
master.target_component,
*rc_channel_values)
if mode not in master.mode_mapping():
print('Unknown mode : {}'.format(mode))
print('Try:', list(master.mode_mapping().keys()))
exit(1)
# Get mode ID
mode_id = master.mode_mapping()[mode]
# Set new mode
# master.mav.command_long_send(
# master.target_system, master.target_component,
# mavutil.mavlink.MAV_CMD_DO_SET_MODE, 0,
# 0, mode_id, 0, 0, 0, 0, 0) or:
# master.set_mode(mode_id) or:
master.mav.set_mode_send(
master.target_system,
mavutil.mavlink.MAV_MODE_FLAG_CUSTOM_MODE_ENABLED,
mode_id)
# Check ACK
ack = False
while not ack:
# Wait for ACK command
ack_msg = master.recv_match(type='COMMAND_ACK', blocking=True)
ack_msg = ack_msg.to_dict()
# Check if command in the same in `set_mode`
if ack_msg['command'] != mavutil.mavlink.MAVLINK_MSG_ID_SET_MODE:
continue
# Print the ACK result !
print(mavutil.mavlink.enums['MAV_RESULT'][ack_msg['result']].description)
break
time.sleep(3)
master.mav.command_long_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_CMD_COMPONENT_ARM_DISARM,
0,
1, 0, 0, 0, 0, 0, 0)
while(True):
set_rc_channel_pwm(5,1650)
time.sleep(7)