Accessing the commander port values

Firmware/software/electronics/mechanics
Post Reply
SqareOfOne
Beginner
Posts: 3
Joined: Wed Nov 07, 2018 12:10 pm

Accessing the commander port values

Post by SqareOfOne » Wed Nov 07, 2018 12:48 pm

We are a group of electronics students trying to create our own on-board controller for the crazyflie.

By using CrazyflieDotNet we are able to send our own values to the copter using the commander port. We have found ways to access the motors and the gyro, implementing our own controller function in power_distribution_stock.c.

However we cannot figure out how to access the commander port values within the firmware.

We tried looking at CommanderRpytDecodeSetpoint in crtp_commander_rpyt.c, since it seem to create the struct we need, but can't seem to figure out how to use it.

The function seem to have existed in an old firmware verison, but i lost track of the exact forum post.

arnaud
Bitcraze
Posts: 1790
Joined: Tue Feb 06, 2007 12:36 pm

Re: Accessing the commander port values

Post by arnaud » Thu Nov 08, 2018 6:34 am

I am not entirely sure I understand your question but I guess what you are after is the stabilizer look? The commander will fill-up a setpoint structure and this structure is made available to the stabilizer loop so that the setpoint can be passed to the controller: https://github.com/bitcraze/crazyflie-f ... zer.c#L181.

SqareOfOne
Beginner
Posts: 3
Joined: Wed Nov 07, 2018 12:10 pm

Re: Accessing the commander port values

Post by SqareOfOne » Thu Nov 08, 2018 10:41 am

Hi Arnaud.
Thanks that is exactly what we were looking for :D
By using setpoint.attitude.roll and setpoint.attitude.pitch, we get two values clean through.
Although we don't seem to get the right values through for thrust and yaw. Are these modified internally somewhere?

arnaud
Bitcraze
Posts: 1790
Joined: Tue Feb 06, 2007 12:36 pm

Re: Accessing the commander port values

Post by arnaud » Fri Nov 09, 2018 7:02 am

Depending of what packet you are sending they are decoded in different places. If you are sending an rpyt packet it is decoded and put in the structure in crtp_commander_rpyt.c. Note that for yaw at least the value will be in setpoint.attitudeRate.yaw and the thrust is between 0 an 65535.

SqareOfOne
Beginner
Posts: 3
Joined: Wed Nov 07, 2018 12:10 pm

Re: Accessing the commander port values

Post by SqareOfOne » Wed Nov 14, 2018 2:22 pm

Thank you very much. We solved it by replacing most of CommanderRpytDecodeSetpoint with a simpler version :)

Post Reply