Virtual Stick Sample

2024-05-17
No Rating

Sample Introduction

The virtual stick function simulates the working of the remote controller sticks and sends stick commands to simulate the manual flight to realize the automatic flight. Through this function, users can open or close the virtual stick mode, get or set the moving amount of the stick, add the virtual stick state listener, and use the advanced mode of the virtual stick function.

Notice:

  • To use the virtual stick function, the drone should not be in any automatic tasks, and the remote controller should be in "normal position". For example, the "normal position" means the N position in the remote controller of drone model M3E/M3T.
  • For aircraft models M3E, M3T, and M3M, if the firmware version is below V7.01.10.03, obstacle sensing will be disabled when virtual stick mode is activated. We recommend updating the aircraft to the latest firmware version for optimal functionality.

Virtual Stick Advanced Mode

When the virtual stick advanced mode is opened, the control data of getLeftStick() and getRightStick() will no longer take effect. Three modes can be used to move the drone.

  • Roll Pitch Control Mode: Set the roll axis and pitch axis in velocity mode or angle mode to change the horizontal position of the drone.
  • Yaw Control Mode: Set the yaw axis in angular velocity mode to change the wayline position of the drone.
  • Vertical Throttle Control Mode: Send command in velocity mode or height mode to change the vertical position.

Related drone knowledge about virtual stick is introduced at Flight Controlleropen in new window. For the parameters can be set in advanced mode and the parameter range, please read virtual stick management class IVirtualStickManageropen in new window.

Control Authority Explanation

The current flight control authority owner will be monitored, as well as whether the virtual stick mode is opened and whether the virtual stick advanced mode is opened. During the period when the virtual stick is opened, the flight control authority owner is MSDK. If the flight control authority is grabbed, virtual stick mode should be reopened and the flight control authority can be regained.

Note: The OSDK mentioned below is the current PSDK. In v3 PSDK, OSDK is merged into PSDK and called PSDK. For more information, you can read the PSDK Tutorialopen in new window.

  • M30 series and the later models: Regardless of whether the flight control authority is on the remote controller or OSDK, MSDK can call enableVirtualStick() to get the control authority and call disableVirtualStick() to release it to the remote controller.

  • M300 RTK: MSDK can only get the flight control authority from the remote controller. If MSDK grabs the control authority from OSDK, it will cause authority confusion. This problem comes from the firmware and temporarily has no fixed plan.

Interface Calling Process

The following figure is a calling example of virtual stick interfaces. Users don't need to follow every step, please call interfaces according to the real situation. For details, please refer to the virtual stick management class IVirtualStickManageropen in new window.

Note:

  • Before using sendVirtualStickAdvancedParam() to send parameters, the virtual stick advanced mode should be opened through setVirtualStickAdvancedModeEnabled().
  • When the virtual stick advanced mode is opened, the left stick getLeftStick() and the right stick getRightStick() will no longer take effect.
  • Users can send parameters at a specific frequency according to their own requirements. The recommended frequency is 5HZ to 25HZ.

Sample Acquisition

Go to Virtual Stick Sampleopen in new window.

If you have any comments or confusion about our documentation, you can click here to give feedback and we will get back to you as soon as possible.