Hello, I’m trying to work something out about mavlink commands.
In dronedojo, it has sample codes for the rover where the robot is supposed to turn right and turn left or even move forward. Using the sample code below, I tested the rover whether it does move or not.
def send_local_ned_velocity(vx, vy, vz): msg = vehicle.message_factory.set_position_target_local_ned_encode( 0, 0, 0, mavutil.mavlink.MAV_FRAME_BODY_OFFSET_NED, 0b0000111111000111, 0, 0, 0, vx, vy, vz, 0, 0, 0, 0, 0) vehicle.send_mavlink(msg) vehicle.flush() counter=0 while counter < 5: send_local_ned_velocity(1,1,0) print("Turning to the right") time.sleep(2) send_local_ned_velocity(1,-1,0) print("Turning to the left") counter = counter + 1
I have no problem implementing the forward movement by sending
However, my only issue is that the right and left rotations are not that desirable. Supposed I want the rover to turn at a specific angle. So at first, I tried implementing the rotation by time-based. Here in this video, I tried implementing send_local_ned_velocity(0,-1,0) for 10 seconds for it to turn left(for 10 seconds). But I don’t understand why it suddenly turned right when it is not supposed to do so.
So my question is that am I missing something about the mavlink here? My GPS is not really that good such that it has a lot of drifts. But my forward movement always work so i’m confused if is this still a GPS problem. Or are there any better mavlink commands that can implement a good rotation instead of MAV_FRAME_BODY_OFFSET_NED and set_position_target_local_ned_encode. Thanks
Another test: Right movement (one of the few good tries)