Issue on receiving data packet QX287

Discussion in 'MōVI Pro API' started by Chong Kwan Lok, Jul 11, 2017.

  1. Chong Kwan Lok

    Chong Kwan Lok New Member

    Joined:
    Jul 4, 2017
    Messages:
    10
    Likes Received:
    0
    Hi all! There are some questions on receiving the data packet QX287.

    1.I would like to ask about the API documentation "7. Implement a custom callback send the packet to comm port function that will send the constructed message to the communication port, or intermediate buffer." Does it mean I need to set the values manually to send out the packets of QX277? Or there are some codes in C that I can implement to send the packets of QX277 with the Freefly code provided?

    2. I looked into the wire definition of the QX287 and I could not find the representation of Gimbal RR, RX, RY, RZ. What are the bits inside represented? I knew that they are all 16-bit long integer but I want to know the specific meaning of each bit.

    3. I found that the received packet changed a little bit comparing to the one which received one second before. And I checked that the packet that I sent was continuously the same. Is it normal to have some diversity owing to the noise to the system?

    4. When I sent the QX277 packets to the MōVI Pro, I analyze the data in the packet and I found that there were some dummy data in the first few bits which were not stated in the API documentation. However, the MōVI Pro worked well with the programmer. Therefore, I would like to ask is whether it is normal to have some dummy variables before the 'Q' and 'X' headers appear or not.

    For your reference, I am neither using Arduino and STM32. I am using ICD 3 to compile the code. Will there be any difference in the coding among this two programming software? It would be my honor if you can solve these questions in my head! Thanks in advance!!
     
  2. Deniz Ozgoren

    Deniz Ozgoren Support Mage
    Staff Member

    Joined:
    Dec 17, 2015
    Messages:
    159
    Likes Received:
    28
    I recommend looking at the Arduino examples to see the most basic implementation of the API. That can help you understand your first question: https://docs.google.com/document/u/1/d/16L65isO7Ifh3iWyqnqK69DHKzTWpJYlfl-hDMx7ABkY/edit

    RR, RX, RY, RZ -> They represent a quaternion

    "Will there be any difference in the coding among this two programming software?"
    • Any platform that can run C code and can output a serial can use the API. Once you setup the API and then make it generate a QX packet, its your responsibility to send it out as a serial command on your platform.
     
  3. Deniz Ozgoren

    Deniz Ozgoren Support Mage
    Staff Member

    Joined:
    Dec 17, 2015
    Messages:
    159
    Likes Received:
    28
    Also, need to look into updating the documentation. I received this message and didn't had a chance to look and verify yet. But sharing with you: "...It appears the API Doc is missing 2 bytes for both the QX277 and QX287 packets. I've taken this into account while developing the Java/C# APIs..."
     
  4. Andy Johnson-Laird

    Andy Johnson-Laird Administrator
    Staff Member

    Joined:
    Jul 31, 2012
    Messages:
    9,574
    Likes Received:
    1,012
    Deniz: Does this mean that the data fields are off by two bytes from what is described in the documentation? Or are you saying that the message you says that there are just two bytes that have not been documented?

    Cheers
    Andy

    Forensic Software & sUAV / Drone Analyst : Photographer : Videographer : Pilot (Portland, Oregon, USA): Trees=2, Ground=1, Props=11. :(
    The Ground Is The Limit™
    ---------- Forensic Drone Analyst : Forensic sUAV Analyst : Forensic Unmanned Aircraft Analyst : Forensic Drone Expert
     
  5. Chong Kwan Lok

    Chong Kwan Lok New Member

    Joined:
    Jul 4, 2017
    Messages:
    10
    Likes Received:
    0
    Hi Deniz! Thanks for your reply at first and I understood the measurement of the gimbals. However, I looked into the Arduino examples to see the most basic implementation of the API and I still cannot make any moves by using my radio controller. Below is my code of inside the mplab. Hope you can take a look and give me some directions on doing this. And I am using the Sbus protocol to receive the data from the radio controller. Is it because the protocol is different ? Thanks a lot!

    FreeflyAPI.begin();

    //Initialize Freefly Communications protocol
    QX_InitCli(&QX_Clients[0], QX_DEV_ID_MOVI_API_CONTROLLER, QX_ParsePacket_Cli_MoVI_Ctrl_CB);


    while (1)//main loop
    {
    // <editor-fold defaultstate="collapsed" desc="20150820 NCL : Magic Switch function">
    //verify if we have already a communication with the first receiver
    if(sbusU3_get_new_frame())
    {//copy values even though frame lost bit is set
    rx1.timeout_cnt = TIME_OUT_VALUE_RX1;//reload the timeout counter
    rx1.new_frame = 1;//indicate if a new frame is available. 2012-03-26 - TWI

    for (i=1;i<=(SBUS_CHANNEL_NUMBER-2);i++)
    {
    rx1_servo_values.raw_values[i-1] = sbusU3_get_ch(i);
    }
    rx1_servo_values.Digit_1 = sbusU3_get_D_ch(1);
    rx1_servo_values.Digit_2 = sbusU3_get_D_ch(2);
    }

    if(rx1.timeout_cnt == 0)
    {
    rx1.timeout = 1;
    rx1.rssi = 0;
    }
    else
    {
    rx1.timeout = 0;
    rx1.rssi = sbusU3_get_RSSI();
    }

    rx1.failsafe = sbusU3_get_FailSafe_status();
    rx1.framelost = sbusU3_get_FrameLost_status();


    //verify if we have already a communication with the second receiver
    if(sbusU4_get_new_frame())
    {//copy values even though frame lost bit is set
    rx2.timeout_cnt = TIME_OUT_VALUE_RX2;//reload the timeout counter
    rx2.new_frame = 1;//indicate if a new frame is available. 2012-03-26 - TWI

    for (i=1;i<=(SBUS_CHANNEL_NUMBER-2);i++)
    {
    rx2_servo_values.raw_values[i-1] = sbusU4_get_ch(i);
    }

    rx2_servo_values.Digit_1 = sbusU4_get_D_ch(1);
    rx2_servo_values.Digit_2 = sbusU4_get_D_ch(2);
    }

    if(rx2.timeout_cnt == 0)
    {
    rx2.timeout = 1;
    rx2.rssi = 0;
    }
    else
    {
    rx2.timeout = 0;
    rx2.rssi = sbusU4_get_RSSI();
    }

    rx2.failsafe = sbusU4_get_FailSafe_status();
    rx2.framelost = sbusU4_get_FrameLost_status();


    //state machines for the magic switch function
    rx1_fsm();
    rx2_fsm();
    div_fsm();
    ss_fsm();

    //source selection
    switch (magic_switch.current_state)
    {
    case MS_MANU_ST:
    output_servo_values = div_servo_values;//je met l'adresse dans un autre pointeur
    break;
    case MS_FS_ST:
    output_servo_values = &failsafe_mode;//
    break;
    default:
    //start case
    output_servo_values = &failsafe_mode;
    break;
    }

    // </editor-fold>

    servo_value = div_servo_values->Channel_1;
    servo_value_1 = div_servo_values ->Channel_2;
    servo_value_2 = div_servo_values ->Channel_3;
    servo_value_3 = div_servo_values ->Channel_5;


    FreeflyAPI.control.roll.type = RATE;
    FreeflyAPI.control.tilt.type = RATE;

    joystick_y = servo_value_1;
    //FreeflyAPI.control.roll.value = joystick_y;
    sliderValueForY = map_f ((float)servo_value_1, 0.0f, 2047.0f, -60.0f, 60.0f);

    joystick_x = servo_value_3;
    FreeflyAPI.control.tilt.value = joystick_x;

    //Using Channel 1 to control the mode

    if(servo_value < 353){
    FreeflyAPI.control.tilt.type = DEFER;
    FreeflyAPI.control.roll.type = RATE; //only control roll axis(turn up the button)
    }
    else if (servo_value > 353 && servo_value < 1695){ // neutral value
    FreeflyAPI.control.tilt.type = RATE;
    FreeflyAPI.control.roll.type = RATE;
    }
    else if (servo_value > 1695){ // kill mode , turn the button down
    kill = !kill;
    }
    FreeflyAPI.control.gimbal_kill = kill;


    // <editor-fold defaultstate="collapsed" desc="buffer for QX277">

    /*buffer[0] = 0x51;
    buffer[1] = 0x58;
    buffer[2] = 0x1A;
    buffer[3] = 0x95;
    buffer[4] = 0x02;
    buffer[5] = 0x42;
    buffer[6] = 0x00;
    buffer[7] = 0x00;
    buffer[8] = 0x00;
    buffer[9] = 0x00;
    buffer[10] = 0x00;
    buffer[11] = 0x2A;
    buffer[12] = 0x00;
    buffer[13] = 0x00;
    buffer[14] = 0x00;
    buffer[15] = 0x00;
    buffer[16] = 0x00;
    buffer[17] = 0x00;
    buffer[18] = 0x00;
    buffer[19] = 0x00;
    buffer[20] = 0x00;
    buffer[21] = 0x00;
    buffer[22] = 0x00;
    buffer[23] = 0x00;
    buffer[24] = 0x00;
    buffer[25] = 0x00;
    buffer[26] = 0x00;
    buffer[27] = 0x00;
    buffer[28] = 0x00;
    buffer[29] = 0xFFFFFFFC;*/
    // </editor-fold>
    FreeflyAPI.send(uart1_send);


    uart1_recv(&rxbyte,64);
    QX_StreamRxCharSM(QX_COMMS_PORT_UART, rxbyte);


    // <editor-fold defaultstate="collapsed" desc="Movi PRO API UART">

    if (send_flag_MoviAPI >= SEND_FREQ_MOVI_API)
    {
    send_flag_MoviAPI = 0;//reset the counter


    for((p = 0); (p < sizeof(UART_Tx_Buf[p])); p++){
    if(BufRemove(1, &UART_Tx_Buf[p]) == 0) break;

    uart1_send(UART_Tx_Buf,64);

    }

    }


    }//end of main loop
    return 0;

    Cheers,
    Chong Kwan Lok
     

Share This Page