GithubHelp home page GithubHelp logo

robotpy / robotpy-rev Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 13.0 230 KB

RobotPy bindings for REV Robotics' REVLib

License: Other

Python 98.21% C++ 1.79%
python robotpy frc robotpy-build motor-controller sensors rev-robotics

robotpy-rev's Introduction

robotpy-rev

This is a python wrapper around the REV Robotics REVLib. The RobotPy project is not associated with or endorsed by REV Robotics.

Documentation

License

RobotPy specific bits are available under a BSD-3-Clause license. The REV specific pieces are available under a BSD license.

Author

Dustin Spicuzza ([email protected])

robotpy-rev's People

Contributors

auscompgeek avatar crispybacon1999 avatar martinrioux avatar thetriplev avatar tyler-duckworth avatar virtuald avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

robotpy-rev's Issues

[BUG]: CANSparkMax references unknown base type, RobotPy 2024 Beta 3

Problem description

When running code in simulation using Robotpy 2024 Beta 3, any time CANSparkMax is imported, the code fails to run with error ImportError: generic_type: type "CANSparkMaxLowLevel" referenced unknown base type "frc::MotorController"
reported. Limiting the code to just this import line still gives the same error. This import statement still has no issue in 2023 RobotPy.

Screenshot 2023-11-13 135805

[NOTE: I'm not really a Python developer or experienced with Github, so I apologize if I'm using this bug reporting process wrong.]

Operating System

Windows

Installed Python Packages

asttokens                2.2.1
attrs                    22.2.0
backcall                 0.2.0
bcrypt                   4.0.1
CacheControl             0.12.11
certifi                  2023.5.7
cffi                     1.15.1
charset-normalizer       3.1.0
click                    8.1.3
cmake                    3.26.4
colorama                 0.4.6
comm                     0.1.3
contourpy                1.1.0
cryptography             40.0.1
cycler                   0.11.0
debugpy                  1.6.7
decorator                5.1.1
executing                1.2.0
fonttools                4.42.0
idna                     3.4
iniconfig                2.0.0
ipykernel                6.23.1
ipython                  8.13.2
jedi                     0.18.2
jupyter_client           8.2.0
jupyter_core             5.3.0
kiwisolver               1.4.4
matplotlib               3.7.2
matplotlib-inline        0.1.6
msgpack                  1.0.5
nest-asyncio             1.5.6
numpy                    1.24.3
opencv-python            4.7.0.72
packaging                23.0
paramiko                 3.1.0
parso                    0.8.3
phoenix6                 24.0.0b2
pickleshare              0.7.5
Pillow                   9.5.0
Pint                     0.20.1
pip                      23.3.1
platformdirs             3.5.1
pluggy                   1.0.0
prompt-toolkit           3.0.38
psutil                   5.9.5
pupil-apriltags          1.0.4.post10
pure-eval                0.2.2
pycparser                2.21
pyfrc                    2024.0.0b1
Pygments                 2.15.1
PyNaCl                   1.5.0
pynetconsole             2.0.4
pyntcore                 2024.0.0b3.post1
pyparsing                3.0.9
pypng                    0.20220715.0
pytest                   7.2.2
pytest-reraise           2.1.2
python-dateutil          2.8.2
pywin32                  306
pyzmq                    25.0.2
qrcode                   7.4.2
requests                 2.31.0
robotpy                  2024.0.0b3
robotpy-commands-v2      2024.0.0b3
robotpy-ctre             2024.0.0b1
robotpy-hal              2024.0.0b3.post1
robotpy-halsim-gui       2024.0.0b3.post1
robotpy-installer        2024.0.0b2
robotpy-navx             2023.0.3
robotpy-pathplannerlib   2023.3.4.1
robotpy-rev              2024.0.0b1
robotpy-wpilib-utilities 2024.0.0b1
robotpy-wpimath          2024.0.0b3.post1
robotpy-wpinet           2024.0.0b3.post1
robotpy-wpiutil          2024.0.0b3.post1
setuptools               68.0.0
six                      1.16.0
stack-data               0.6.2
statbotics               2.0.3
tbapy                    1.3.2
tornado                  6.3.2
traitlets                5.9.0
typing_extensions        4.5.0
urllib3                  2.0.2
wcwidth                  0.2.6
wheel                    0.40.0
wpilib                   2024.0.0b3.post1

Reproducible example code

from rev import CANSparkMax

Update to robotpy-rev 2020 not installing

The previous 2019 version of rev installs correctly and works but when I try to run pip install --upgrade robotpy-rev to upgrade to the 2020 release, it gives me a bunch of errors and refuses to install. First it says it is missing build requirements in pyproject.toml for robotpy-rev then trys to build wheels but fails, giving the final error message of: ERROR: Could not build wheels for robotpy-rev which use PEP 517 and cannot be installed directly I have attached a text document with all the error messages and would appreciate some help figuring out how to update the rev library on my computer.

