get_opt_flow_position() / getOptFlowPosition()

Description

This function gets the x and y coordinates from the optical flow sensor.
Keep in mind, the positioning does not take rotation into account.

Syntax

Python: get_opt_flow_position()
Arduino: getOptFlowPosition()

Parameters

None

Returns

Outputs to visual UI. In code, it returns a class in Python and struct in Arduino.

Example Code
Python
#Python code
import CoDrone

def main():
    drone = CoDrone.CoDrone()
    drone.pair()

    # print the optical flow position x,y value
    position = drone.get_opt_flow_position()
    print(position.X, position.Y)

if __name__ == '__main__':
    main()
Arduino
//Arduino code
//Code for print request data to serial monitor
#include<CoDrone.h>     //header

void setup(){
    //open serial and connect
    CoDrone.begin(115200);
    CoDrone.pair(Nearest);  
}

void loop(){
    // Struct for get optical flow sensor data
    optdata opt;

    CoDrone.Send_LinkModeBroadcast(LinkBroadcast_Active);   //link module mode change => Active
    opt = CoDrone.getOptFlowPosition();                     //save request data
    delay(100);

    CoDrone.Send_LinkModeBroadcast(LinkModeMute);           //link module mode change => Mute
    delay(100);

    Serial.println("");
    Serial.println("--------- Now -----------");
    Serial.print("opt x : \t");
    Serial.println(opt.x);
    Serial.print("opt y : \t");
    Serial.println(opt.y);  
}