How to customize response CRTPpackets?

Firmware/software/electronics/mechanics
Post Reply
CrazyGuy
Beginner
Posts: 27
Joined: Fri May 02, 2014 6:03 pm

How to customize response CRTPpackets?

Post 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?
        }
    }
}
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: How to customize response CRTPpackets?

Post 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)
CrazyGuy
Beginner
Posts: 27
Joined: Fri May 02, 2014 6:03 pm

Re: How to customize response CRTPpackets?

Post 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
molatokarlo
Beginner
Posts: 6
Joined: Fri Jan 22, 2016 4:49 am

Re: How to customize response CRTPpackets?

Post by molatokarlo »

Hello Sir,

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

Thank you so much.
derf
Expert
Posts: 163
Joined: Fri May 31, 2013 12:17 am
Location: Germany

Re: How to customize response CRTPpackets?

Post 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.
Post Reply