Follow Mode and and mavlink messages

Hi there!

If I did not understand wrong, if I put a copter/quad in Follow Mode, I can inject its “master” location thru set_position_target_global_int_send(). So, the copter in Follow Mode should to its desired location. Am I correct?

I did a python script that does that, and the follower still stopped in the air. Would it be necessary to inject the “master” sysid somehow? Using relative altitude could be a problem? I am testing in SITL.

The same script used in Guided Mode moves the quad to desired locations. Here is the message sent:

          copter.mav.mav.set_position_target_global_int_send(
            0,  # timestamp
            copter.target_system,  # target system_id
            1,  # target component id
            mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT_INT,  # mavutil.mavlink.MAV_FRAME_GLOBAL_INT,
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_VX_IGNORE |
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_VY_IGNORE |
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_VZ_IGNORE |
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_AX_IGNORE |
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_AY_IGNORE |
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_AZ_IGNORE, # |
            # mavutil.mavlink.POSITION_TARGET_TYPEMASK_FORCE_SET |
            # mavutil.mavlink.POSITION_TARGET_TYPEMASK_YAW_IGNORE |
            # mavutil.mavlink.POSITION_TARGET_TYPEMASK_YAW_RATE_IGNORE,
            int(targetpos.lat * 1.0e7),  # lat
            int(targetpos.lng * 1.0e7),  # lon
            targetpos.alt,  # alt
            0,  # vx
            0,  # vy
            0,  # vz
            0,  # afx
            0,  # afy
            0,  # afz
            0,  # yaw
            0,  # yawrate
        )

Any thoughts @rmackay9 and @amilcarlucas?

@brunoolivieri,

That sounds right. Remember the message must be sent constantly at no less than once every 3 seconds or the vehicle will stop. It is also important that the system id of the mavlink message is not the same as the vehicle.

Thanks Randy.

Did you mean sysid? I am using follower sysid in the message.

Follower script gets “master” (id 11) location each 1Hz and send above message to SITL (id 20).

The short video (1min) below shows:

  • Quad id 20 in Guided mode following quad 11 correctly.
  • Then I switch the follower from Guided mode to Follow, and its stops. The whole message still the same and still be sending in the same way.

yes, that’s right… sysid.

The most common problem is the frame of the altitude. It may help to set the FOLL_DIST_MAX parameter to a very large value.

I’m sure you’ve see the wiki re follow mode but just in case…

Yes, I checked the documentation and also tested MAV_FRAME_GLOBAL_RELATIVE_ALT_INT and MAV_FRAME_GLOBAL_INT (same in both quads). My dummy follow mode made in Guided mode works.

Once the SITL engage in Follow mode, I noticed a minimal shake on the simulated follower, and the yaw is reset.

I got it almost working: The following process only starts if I send a “fly to” with Mission Planner. Without this step, the quad stay stopped:

I tried to find how MP sends such command, but I want able to passthrough MP interface components… :frowning:

I also tried to play a simple “goto” before engaging (after as well) the Follow mode without success in my script.

Do you know if it is necessary to flush or reset something before engage Follow mode?