DJI::OSDK::VirtualRC Class Reference
VirtualRC class has all the methods to mimic the RC functionality via OSDK. More...
#include <dji_virtual_rc.hpp>
Public Types | |
enum | CutOff { CutOff_ToLogic = 0, CutOff_ToRealRC = 1 } |
Public Member Functions | |
VirtualRC (Vehicle *vehicle=0) | |
void | setControl (bool enable, CutOff cutoffType) |
void | sendData (VirtualRCData Data) |
void | resetVRCData () |
void | neutralVRCSticks () |
Telemetry::RC | getRCData () const |
VirtualRCData | getVRCData () const |
void | setVRCData (const VirtualRCData &value) |
bool | isVirtualRC () const |
Vehicle * | getVehicle () const |
void | setVehicle (Vehicle *v) |
Static Public Member Functions | |
static Telemetry::RC | toRCData (VirtualRCData &vData) |
static VirtualRCData | toVirtualRCData (Telemetry::RC &rcData) |
Detailed Description
Member Function Documentation
◆ setControl()
void VirtualRC::setControl | ( | bool | enable, |
VirtualRC::CutOff | cutoffType | ||
) |
- Attention
- Safety notes You must use these methods below really carefully with following rules:
- Use API setControl(bool enable, CutOff cutoffType); only once in your main loop;
- Check your control device status by useing the following method: if(getControlDevice() != CONTROL_BY_VIRTUALRC) { reset code; }
-
Your reset code must not be "setControl(true);" without any status check It may cause your drone became a nut drone.
- Note
- You could quit your VRC(Virtual Remot Control) by switching your remote controller out of modeF
- Attention
- Most dangerous, setControl(true); must not be called over 0.5Hz or your drone will be locked in a logic-checking loop. And you cannot exit VirtualRC mode by switching your remote controller's mode. Actually, in this situation your drone will be a full automatically controlled by it self. It will keep flying until its bettery is empty or your code make it stop.
-
If you do not know what reset code you need to write, please just output your datalog and keep it empty.
- It would be realy dangous if you keep calling sendData(); in a loop with out control-losing protection. like :
Global: VirtualRCData myData;
Thread 1: while(1) { myData = myAPIToSetupDataFromGroundStation(); }
Thread 2: while(1) { sendData(myData); msleep(200); }
When your drone lose signal, it will keep the recent command sent by your API: myAPIToSetupDataFromGroundStation(); This may result in a catastrophic crash.
- Note
- API "sendData();" need to be called above 2Hz, and not greater than 25hz.
- API "sendSafeModeData();" will lead your drone hover;
The documentation for this class was generated from the following files:
- osdk-core/api/inc/dji_virtual_rc.hpp
- osdk-core/api/src/dji_virtual_rc.cpp