robotpy / robotpy-ctre

RobotPy wrappers for CTRE Phoenix 5 library
Other
13 stars 21 forks source link

[BUG]: WPI_TalonSRX does not support canbus property #165

Closed trindels closed 1 year ago

trindels commented 1 year ago

Problem description

WPI_TalonSRX does not support providing the canbus property. This is needed for operating on a CANivore instead of the RoboRIO. The TalonSRX and BaseTalon support this property. WPI_TalonFX supports this property as well. Please update in order to propertly support compatibility.

self.motor = WPI_TalonSRX( 22, canbus="rio" )

Error Message:
__init__(): incompatible constructor arguments. The following argument types are supported:
    1. ctre._ctre.WPI_TalonSRX(deviceNumber: int)

Invoked with: 22; kwargs: canbus='rio'

Operating System

Windows, RoboRIO

Installed Python Packages

attrs                     22.2.0
bcrypt                    4.0.1
cffi                      1.15.1
click                     8.1.3
colorama                  0.4.6
coverage                  7.1.0
cryptography              39.0.1
iniconfig                 2.0.0
packaging                 23.0
paramiko                  3.0.0
Pint                      0.20.1
pip                       23.0
pluggy                    1.0.0
pycparser                 2.21
pyfrc                     2023.0.1
PyNaCl                    1.5.0
pynetconsole              2.0.4
pyntcore                  2023.4.1.1
pytest                    7.2.1
pytest-reraise            2.1.2
robotpy                   2023.4.1
robotpy-apriltag          2023.4.1.0
robotpy-commands-v2       2023.4.1.0
robotpy-cscore            2023.4.1.0
robotpy-ctre              2023.0.0
robotpy-hal               2023.4.1.0
robotpy-halsim-ds-socket  2023.4.1.0
robotpy-halsim-gui        2023.4.1.0
robotpy-halsim-ws         2023.4.1.0
robotpy-installer         2023.0.2
robotpy-navx              2023.0.3
robotpy-pathplannerlib    2023.3.4.1
robotpy-photonvision      2023.3.0
robotpy-playingwithfusion 2023.1.0
robotpy-rev               2023.1.3.2
robotpy-wpilib-utilities  2023.1.0
robotpy-wpimath           2023.4.1.0
robotpy-wpinet            2023.4.1.0
robotpy-wpiutil           2023.4.1.0
setuptools                65.5.0
wpilib                    2023.4.1.0

Reproducible example code

self.motor = WPI_TalonSRX( 1, "canivore1")
virtuald commented 1 year ago

The C++ version of the CTRE libraries do not support this for WPI_TalonSRX:

WPI_TalonSRX.h:

class WPI_TalonSRX : public virtual TalonSRX,
                     public virtual WPI_BaseMotorController
{
public:
    /**
     * Constructor for a WPI_TalonSRX
     * @param deviceNumber Device ID of TalonSRX
     */
    WPI_TalonSRX(int deviceNumber);
    virtual ~WPI_TalonSRX();

    WPI_TalonSRX() = delete;
    WPI_TalonSRX(WPI_TalonSRX const &) = delete;
    WPI_TalonSRX &operator=(WPI_TalonSRX const &) = delete;

As pointed out, TalonSRX does, but only not on roboRIO:

                class TalonSRX : public virtual BaseTalon
                {
                private:

                public:
                    /**
                     * Constructor for a Talon
                     * @param deviceNumber CAN Device ID of TalonSRX
                     */
                    TalonSRX(int deviceNumber);

#ifndef __FRC_ROBORIO__
                    /**
                     * Constructor so non-FRC platforms can specify a CAN 2.0 socketcan bus
                     * @param deviceNumber CAN Device ID of TalonSRX
                     * @param canbus String specifying the bus
                     */
                    TalonSRX(int deviceNumber, std::string const &canbus);
#endif

Unfortunately, that constructor isn't accessible in the child class WPI_TalonSRX. Please contact the vendor and have them fix their library.