errors.txt

[BUG]: Creating a brushed Spark Max aborts in sim

Problem description

Constructing a CANSparkMax with MotorType.kBrushed in simulation causes the robot code to exit with SIGABRT.

[CAN SPARK] IDs: 2, Parameter type mismatch for parameter id Getting Product ID parameter failed. Unable to account for device-specific behavior differences.


[CAN SPARK] IDs: 2, Error Invalid Cannot set motor type to kBrushed for SPARK without a dock connected.

libc++abi: terminating
fish: Job 1, 'python' terminated by signal SIGABRT (Abort)

Operating System

MacOS

Installed Python Packages

Package                  Version                               Editable project location
------------------------ ------------------------------------- ------------------------------------------------------
bcrypt                   4.1.2
beartype                 0.16.4
black                    23.12.1
cffi                     1.16.0
click                    8.1.7
cryptography             41.0.7
cxxheaderparser          1.3.0
delocate                 0.10.7
iniconfig                2.0.0
Jinja2                   3.1.2
MarkupSafe               2.1.3
mypy-extensions          1.0.0
overtake                 0.4.0
packaging                23.2
paramiko                 3.4.0
patch                    1.16
pathspec                 0.12.1
pcpp                     1.30
Pint                     0.23
pip                      23.3.2
platformdirs             4.1.0
pluggy                   1.3.0
pybind11-stubgen         2.3.7
pycparser                2.21
pydantic                 1.10.13
pyfrc                    2024.0.1
PyNaCl                   1.5.0
pynetconsole             2.0.4
pyntcore                 2024.1.1.0
pytest                   7.4.2
pytest-reraise           2.1.2
PyYAML                   6.0.1
robotpy                  2024.1.1
robotpy-build            2024.0.0                              /Users/davidv/dev/frc/robotpy/robotpy-build
robotpy-cli              2024.0.0
robotpy-commands-v2      2024.0.0b4                            /Users/davidv/dev/frc/robotpy/robotpy-commands-v2
robotpy-hal              2024.1.1.0
robotpy-halsim-gui       2024.1.1.0
robotpy-installer        2024.0.2
robotpy-rev              2024.0.0b1.post2.dev1+gba85a5563af7   /Users/davidv/dev/frc/robotpy/robotpy-rev
robotpy-wpilib-utilities 2024.0.1.dev0+g58dc9c8ff091.d20240107 /Users/davidv/dev/frc/robotpy/robotpy-wpilib-utilities
robotpy-wpimath          2024.1.1.0
robotpy-wpinet           2024.1.1.0
robotpy-wpiutil          2024.1.1.0
setuptools               68.1.2
setuptools-scm           7.1.0
sphinxify                0.11                                  /Users/davidv/dev/frc/robotpy/sphinxify
tomli                    2.0.1
tomli_w                  1.0.0
toposort                 1.10
typing_extensions        4.9.0
wheel                    0.42.0
wpilib                   2024.1.1.0

Reproducible example code

import rev
sm = rev.CANSparkMax(2, rev.CANSparkLowLevel.MotorType.kBrushed)

SIGSEGV on simulation exit

Happening in 2024.2.1, seen in CI. Really hard to reproduce locally, but I caught this:

(gdb) bt
#0  ___pthread_mutex_lock (mutex=0x7f5cac038) at pthread_mutex_lock.c:80
#1  0x00007f5cb569a7e0 in __gthread_mutex_lock (__mutex=0x7f5cac038)
    at /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:749
#2  std::mutex::lock (this=0x7f5cac038) at /usr/include/c++/11/bits/std_mutex.h:100
#3  std::scoped_lock<std::mutex>::scoped_lock (__m=..., this=<synthetic pointer>)
    at /usr/include/c++/11/mutex:655
#4  HAL_StopNotifier (notifierHandle=<optimized out>, status=<optimized out>)
    at /work/hal/src/main/native/sim/Notifier.cpp:200
#5  0x00007f5cb122f541 in (anonymous namespace)::HeartbeatDaemon::Main() ()
   from /home/virtuald/src/frc/robotpy-rev/rev/_rev.cpython-38-x86_64-linux-gnu.so
#6  0x00007f5cb5939c4b in operator() (__closure=0x5587df615988)
    at /work/wpiutil/src/main/native/cpp/SafeThread.cpp:79
