These are chat archives for dronekit/dronekit-android

15th
Aug 2018
Esteban Gallardo
@EstebanGameDevelopment
Aug 15 2018 15:34
Hello, I'm trying to move a vehicle by changing the velocity. I've been able to perform the operation successfully in Python, but for my project I can not use Python, so I'm using Android to try to make the same operation. The working functionality in Python is:
def send_ned_velocity(velocity_x, velocity_y, velocity_z):
    """
    Move vehicle in direction based on specified velocity vectors.
    """
    msg = vehicle.message_factory.set_position_target_local_ned_encode(
        0,       # time_boot_ms (not used)
        0, 0,    # target system, target component
        mavutil.mavlink.MAV_FRAME_BODY_NED, # frame
        0b0000111111000111, # type_mask (only speeds enabled)
        0, 0, 0, # x, y, z positions (not used)
        velocity_x, velocity_y, velocity_z, # x, y, z velocity in m/s
        0, 0, 0, # x, y, z acceleration (not supported yet, ignored in GCS_Mavlink)
        0, 0)    # yaw, yaw_rate (not supported yet, ignored in GCS_Mavlink)
    # send command to vehicle
    vehicle.send_mavlink(msg)
    vehicle.flush()
What I'm trying to do in Android is:
                    // Create the message
                    msg_local_position_ned msgMessageInterval = new msg_local_position_ned();
                    msgMessageInterval.x = 0;
                    msgMessageInterval.y = 0;
                    msgMessageInterval.z = 0;
                    msgMessageInterval.vx = 10;
                    msgMessageInterval.vy = 0;
                    msgMessageInterval.vz = 0;
                    msgMessageInterval.time_boot_ms = 0;

                    MavlinkMessageWrapper mavlinkMessageWrapper = new MavlinkMessageWrapper(msgMessageInterval);

                    // Send the message to MavLink
                    ExperimentalApi.getApi(drone).sendMavlinkMessage(mavlinkMessageWrapper);

                    // Listen for the message received
                    drone.addMavlinkObserver(new MavlinkObserver() {
                        @Override
                        public void onMavlinkMessageReceived(MavlinkMessageWrapper mavlinkMessageWrapper) {
                            System.out.println("MESSAGE RECEIVED="+mavlinkMessageWrapper.getMavLinkMessage().toString());
                        }
                    });
What am I missing? Any help would be greatly appreciated since I'm running out of time. Thanks.