Sir,
The topside computer is connected to raspberry pi through an ethernet cable. I had installed python-pip, python-future and pymavlink in my topside computer, along with python 2.7.12. I followed the commands given in the ardusub page ‘https://www.ardusub.com/developers/pymavlink.html’. For eg, if I wanted to send RC values to my vehicle, the command given in the page is as given below.
Import mavutil
from pymavlink import mavutil
Create the connection
master = mavutil.mavlink_connection(‘udpin:0.0.0.0:14550’)
Wait a heartbeat before sending commands
master.wait_heartbeat()
Create a function to send RC values
More information about Joystick channels
def set_rc_channel_pwm(id, pwm=1500):
“”" Set RC channel pwm value
Args:
id (TYPE): Channel ID
pwm (int, optional): Channel pwm value 1100-1900
“”"
if id < 1:
print(“Channel does not exist.”)
return
# We only have 8 channels
#http://mavlink.org/messages/common#RC_CHANNELS_OVERRIDE
if id < 9:
rc_channel_values = [65535 for _ in range(8)]
rc_channel_values[id - 1] = pwm
master.mav.rc_channels_override_send(
master.target_system, # target_system
master.target_component, # target_component
*rc_channel_values) # RC channel list, in microseconds.
Set some roll
set_rc_channel_pwm(2, 1600)
Set some yaw
set_rc_channel_pwm(4, 1600)
The camera pwm value is the servo speed
and not the servo position
Set camera tilt to 45º with full speed
set_rc_channel_pwm(8, 1900)
The main doubt lies within the code. Here we gave a certain PWM value to each channel which implies we are setting the PWM value for yaw, roll etc which are the RC channel inputs. Now suppose, if I want the whole ardusub vehicle to move up/down, If I give the input " Vehicle up/down", all the thrusters which makes the vehicle to move up/down, should receive the PWM(it may be thruster2, thruster 3, thruster5) and these thruster should spin. Is it possible in ardusub using pymavlink. if so, How do I need to change the code?
Looking forward for your reply,
Thanking you,
Regards,
Deepak