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 »

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: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Accessing the commander port values

Post by arnaud »

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 »

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: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Accessing the commander port values

Post by arnaud »

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 »

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