robotpy / examples

Repository of RobotPy example projects
45 stars 53 forks source link

The example code doesn't work. #16

Closed adam-mcdaniel closed 6 years ago

adam-mcdaniel commented 6 years ago

Ive been trying to get pathfinder working on my robot for about an hour. When I ran the physics-pathfinder example, I got this error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\wpilib\robotbase.py", line 168, in main
    robot.startCompetition()
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\wpilib\timedrobot.py", line 68, in startCompetition
    self.loopFunc()
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\wpilib\iterativerobotbase.py", line 164, in loopFunc
    self.autonomousPeriodic()
  File "robot.py", line 89, in autonomousPeriodic
    l = self.leftFollower.calculate(self.l_encoder.get())
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\pathfinder\followers.py", line 154, in calculate
    return pathfinder_follow_encoder2(self.cfg, self, self.trajectory[self.segment], tlen, encoder_tick)
IndexError: list index out of range
virtuald commented 6 years ago

Well... it works for me? Do you have all of your robotpy pieces up to date? What does the output of py -3 -m pip list output for you?

virtuald commented 6 years ago

It appears to work fine on OSX/Linux, but I was able to reproduce the error you experienced on Windows. The wheel that we pushed to pypi does not seem to work as expected (perhaps a pybind11 bug?), and the segment variable doesn't seem to get initialized in Windows for some reason. Adding the following code right after the configurePIDVA statement fixes it:

leftFollower.segment = 0
rightFollower.segment = 0

I'll push a fix to pathfinder at some point, but for now that should get you going.

virtuald commented 6 years ago

Fixed in robotpy-pathfinder 0.2.4

virtuald commented 6 years ago

Actually, 0.2.5