#7  std::__invoke_impl<void, wpi::detail::SafeThreadOwnerBase::Start(std::shared_ptr<wpi::SafeThreadBase>)::<lambda()> > (__f=...) at /usr/include/c++/11/bits/invoke.h:61
#8  std::__invoke<wpi::detail::SafeThreadOwnerBase::Start(std::shared_ptr<wpi::SafeThreadBase>)::<lambda()> > (__fn=...) at /usr/include/c++/11/bits/invoke.h:96
#9  std::thread::_Invoker<std::tuple<wpi::detail::SafeThreadOwnerBase::Start(std::shared_ptr<wpi::SafeThreadBase>)::<lambda()> > >::_M_invoke<0> (this=0x5587df615988) at /usr/include/c++/11/bits/std_thread.h:259
#10 std::thread::_Invoker<std::tuple<wpi::detail::SafeThreadOwnerBase::Start(std::shared_ptr<wpi::SafeThreadBase>)::<lambda()> > >::operator() (this=0x5587df615988) at /usr/include/c++/11/bits/std_thread.h:266
#11 std::thread::_State_impl<std::thread::_Invoker<std::tuple<wpi::detail::SafeThreadOwnerBase::Start(std::shared_ptr<wpi::SafeThreadBase>)::<lambda()> > > >::_M_run(void) (this=0x5587df615980)
    at /usr/include/c++/11/bits/std_thread.h:211
#12 0x00007f5cb54e31e3 in std::execute_native_thread_routine (__p=0x5587df615980)
    at ../../../../../libstdc++-v3/src/c++11/thread.cc:104
#13 0x00007f5cc36ac897 in start_thread (arg=<optimized out>) at pthread_create.c:444
#14 0x00007f5cc373380c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

[BUG]: setFeedbackDevice doesn't work

Problem description

Sad.

Operating System

RoboRIO

Installed Python Packages

No response

Reproducible example code

>>> import rev
>>> s = rev.CANSparkMax(1, rev.CANSparkMaxLowLevel.MotorType.kBrushless)
>>> e = s.getEncoder()
>>> p = s.getPIDController()
>>> p.setFeedbackDevice(e)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: setFeedbackDevice(): incompatible function arguments. The following argument types are supported:
    1. (self: rev._rev.SparkMaxPIDController, sensor: rev._rev.CANSensor) -> rev._rev.REVLibError

Invoked with: <rev._rev.SparkMaxPIDController object at 0x10e266670>, <rev._rev.SparkMaxRelativeEncoder object at 0x10fdffd30>

[BUG]: Instantiating CANSparkMax raises a warning in sim

Problem description

Warning at CANSparkMax: Warning: CANSparkMax object created for CAN ID 1, which is not a SPARK MAX. Some functionalities may not work.
  File "/home/davo/dev/frc/thedropbears/pycrescendo/.venv/lib64/python3.12/site-packages/wpilib/_impl/start.py", line 247, in _start
    self.robot.startCompetition()

  File "/home/davo/dev/frc/thedropbears/pycrescendo/.venv/lib/python3.12/site-packages/magicbot/magicrobot.py", line 361, in startCompetition
    self.robotInit()

  File "/home/davo/dev/frc/thedropbears/pycrescendo/.venv/lib/python3.12/site-packages/magicbot/magicrobot.py", line 110, in robotInit
    self._create_components()

  File "/home/davo/dev/frc/thedropbears/pycrescendo/.venv/lib/python3.12/site-packages/magicbot/magicrobot.py", line 616, in _create_components
    component = self._create_component(m, ctyp, injectables)

  File "/home/davo/dev/frc/thedropbears/pycrescendo/.venv/lib/python3.12/site-packages/magicbot/magicrobot.py", line 687, in _create_component
    component = ctyp(**injections)

  File "/home/davo/dev/frc/thedropbears/pycrescendo/components/shooter.py", line 61, in __init__
    self.injector = CANSparkMax(

[CAN SPARK] IDs: 1, 2, 3, Parameter type mismatch for parameter id Getting Product ID parameter failed. Unable to account for device-specific behavior differences.

Operating System

Windows, MacOS, Linux

Installed Python Packages

╭──────────────────────────┬────────────┬──────────╮
│ name                     │ version    │ location │
├──────────────────────────┼────────────┼──────────┤
│ attrs                    │ 23.2.0     │          │
│ bcrypt                   │ 4.1.2      │          │
│ cffi                     │ 1.16.0     │          │
│ coverage                 │ 7.4.0      │          │
│ cryptography             │ 41.0.7     │          │
│ hypothesis               │ 6.97.4     │          │
│ iniconfig                │ 2.0.0      │          │
│ mypy                     │ 1.8.0      │          │
│ mypy-extensions          │ 1.0.0      │          │
│ numpy                    │ 1.26.3     │          │
│ packaging                │ 23.2       │          │
│ paramiko                 │ 3.4.0      │          │
│ phoenix6                 │ 24.1.0     │          │
│ photonlibpy              │ 2024.2.2   │          │
│ Pint                     │ 0.23       │          │
│ pip                      │ 23.2.1     │          │
│ pluggy                   │ 1.3.0      │          │
│ py                       │ 1.11.0     │          │
│ pycparser                │ 2.21       │          │
│ pyfrc                    │ 2024.0.1   │          │
│ PyNaCl                   │ 1.5.0      │          │
│ pynetconsole             │ 2.0.4      │          │
│ pyntcore                 │ 2024.2.1.2 │          │
│ pytest                   │ 8.0.0      │          │
│ pytest-forked            │ 1.6.0      │          │
│ pytest-reraise           │ 2.1.2      │          │
│ robotpy                  │ 2024.2.1.1 │          │
│ robotpy-apriltag         │ 2024.2.1.2 │          │
│ robotpy-cli              │ 2024.0.0   │          │
│ robotpy-ctre             │ 2024.1.1   │          │
│ robotpy-hal              │ 2024.2.1.2 │          │
│ robotpy-halsim-gui       │ 2024.2.1.2 │          │
│ robotpy-installer        │ 2024.1.3   │          │
│ robotpy-navx             │ 2024.1.0   │          │
│ robotpy-rev              │ 2024.2.0   │          │
│ robotpy-wpilib-utilities │ 2024.0.0   │          │
│ robotpy-wpimath          │ 2024.2.1.2 │          │
│ robotpy-wpinet           │ 2024.2.1.2 │          │
│ robotpy-wpiutil          │ 2024.2.1.2 │          │
│ setuptools               │ 69.0.3     │          │
│ sortedcontainers         │ 2.4.0      │          │
│ tomli                    │ 2.0.1      │          │
│ typing_extensions        │ 4.9.0      │          │
│ wpilib                   │ 2024.2.1.2 │          │
╰──────────────────────────┴────────────┴──────────╯

Reproducible example code

motor = rev.CANSparkMax(1, rev.CANSparkMax.MotorType.kBrushless)

[BUG]: __init__ doesn't include AbsoluteEncoder or SparkMaxAbsoluteEncoder

Problem description

We're working on porting the Java code from REV for their new swerve modules and noticed the Python bindings for revlib seem to lack the AbsoluteEncoder and SparkMaxAbsoluteEncoder that the swerve modules utilize.

dir(rev)
['AnalogInput', 'CANSensor', 'CANSparkMax', 'CANSparkMaxLowLevel', 'CIEColor', 'ColorMatch', 'ColorSensorV3', 'MotorFeedbackSensor', 'REVLibError', 'RelativeEncoder', 'SparkMaxAlternateEncoder', 'SparkMaxAnalogSensor', 'SparkMaxLimitSwitch', 'SparkMaxPIDController', 'SparkMaxRelativeEncoder', 'all', 'builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'path', 'spec', 'version', '_rev', 'version']
rev.version
'2023.1.2'

grepping around in the site-packages, it looks like the C++ code is there and it looks like it's in the rev._rev package -

import rev._rev
dir(rev._rev)
['AbsoluteEncoder', 'AnalogInput', 'CANSensor', 'CANSparkMax', 'CANSparkMaxLowLevel', 'CIEColor', 'ColorMatch', 'ColorSensorV3', 'MotorFeedbackSensor', 'REVLibError', 'RelativeEncoder', 'SparkMaxAbsoluteEncoder', 'SparkMaxAlternateEncoder', 'SparkMaxAnalogSensor', 'SparkMaxLimitSwitch', 'SparkMaxPIDController', 'SparkMaxRelativeEncoder', 'doc', 'file', 'loader', 'name', 'package', 'spec']

So, I think it's just missing from the rev init.py perhaps?

Thanks
-Brian

Operating System

Windows

Installed Python Packages

No response

Reproducible example code

No response

Fix setSmartCurrentLimit in simulation

The single-argument overload actually calls the 2-argument overload with a freeLimit of 0. Perhaps it might be better/simpler for us to just expose the 3-arg overload with freeLimit defaulting to 0.

Type stubs have bogus imports

rev/_rev/__init__.pyi begins with:

import rev._rev
import typing
import AnalogMode
import ArbFFUnits
import CANAnalog
import CANDigitalInput
import CANEncoder
import CANPIDController
import CANSparkMax
import CANSparkMaxLowLevel
import ControlType
import EncoderType
import wpilib._wpilib
import wpilib.interfaces._interfaces

The "imports" of all the classes should not be there, and breaks autocomplete/Intellisense.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.