Onboard-SDK-ROS
Public Types | Public Member Functions | Static Public Member Functions | List of all members
DJI::onboardSDK::VirtualRC Class Reference

VirtualRC class has all the methods to mimic the RC functionality via OnboardSDK. More...

#include <DJI_VirtualRC.h>

Public Types

enum  CutOff { CutOff_ToLogic = 0, CutOff_ToRealRC = 1 }
 

Public Member Functions

 VirtualRC (CoreAPI *ControlAPI=0)
 
void setControl (bool enable, CutOff cutoffType)
 
void sendData (VirtualRCData Data)
 
void sendData ()
 This function will be deprecated in a future release. Please use sendData(VirtualRCData Data) instead.
 
void resetData ()
 This function will not be maintained and will be deprecated in a future release. Please use resetVRCData() instead.
 
void sendSafeModeData ()
 This function will be deprecated in the future. Please use neutralVRCSticks() instead.
 
void neutralVRCSticks ()
 
VirtualRCData getVRCData () const
 New function - this will replace sendSafeModeData() in a future release.
 
RadioData getRCData () const
 
void setVRCData (const VirtualRCData &value)
 
bool isVirtualRC () const
 
CoreAPIgetApi () const
 
void setApi (CoreAPI *value)
 

Static Public Member Functions

static RadioData toRadioData (VirtualRCData &vData)
 
static RCData toRCData (VirtualRCData &vData)
 
static VirtualRCData toVirtualRCData (RadioData &rData)
 

Detailed Description

VirtualRC class has all the methods to mimic the RC functionality via OnboardSDK.

Member Function Documentation

RadioData VirtualRC::getRCData ( ) const
Warning
return type will change to RCData in a future release
The return type will change to RCData in a future release.
void VirtualRC::neutralVRCSticks ( )
Deprecated:
This function will not be maintained and will be deprecated in a future release - please use neutralVRCSticks() instead.
void VirtualRC::sendData ( VirtualRCData  Data)

api->send command was moved to this function from sendData().

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(); Somehow, you will never get your drone back in one pice, if this tragedy happend.

Note
API "sendData();" need to be called above 2Hz, and not greater than 25hz.
API "sendSafeModeData();" will lead your drone hover;
RadioData VirtualRC::toRadioData ( VirtualRCData vData)
static
Warning
old interface. Will be replaced by toRCData (see below) in a future release.
This function will be deprecated in a future release. Please use toRCData instead.

The documentation for this class was generated from the following files: