Hi, I am a beginner trying to control T200 thrusters using pymavlink python. How can i make my thrusters move forward, backward, downward and so on. I tried using rc_channel_override_send() but i got some error saying that 11 or 12 positional arguments required but 21 were given. I tried using set_servo_pwm() but it didnt work. And is there any way to make my auv move to certain distance for eg: if 5m forward command were given then my auv should go 5m forward.
I am using Jetson Nano, Pixhawk 2.4.3, Ardusub 4
Communicating nano and pixhawk using usb connection.
Now i can control my thrusters using manual_control() but i can give movement commands with a delay of 2 seconds, command without delay is not executed. Exact 2 seconds delay is required for to run thrusters constantly. how can i change the delay?
I searched for this problem in this entire forum i couldn’t get it solved.
i can give movement commands using manual control but with a delay of 2 seconds, command without delay is not executed. Exact 2 seconds delay is required for to run thrusters constantly. how can i change the delay?
delay is given in the while loop
P.S: mentioning someone because no one answered my previous post and my old post been posted about week ago
How are you getting the python commands to the ESCs for the thrusters? We need a lot more info about your system architecture to be able to help.
Are you running ROS (1or 2)?
Python to some PWM controller?
Hi @jagajith23, welcome to the forum
Apologies for the delay on responding to this - I’m travelling at the moment along with several other members of the team, which has made fast turnaround on responses quite difficult.
That issue sounds potentially the same as this one, so I’d recommend reading through that and trying some of the suggestions there.
Precise positioning requires some form of positioning system, or at least a velocity sensor) for somewhat accurate movement estimation. It’s possible to use the flight controller’s internal accelerometer for very rough movement estimates, but positioning error grows quickly with double-integrated quantities that have no source of feedback.
I’m not certain what you’re referring to here. Are you saying if you don’t add a delay to your code it doesn’t work, or that your commands stop working after some amount of time (that you’re referring to as a delay)? If it’s the latter, you’re most likely running into a failsafe that you’re not handling correctly.
Hey, Greetings for the day, Thank you for your answers @EliotBR
from pymavlink import mavutil
buttons = 1 + 1 << 3 + 1 << 7
def control(x=0, y=0, z=500):
z, # 500 means neutral throttle
if mode not in master.mode_mapping():
print("Unknown mode: %s" % mode)
print("Available modes: %s" % master.mode_mapping())
# Get mode ID
mode_id = master.mode_mapping()[mode]
# Set mode
# Set the target depth as negative values
int(1e3 * (time.time() - boot_time)), # ms since boot
), lat_int=0, lon_int=0, alt=depth,
vx=0, vy=0, vz=0,
afx=0, afy=0, afz=0, yaw=0, yaw_rate=0
# Create the connection
master = mavutil.mavlink_connection('/dev/ttyACM0', baud=115200)
# Wait a heartbeat before sending commands
# Choose a mode
mode = 'ALT_HOLD'
for _ in range(10):
this is the code i developed. i’m referring delay as time.sleep(2). if i run this for loop for one time, my thrusters will run for two seconds and if i give any command without time.sleep(2) , those commands are not executed for example:
for _ in range(10):
my thrusters will run for only 2 seconds for the above code but if add time.sleep(2) my thrusters will run for 20 seconds. How can i overcome this problem
Hey, Greetings for the day,
i’m not using ROS here
i’m just using pymavlink manual_control commands to control my auv.
And now encountered a new problem somehow i messed up with my code, now vehicle type changed to default MAV_TYPE_FIXED_WING. how can i change it back to MAV_TYPE_SUBMARINE. Can you provide me a code sample. And can you also provide me a code sample for to change FS_PILOT_TIMEOUT and RC_OVERRIDE_TIME parameters. @EliotBR
Thanks & Regards
That’s most likely a failsafe issue - with no delay the loop sends the 10 control commands within a few milliseconds, and then a few seconds later with no pilot input and no heartbeats sent the vehicle will failsafe and disarm. When you add a sleep your vehicle sends additional pilot input commands within the failsafe period until it finishes the loop, after which there’s a period of no pilot input and a failsafe occurs to stop the vehicle.
You can overcome that by either sending regular heartbeats and control input while you want to control the vehicle (recommended), or by adjusting the failsafe timeout(s) and/or turning off the failsafes entirely (not recommended).
Either the connection was not established correctly, your flight controller is not running ArduSub firmware, or you’re connecting to a different vehicle. None of those can be fixed with a code sample - you may wish to install ArduSub.
Parameters are persistent across reboots, so should only need to be changed / set once (unless you flash new firmware onto your flight controller). If you want to do it with code you can use our read and write parameters pymavlink example, or something like this, but you can also set them using QGroundControl if you want (you can connect your Pixhawk directly to your topside computer to do this, if you don’t have an existing connection through your Jetson Nano).
Thank you for your time @EliotBR
But one last thing, can you give some code sample for sending regular heartbeats and control input.
Outside of the “something like this” example I already linked you to, this forum comment covers sending regular heartbeats with a periodic event. You can use the same idea to send regular control inputs as well.
You may also wish to look at other posts with the #pymavlink tag for some inspiration.
You’re also welcome to provide your own examples and/or attempts and discuss here how to fix or improve them
Is there any way to increase gain of thrusters using pymavlink?
I searched this forum I got some resource but I couldn’t get any code samples. Since, I am a beginner I don’t know how to implement those. So, kindly provide me with a code sample.
And is there anyway that I could change controls like if I send forward command, it should move forward until i send stop command or any other command. Can you send me code samples for these too??
Gain settings are handled by setting parameters, and the actual gain control is handled by manual_control messages using the
gain_* joystick button functions.
Yes, that should be possible with the
While we try to make our documentation and examples as accessible as possible, we can’t always provide examples on demand. The best way to get help is to provide what you’re trying to achieve, what you’ve tried so far, and what is and isn’t working, and we can try to provide advice on examples to refer to, or how to improve/fix your existing attempt