“How to get both distance and angle from Portenta UWB Shield/Stella Setup in TWR

I’m working with a Portenta C33 UWB shield and Stella UWB.
I'm using the PortentaUWBShield and StellaUWB libraries.
The default examples (UWB_RangingControlee and UWB_Tracker) give me distance using TWR.
I found AoA structs in uwb_types.hpp, but when I try to access angleOfArrival, I get a compile error:
'class UWBRangingData' has no member named 'extraAoaPdoaMeasure'.

Has anyone successfully retrieved both distance and angle (AoA) in the same sketch?
Do I need to run two sessions (TWR + OWR_AOA), or is there a combined mode available in the current library? Please help.

you might be interested in reading this discussion

I found the solution to my own question on how to get both distance and angle (AoA) using the Portenta UWB Shield and Stella setup in TWR mode, so sharing it here in case it helps others.

I used the PortentaUWBShield and StellaUWB libraries.

For the Portenta side, open:
File → Examples → PortentaUWBShield → UWB_RangingControlee.ino

For the Stella side, open:
File → Examples → StellaUWB → UWB_Tracker.ino

Keep the example code unchanged except for the rangingHandler() function.
Replace the existing rangingHandler() in both examples with the following:

void rangingHandler(UWBRangingData &rangingData) {

Serial.print("GOT RANGING DATA - Type: ");
Serial.println(rangingData.measureType());

if(rangingData.measureType() == (uint8_t)uwb::MeasurementType::TWO_WAY)
{
RangingMeasures twr = rangingData.twoWayRangingMeasure();

for(int j = 0; j < rangingData.available(); j++)
{
  if(twr[j].status == 0 && twr[j].distance != 0xFFFF)
  {
    // -------- Distance --------
    Serial.print("Distance: ");
    Serial.println(twr[j].distance);

    // -------- Azimuth --------
    float azimuth = twr[j].aoa_azimuth / 128.0;
    Serial.print("Azimuth (deg): ");
    Serial.println(azimuth);

    // -------- Elevation --------
    float elevation = twr[j].aoa_elevation / 128.0;
    Serial.print("Elevation (deg): ");
    Serial.println(elevation);

    // -------- Quality --------
    Serial.print("Azimuth FOM: ");
    Serial.println(twr[j].aoa_azimuth_fom);

    Serial.println("-----------------------------");
  }
}

}
}

aoa_azimuth and aoa_elevation are already available inside the TWR measurement structure. These values are stored in Q9.7 fixed-point format, so they must be divided by 128.0 to convert them into degrees. The azimuth FOM (Figure of Merit) indicates the quality or reliability of the angle measurement. After uploading the modified code to both boards and opening the Serial Monitor at 115200 baud(Try in Portenta ), you will be able to see distance, azimuth angle, elevation, and FOM values. So basically, the angle information is already provided by the library, and we only need to read and print those fields inside the rangingHandler() function. Hope this helps anyone working with Portenta UWB Shield and Stella UWB in TWR mode.

Thankyou

Thanks for sharing back

And also for the above setup

From the same setup, I am now able to read and print the azimuth angle successfully. However, I am still trying to understand the exact meaning and functionality of this angle. Could someone explain what this azimuth angle represents physically — i.e., with respect to which board’s orientation (Stella or Portenta) the angle is measured, and how it should be interpreted in the setup?

It would be helpful if someone could explain this in detail.