robotpy / mostrobotpy

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

SendableRegistry Add/AddLW/AddChild are broken #83

Open virtuald opened 9 months ago

virtuald commented 9 months ago

They are trying to use keep alives to keep the pointers alive but it's not the right solution.

Probably need to do the same thing we do for SmartDashboard with a separate hash map to hold references.

import wpilib
import wpilib.drive
import wpiutil

leftLeader = wpilib.PWMSparkMax(1)
rightLeader = wpilib.PWMSparkMax(2)
drive = wpilib.drive.DifferentialDrive(
            leftLeader,
            rightLeader,
        )

wpiutil.SendableRegistry.addChild(drive, leftLeader)
$ python ../../t.py 
Traceback (most recent call last):
  File "../../t.py", in <module>
    wpiutil.SendableRegistry.addChild(drive, leftLeader)
RuntimeError: Could not activate keep_alive!