[CLOSED] Logging setpoint (roll, pitch, yaw, thrust) using ROS and high-level commander mode

Firmware/software/electronics/mechanics
Post Reply
mouhyemen
Beginner
Posts: 13
Joined: Sun Feb 02, 2020 5:24 pm

[CLOSED] Logging setpoint (roll, pitch, yaw, thrust) using ROS and high-level commander mode

Post by mouhyemen »

I am interested in logging the setpoints that the underlying controller tracks.

My current understanding is the following:
  • Whether one uses high-level mode or low-level mode, the setpoint is always computed for the underlying controller to track using control.
If my understanding above is right, please confirm.

If so, I am using the high-level commander mode (using crazyflie_ros), to takeOff, goTo, land etc. I am interested in seeing what setpoints are generated that the underlying controller is tracking.

For doing so, I added the following in the firmware:

Code: Select all

LOG_GROUP_START(stabilizer)

LOG_ADD(LOG_FLOAT, roll, &state.attitude.roll)
LOG_ADD(LOG_FLOAT, pitch, &state.attitude.pitch)
LOG_ADD(LOG_FLOAT, yaw, &state.attitude.yaw)
LOG_ADD(LOG_FLOAT, thrust, &control.thrust)

LOG_ADD(LOG_FLOAT, rollSetpoint, &setpoint.attitude.roll)
LOG_ADD(LOG_FLOAT, pitchSetpoint, &setpoint.attitude.pitch)
LOG_ADD(LOG_FLOAT, yawSetpoint, &setpoint.attitude.yaw)
LOG_ADD(LOG_FLOAT, thrustSetpoint, &setpoint.thrust)

LOG_GROUP_STOP(stabilizer)
When I log (rollSetpoint, pitchSetpoint, yawSetpoint, thrustSetpoint), I get the following plot:
cf_hover_setpoint_plotjuggler.png
The roll/pitch/yawSetpoints are shown in bottom-left plot and thrustSetpoint is shown in bottom-right plot.

The thrustSetpoint is zero. Why would that be? Shouldn't it be around 30000-45000 thrust units? What log should I pulling to see non-zero thrust?
The roll/pitchSetpoints are zero. That is also strange, because I tell the drone to go forward, hence a non-zero pitch setpoint should be induced for enabling forward flight.

I am ultimately interested in logging the setpoint (roll/pitch/yaw/thrust) that the drone is acting upon.
Last edited by mouhyemen on Fri Sep 04, 2020 4:22 pm, edited 1 time in total.
kristoffer
Bitcraze
Posts: 322
Joined: Tue Jun 30, 2015 7:47 am

Re: Logging setpoint (roll, pitch, yaw, thrust) using ROS and high-level commander mode

Post by kristoffer »

Hi!

I think you have a fairly correct view of how the set point is handled. A clarification might be that when not using the high level commander, the set point essentially is transferred directly from a client to the controller. When a set point arrives on the CRTP protocol, it is written to the setpointQueue, the first line of the commanderGetSetpoint() function then copies the queue entry to the setpoint struct.

The set point struct may be slightly confusing, it is very generic and designed to work in many scenarios. The thing is that all members of the struct do not always contain data, it depends on what the set point is used for. If you fly the crazyflie manually from a game pad, thrust will be filled in, but in your case it is not.
The set point is passed on to the the controller that outputs a control struct (control_t type), containing the actual roll/pitch/yaw/thrust used to control the motors in the powerDistribution() function. You will find the thrust you are looking for there, it is also logged in the stabilizer.thrust log variable.

BTW The logs for roll, pitch and yaw set points are already defined in the ctrltarget log group.
mouhyemen
Beginner
Posts: 13
Joined: Sun Feb 02, 2020 5:24 pm

Re: [CLOSED] Logging setpoint (roll, pitch, yaw, thrust) using ROS and high-level commander mode

Post by mouhyemen »

Thanks for the explanation. I am able to log the desired roll/pitch/yaw/thrust values now.

I am closing the topic.
Post Reply