Page 1 of 1

How to customize response CRTPpackets?

Posted: Fri Oct 09, 2015 5:50 pm
by CrazyGuy
Hi,

I want to calculate the motorratios on the client. Therefor I have to get the gyro data and euler-angles. Ideally I send the motorratios to the crazyflie and the response (I think there is one?) contains the data I'm interested in. But I'm not sure where I have to make the adjustments. So can you pls tell me if my understanding of the communication is right? Or tell me how to customize the response if I'm totally wrong... :)

crtpRxTask manages the received packets. "link->receivePacket" fetches a new packet. I don't really know what "if(queues[p.port]" checks!? But if it is successfull the packet gets pushed in the send-queue? So before this instruction I have to check if p.port equals 3 (= commands port) and if necessary update the packet with my data?

Thanks for any hints :)
crazyguy

Code: Select all

void crtpRxTask(void *param)
{
    CRTPPacket p;
    static unsigned int droppedPacket=0;

    while (TRUE)
    {
        if (!link->receivePacket(&p))
        {
            if(queues[p.port])
            {
                // TODO: If full, remove one packet and then send
                xQueueSend(queues[p.port], &p, 0);
            }
            else
            {
                droppedPacket++;
            }

            if(callbacks[p.port])
                callbacks[p.port](&p);  //Dangerous?
        }
    }
}

Re: How to customize response CRTPpackets?

Posted: Tue Oct 13, 2015 10:31 am
by arnaud
Hi,

To get the angles from the copter you can use the Log subsystem, it has been designed for this kind of task. You can setup one log packet with all the data you are interested into and it will be sent by the copter.

The code you copied is the low level of CRTP and you should not have to touch it, instead you can register for a new port and setup a callback or listen to the queue.

For example the commander is setting up a callback: https://github.com/bitcraze/crazyflie-f ... nder.c#L72

For your usage one option is to add a test for the packet channel in the commander and send the ratios as a commander packet on channel 1(https://wiki.bitcraze.io/doc:crazyflie:crtp:index)

Re: How to customize response CRTPpackets?

Posted: Tue Oct 13, 2015 3:06 pm
by CrazyGuy
Hi,

thanks for the reply.

I've already used the logging system but for some reasons my regulator doesn't work. At the moment I think, that the logged data are not "up to date". See also my other thread: viewtopic.php?f=6&t=1708

I'll try the suggestion with the callbacks.

Thanks,
crazyguy

Re: How to customize response CRTPpackets?

Posted: Fri Jan 22, 2016 5:12 am
by molatokarlo
Hello Sir,

Can you please help me on how to get the Gyro data?

Thank you so much.

Re: How to customize response CRTPpackets?

Posted: Fri Jan 22, 2016 12:42 pm
by derf
As Arnaud already wrote:
To get the angles from the copter you can use the Log subsystem, it has been designed for this kind of task. You can setup one log packet with all the data you are interested into and it will be sent by the copter.