[Question] Collision Prevention Behavior under Strong Headwind

I’m currently studying the acceleration-based Collision Prevention (CP) logic in v1.16+ and I have a question regarding its behavior in a specific, but what seems to be a realistic, scenario. I’ve tried to trace the logic in the code, and I would be grateful if you could clarify whether my understanding is correct or if perhaps I’m missing a key part of the implementation.


The Scenario

  1. The vehicle is operating in Position Mode under a strong, constant headwind.

  2. To hold its position, the position controller is commanding a significant and continuous forward pitch (e.g., 10-15 degrees), effectively thrusting against the wind to maintain a ground speed of zero.

  3. An obstacle appears in front of the vehicle, triggering the Collision Prevention module.


My Understanding of the Logic

Based on my reading of CollisionPrevention.cpp, it appears the following sequence of events might occur:

  1. The position controller, while fighting the headwind, maintains a non-zero internal velocity setpoint (setpoint_vel) in the forward direction. This setpoint represents the necessary “effort” to counteract the wind.

  2. When CP is triggered, _getVelocityCompensationAcceleration is called. It seems this function would use the internal forward setpoint_vel as the curr_vel_parallel component directed towards the obstacle.

  3. The function then calculates a necessary braking acceleration (curr_acc_vel_constraint) in the opposite (rearward) direction. My interpretation is that this is intended to reduce the forward velocity component to zero to prevent a collision.

    C++

    curr_acc_vel_constraint = _param_mpc_xy_vel_p_acc.get() * math::min(max_vel - curr_vel_parallel, 0.f);
    
    
  4. This braking acceleration is then added to the final setpoint_accel sent to the attitude controller.

    C++

    setpoint_accel = constr_accel_setpoint + vel_comp_accel * vel_comp_accel_dir;
    
    
  5. To execute a command that now contains a significant rearward acceleration component, it seems the attitude controller would have no choice but to reduce the forward pitch, leveling the vehicle out.

  6. Once the forward pitch is reduced, the force counteracting the headwind is lost, which could cause the vehicle to drift backward.


Request for Clarification

This leads to my main question:

Does the current “Velocity Compensation” logic have a way to differentiate between a user’s explicit command to move forward and the position controller’s internal velocity setpoint that is generated solely to counteract external forces like wind?

From my perspective, it appears the logic might treat both situations similarly. If my understanding is correct, while collision is successfully prevented, the vehicle might fail to hold its position.

I would greatly appreciate it if you could let me know if this interpretation of the logic is accurate, or if there’s a different mechanism at play that I’ve overlooked.