robotpy / mostrobotpy

Official Repository of python implementation of WPILib components
https://robotpy.github.io
Other
11 stars 14 forks source link

Allow accessing AddressableLED.LEDData fields #77

Closed auscompgeek closed 9 months ago

auscompgeek commented 9 months ago

wpilib.AddressableLED.LEDData.setRGB is documented as:

A helper method to set all values of the LED.

But how do you set the individual values of the LED? In C++ you'd be able to set the r, g, and b members. However our bindings currently don't allow that, because we hide the fact that LEDData subclasses the hal.AddressableLEDData struct.

This makes those member variables visible via the base hal.AddressableLEDData.

auscompgeek commented 9 months ago

From the build log:

build/temp.linux-x86_64-cpython-311/gensrc/wpilib_core/AddressableLED.cpp:62:60: error: ‘HAL_AddressableLEDData’ is not a member of ‘frc’; did you mean ‘AddressableLED’?
   62 |     py::class_<typename frc::AddressableLED::LEDData, frc::HAL_AddressableLEDData> cls_LEDData;
      |                                                            ^~~~~~~~~~~~~~~~~~~~~~
      |                                                            AddressableLED

I don't understand why robotpy-build is prefixing the base type with the frc:: namespace.

virtuald commented 9 months ago

It's doing it because there's no namespace specified for the base, and the child lives in a namespace, so the odds are that the base is going to be in the same namespace.