RobotPy segmentation fault

We just started trying to use the command based framework with Robtpy. Everything seems to run fine in the simulator, and it even says deploy successful, but we end up with no robot code. NetConsole says “Fatal Python error: turn goal Segmentation fault”. Here’s the full output:

Connecting to 10.41.69.2:1741...OK
07:58:17:007 INFO    : deploy              : Netconsole is listening...
[8.39] 07:58:23:322 INFO    : wpilib              : WPILib version 2022.3.1.1
[8.39] 07:58:23:323 INFO    : wpilib              : HAL version 2022.3.1.0
[8.39] 07:58:23:326 INFO    : wpilib              : robotpy-cscore version 2022.0.3
[8.40] 07:58:23:327 INFO    : wpilib              : robotpy-wpiutil version 2022.3.1.2
[8.40] 07:58:23:327 INFO    : wpilib              : robotpy-wpimath version 2022.3.1.1
[8.40] 07:58:23:328 INFO    : wpilib              : robotpy-rev version 2022.0.1
[8.40] 07:58:23:329 INFO    : wpilib              : robotpy-navx version 2022.0.1
[8.40] 07:58:23:330 INFO    : wpilib              : robotpy-ctre version 2022.1.0
[8.40] 07:58:23:331 INFO    : wpilib              : robotpy-commands-v2 version 2022.3.1.1
[8.40] 07:58:23:332 INFO    : wpilib              : pyntcore version 2022.3.1.0
[8.40] 07:58:23:334 INFO    : faulthandler        : registered SIGUSR2 for PID 4525
[8.42] Camera Server Library Not Found
[8.47] Instantiating navX-Sensor on I2C Port 1.
[8.47] navX-Sensor C++ library for FRC
[8.47] Instantiating navX-Sensor on Serial Port 2.
[8.47] navX-Sensor C++ library for FRC
[8.47] Opening USB  serial port to communicate with navX-MXP/Micro.
[8.52] distance goal -3
[8.52] turn goal 0
[8.52] distance goal 0
[8.52] turn goal 90
[8.52] distance goal -3
[8.52] turn goal 90
[8.52] distance goal 0
[8.52] turn goal 180
[8.52] distance goal -3
[8.53] turn goal 180
[8.53] distance goal 0
[8.53] Fatal Python error: turn goal Segmentation fault
[8.53]
[8.53] 270Thread 0xb2e07470
[8.53]  (most recent call first):
[8.53]   File distance goal"/usr/local/lib/python3.10/site-packages/_pyntcore/_logutil.py", line 60 in _logging_thread
[8.53]   File "/usr/local/lib/python3.10/threading.py" , line 946-3 in run
[8.53]
[8.53]   File turn goal"/usr/local/lib/python3.10/threading.py" , line 1009270 in _bootstrap_inner
[8.53]
[8.54]   File "/usr/local/lib/python3.10/threading.py", line 966distance goal in _bootstrap
[8.54]
[8.54] Thread 0x b6ef7210 (most recent call first):
[8.54] 0  File "/home/lvuser/py/commands/movecommand.py
[8.54] "turn goal, line 14 in  __init__
[8.54] 360  File "/home/lvuser/py/commands/complexauto.py
[8.54] ", line distance goal27 in __init__
[8.54]   File "/home/lvuser/py/robotcontainer.py", line 65 in __init__
[8.54]   File "/home/lvuser/py/robot.py", line 81 in robotInit
[8.54]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py", line  131 in _start-3.6666667
[8.54]   File "
[8.55] /usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py"turn goal, line 65 in  start
[8.55] 0  File "
[8.55] /usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py", line 61distance goal in run
[8.55]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py", line 19  in run
[8.55] 0  File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/main.py
[8.55] ", line turn goal193 in run
[8.56] 65
[8.56] distance goal -0.75
[8.56] turn goal 65
[8.56] distance goal 0.75
[8.56] turn goal 65
[8.56] distance goal 0
[8.56] turn goal -130
[8.56] distance goal -6.42
[8.56] turn goal -130
[8.56] distance goal 0
[8.56] turn goal 50
[8.56] distance goal -6.42
[8.56] turn goal 50
[8.56] distance goal 0
[8.56] turn goal 67.5
[8.56] distance goal -1
[8.56] turn goal 67.5
[8.56]   File "/home/lvuser/py/robot.py", line 249 in <module>
[14.47] 07:58:29:404 INFO    : wpilib              : WPILib version 2022.3.1.1
[14.47] 07:58:29:407 INFO    : wpilib              : HAL version 2022.3.1.0
[14.48] 07:58:29:409 INFO    : wpilib              : robotpy-cscore version 2022.0.3
[14.48] 07:58:29:410 INFO    : wpilib              : robotpy-wpiutil version 2022.3.1.2
[14.48] 07:58:29:411 INFO    : wpilib              : robotpy-wpimath version 2022.3.1.1
[14.48] 07:58:29:411 INFO    : wpilib              : robotpy-rev version 2022.0.1
[14.48] 07:58:29:415 INFO    : wpilib              : robotpy-navx version 2022.0.1
[14.48] 07:58:29:415 INFO    : wpilib              : robotpy-ctre version 2022.1.0
[14.48] 07:58:29:417 INFO    : wpilib              : robotpy-commands-v2 version 2022.3.1.1
[14.48] 07:58:29:417 INFO    : wpilib              : pyntcore version 2022.3.1.0
[14.49] 07:58:29:420 INFO    : faulthandler        : registered SIGUSR2 for PID 4682
[14.50] Camera Server Library Not Found
[14.55] Instantiating navX-Sensor on I2C Port 1.
[14.55] navX-Sensor C++ library for FRC
[14.56] Instantiating navX-Sensor on Serial Port 2.
[14.56] navX-Sensor C++ library for FRC
[14.56] Opening USB  serial port to communicate with navX-MXP/Micro.
[14.60] distance goal -3
[14.60] turn goal 0
[14.61] distance goal 0
[14.61] turn goal 90
[14.61] distance goal -3
[14.61] turn goal 90
[14.61] distance goal 0
[14.61] turn goal 180
[14.61] distance goal -3
[14.61] turn goal 180
[14.61] distance goal 0
[14.61] turn goal 270
[14.62] distance goal -3
[14.62] turn goal 270
[14.62] Fatal Python error: Segmentation fault
[14.62]
[14.62] Thread 0xb2ee6470 (most recent call first):
[14.62]   File "/usr/local/lib/python3.10/site-packages/_pyntcore/_logutil.py", line 60 in _logging_thread
[14.62]   File distance goal" /usr/local/lib/python3.10/threading.py0"
[14.62] , line turn goal946  in 360run
[14.63]
[14.63]   File "/usr/local/lib/python3.10/threading.py", line 1009 in _bootstrap_inner
[14.63]   File "/usr/local/lib/python3.10/threading.py", line 966 in _bootstrap
[14.63]
[14.63] Thread 0xb6fd8210 (most recent call first):
[14.63]   File "/home/lvuser/py/commands/complexauto.py", line 17 in __init__
[14.63]   File "/home/lvuser/py/robotcontainer.py", line 62 in __init__
[14.63]   File "/home/lvuser/py/robot.py", line 81 in robotInit
[14.63]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py", line 131 in _start
[14.63]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py", line 65 in start
[14.63]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py", line 61 in run
[14.63]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py", line 19 in run
[14.63]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/main.py", line 193 in run
[14.63]   File "/home/lvuser/py/robot.py", line 249 in <module>
[14.63] distance goal -3.6666667
[14.63] turn goal 0
[14.63] distance goal 0
[14.63] turn goal 65
[14.63] distance goal -0.75
[14.63] turn goal 65
[14.63] distance goal 0.75
[14.63] turn goal 65
[20.60] 07:58:35:528 INFO    : wpilib              : WPILib version 2022.3.1.1
[20.60] 07:58:35:530 INFO    : wpilib              : HAL version 2022.3.1.0
[20.60] 07:58:35:532 INFO    : wpilib              : robotpy-cscore version 2022.0.3
[20.60] 07:58:35:532 INFO    : wpilib              : robotpy-wpiutil version 2022.3.1.2
[20.60] 07:58:35:533 INFO    : wpilib              : robotpy-wpimath version 2022.3.1.1
[20.60] 07:58:35:533 INFO    : wpilib              : robotpy-rev version 2022.0.1
[20.60] 07:58:35:534 INFO    : wpilib              : robotpy-navx version 2022.0.1
[20.60] 07:58:35:535 INFO    : wpilib              : robotpy-ctre version 2022.1.0
[20.60] 07:58:35:535 INFO    : wpilib              : robotpy-commands-v2 version 2022.3.1.1
[20.60] 07:58:35:536 INFO    : wpilib              : pyntcore version 2022.3.1.0
[20.61] 07:58:35:537 INFO    : faulthandler        : registered SIGUSR2 for PID 4839
[20.62] Camera Server Library Not Found
[20.67] Instantiating navX-Sensor on I2C Port 1.
[20.67] navX-Sensor C++ library for FRC
[20.67] Instantiating navX-Sensor on Serial Port 2.
[20.67] navX-Sensor C++ library for FRC
[20.67] Opening USB  serial port to communicate with navX-MXP/Micro.
[20.72] Fatal Python error: Segmentation fault
[20.72]
[20.72] distance goal -3
[20.72] turn goal 0
[20.72] distance goal 0
[20.72] turn goal 90
[20.72] distance goal -3
[20.72] turn goal 90
[20.72] distance goal 0
[20.72] turn goal 180
[20.72] distance goal -3
[20.73] turn goal 180
[20.73] distance goal 0
[20.73] turn goal 270
[20.73] distance goal -3
[20.73] turn goal 270
[20.73] distance goal 0
[20.73] turn goal 360
[20.74] distance goal -3.6666667
[20.74] turn goal 0
[20.74] distance goal 0
[20.74] turn goal 65
[20.74] distance goal -0.75
[20.75] turn goal 65
[20.75] distance goal 0.75
[20.75] turn goal 65
[20.75] distance goal 0
[20.75] turn goal -130
[20.75] distance goal -6.42
[20.76] turn goal -130
[20.76] distance goal 0
[20.76] turn goal 50
[20.77] distance goal -6.42
[20.77] turn goal 50
[20.77] distance goal 0
[20.77] turn goal 67.5
[20.77] distance goal -1
[20.77] turn goal 67.5
[20.77] distance goal 1
[20.77] turn goal 67.5
[20.77] distance goal -3.6666667
[20.77] turn goal 0
[20.77] distance goal 0
[20.77] turn goal -65
[20.77] distance goal -0.75
[20.77] turn goal -65
[20.77] distance goal 0.75
[20.77] turn goal -65
[20.77] distance goal 0
[20.77] turn goal 130
[20.77] distance goal -6.42
[20.77] turn goal 130
[20.77] distance goal 0
[20.77] turn goal -50
[20.77] distance goal -6.42
[20.77] turn goal -50
[20.77] distance goal 0
[20.77] turn goal -67.5
[20.77] distance goal -1
[20.77] turn goal -67.5
[20.77] distance goal 1
[20.78] turn goal -67.5
[20.78] distance goal -3.75
[20.78] turn goal 0
[20.78] distance goal 0
[20.78] turn goal 180
[20.78] distance goal -7
[20.78] turn goal 180
[20.78] distance goal 0
[20.78] turn goal 220
[20.78] distance goal -1
[20.78] turn goal 220
[20.78] distance goal 1
[20.78] turn goal 220
[20.78] distance goal -3.75
[20.78] turn goal 0
[20.78] Thread 0xb2e2e470 (most recent call first):
[20.78]   File "/usr/local/lib/python3.10/site-packages/_pyntcore/_logutil.py", line 60distance goal 0
[20.78] turn goal -180
[20.79] distance goal -7
[20.79] turn goal -180
[20.79] distance goal 0
[20.79] turn goal -220
[20.79] distance goal -1
[20.79] turn goal -220
[20.79] distance goal 1
[20.79] turn goal -220
[20.79]  in _logging_thread
[20.79]   File "/usr/local/lib/python3.10/threading.py", line 946 in run
[20.79]   File "/usr/local/lib/python3.10/threading.py", line 1009 in _bootstrap_inner
[20.79]   File "/usr/local/lib/python3.10/threading.py", line 966 in _bootstrap
[20.79]
[20.79] Thread 0xb6f1d210 (most recent call first):
[20.79]
[20.79] ********** Robot program startup complete **********
[20.79]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py", line 131 in _start
[20.79]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py"D, line efault DisabledPeriodic() method... Override me!
[20.79] 65 in start
[20.79]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py", line 61 in run
[20.80]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py", line 19 in run
[20.80]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/main.py", line 193 in run
[20.80]   File "/home/lvuser/py/robot.py", line 249 in <module>
[-0.00] 07:58:41:584 INFO    : wpilib              : WPILib version 2022.3.1.1
[0.00] 07:58:41:585 INFO    : wpilib              : HAL version 2022.3.1.0
[0.01] 07:58:41:591 INFO    : wpilib              : robotpy-cscore version 2022.0.3
[0.01] 07:58:41:592 INFO    : wpilib              : robotpy-wpiutil version 2022.3.1.2
[0.01] 07:58:41:593 INFO    : wpilib              : robotpy-wpimath version 2022.3.1.1
[0.01] 07:58:41:594 INFO    : wpilib              : robotpy-rev version 2022.0.1
[0.01] 07:58:41:595 INFO    : wpilib              : robotpy-navx version 2022.0.1
[0.01] 07:58:41:596 INFO    : wpilib              : robotpy-ctre version 2022.1.0
[0.01] 07:58:41:597 INFO    : wpilib              : robotpy-commands-v2 version 2022.3.1.1
[0.01] 07:58:41:598 INFO    : wpilib              : pyntcore version 2022.3.1.0
[0.01] 07:58:41:600 INFO    : faulthandler        : registered SIGUSR2 for PID 4997
[0.03] Camera Server Library Not Found
[0.08] Instantiating navX-Sensor on I2C Port 1.
[0.08] navX-Sensor C++ library for FRC
[0.09] Instantiating navX-Sensor on Serial Port 2.
[0.09] navX-Sensor C++ library for FRC
[0.09] Opening USB  serial port to communicate with navX-MXP/Micro.
[0.13] distance goal -3
[0.14] turn goal 0
[0.14] distance goal 0
[0.14] turn goal 90
[0.14] distance goal -3
[0.14] turn goal 90
[0.14] distance goal 0
[0.14] turn goal 180
[0.14] distance goal -3
[0.15] turn goal 180
[0.15] distance goal 0
[0.15] turn goal 270
[0.15] distance goal -3
[0.15] turn goal 270
[0.15] distance goal 0
[0.15] turn goal 360
[0.15] distance goal -3.6666667
[0.15] turn goal 0
[0.15] distance goal 0
[0.15] turn goalFatal Python error:  Segmentation fault65
[0.15]
[0.15]
[0.15] Thread 0xdistance goalb2e4d470  (most recent call first):
[0.15] -0.75  File
[0.15] "turn goal/usr/local/lib/python3.10/site-packages/_pyntcore/_logutil.py "65, line
[0.15] 60distance goal in _logging_thread
[0.15]   File "/usr/local/lib/python3.10/threading.py", line 946 in run
[0.15]   File "/usr/local/lib/python3.10/threading.py", line 1009 in _bootstrap_inner
[0.15]   File "/usr/local/lib/python3.10/threading.py", line 966 in _bootstrap
[0.15]
[0.16] Thread 0xb6f50210 (most recent call first):
[0.16]   File "/home/lvuser/py/commands/movecommand.py", line 13 in __init__
[0.16]   File "/home/lvuser/py/commands/lucautocommand.py", line 26 in __init__
[0.16]   File "/home/lvuser/py/robotcontainer.py", line 65 in __init__
[0.16]   File "/home/lvuser/py/robot.py", line 81 in robotInit
[0.16]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py", line 131 in _start
[0.16]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py", line 65 in start
[0.16]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py", line 61 in run
[0.16]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py", line 19 in run
[0.16]   File "/usr/local/lib/python3.10/site-packages/wpilib/_impl/main.py", line 193 in run
[0.16]   File "/home/lvuser/py/robot.py", line 249 in <module>
[0.16]  0.75
[0.16] turn goal 65
[0.16] distance goal 0
[0.16] turn goal -130
[0.16] distance goal -6.42
[0.16] turn goal -130
[6.11] 07:58:47:693 INFO    : wpilib              : WPILib version 2022.3.1.1
[6.11] 07:58:47:695 INFO    : wpilib              : HAL version 2022.3.1.0
[6.11] 07:58:47:696 INFO    : wpilib              : robotpy-cscore version 2022.0.3
[6.12] 07:58:47:697 INFO    : wpilib              : robotpy-wpiutil version 2022.3.1.2
[6.12] 07:58:47:704 INFO    : wpilib              : robotpy-wpimath version 2022.3.1.1
[6.12] 07:58:47:705 INFO    : wpilib              : robotpy-rev version 2022.0.1
[6.12] 07:58:47:705 INFO    : wpilib              : robotpy-navx version 2022.0.1
[6.12] 07:58:47:706 INFO    : wpilib              : robotpy-ctre version 2022.1.0
[6.12] 07:58:47:707 INFO    : wpilib              : robotpy-commands-v2 version 2022.3.1.1
[6.12] 07:58:47:708 INFO    : wpilib              : pyntcore version 2022.3.1.0
[6.12] 07:58:47:710 INFO    : faulthandler        : registered SIGUSR2 for PID 5154
[6.14] Camera Server Library Not Found
[6.19] Instantiating navX-Sensor on I2C Port 1.
[6.19] navX-Sensor C++ library for FRC
[6.19] Instantiating navX-Sensor on Serial Port 2.
[6.20] navX-Sensor C++ library for FRC
[6.20] Opening USB  serial port to communicate with navX-MXP/Micro.
[6.24] distance goal -3
[6.25] turn goal 0
[6.25] distance goal 0
[6.25] turn goal 90
[6.25] distance goal -3
[6.25] turn goal 90
[6.26] distance goal 0
[6.26] turn goal 180
[6.26] Fatal Python error: Segmentation fault
[6.26]
[6.26] distance goalThread 0xb2ead470 (most recent call first):
[6.27]   File " /usr/local/lib/python3.10/site-packages/_pyntcore/_logutil.py", line -360 in
[6.27] _logging_thread
[6.28] turn goal  File "/usr/local/lib/python3.10/threading.py ", line 946 in 180run
[6.28]
[6.28]   File "/usr/local/lib/python3.10/threading.pydistance goal", line 1009 in _bootstrap_inner
[6.28]   File "/usr/local/lib/python3.10/threading.py" , line 9660 in _bootstrap
[6.28]
[6.28]
[6.29] turn goalThread 0xb6fb0210 (most recent call first):
[6.29]   File  "/home/lvuser/py/commands/movecommand.py270", line
[6.29] 14 in distance goal__init__
[6.29]   File "/home/lvuser/py/commands/complexauto.py", line 26 in __init__
[6.29]    File "/home/lvuser/py/robotcontainer.py-3", line 62
[6.29]  in __init__
[6.29]   File "turn goal/home/lvuser/py/robot.py" , line 81270 in robotInit
[6.30]
[6.30]   File distance goal"/usr/local/lib/python3.10/site-packages/wpilib/_impl/start.py", line 131 in _start
[6.30]   File "/usr/local/

XXXXXXI’m also unsure what “turn goal” and “distance goal” are. My firth thought was that we were printing it somewhere, but I can’t find it in the code at all, and we’re unable to enable the robot, so I don’t think we’d be able to print anything. Has anyone seen this before?XXXXXXX

Edit: I found those print statments berried in MoveCommand

We tried initalizing MyRobot as both wpilib.TimedRobot and commands2.TimedCommandRobot. We’re using command based for auto and time based for teleop.

Here’s our current versions of everything:

1 Like

The code seems to be crashing in a bunch of your command __init__s. Without your code though, I can only guess as to why. It looks like something else is printing all those distance goal and turn goal messages too - possibly outside of Python, as they’re getting interleaved with Python’s stack traces.

There’s one run at [20.60] 07:58:35 which doesn’t seem to crash in your Python code at all though… in fact it got as far as calling the TimedRobot default disabledPeriodic…

I think I see it crashing in:

  • commands/movecommand.py line 14
  • commands/complexauto.py line 17
  • ???
  • commands/movecommand.py line 13
  • commands/movecommand.py line 14

I notice your RobotPy installation is slightly outdated. WPILib 2022.4.1 was released recently, with a corresponding RobotPy release following. Does it still segfault after updating?

Also, would you be able to provide the full list of installed packages on your robot, using the following command, please?

robotpy-installer list

Oh, I forgot to leave my guess in that post too, although that third run seems odd and I’m not sure would be explained by my guess:

Is the superclass __init__ being called in your __init__ methods? Upgrade Notes — RobotPy 2021 documentation

Our code can be found here. The print statements are coming from commands/movecommand.py

We had movecommand.py working on our test robot last week, so I’m inclined to think it’s not a version issue, but we will upgrade later today in case.

Unfortunately, I haven’t been able to duplicate your issue in simulation. Your code doesn’t have anything that looks obviously wrong to me.

One thing that sticks out as weird to me – do you actually have two NavX on your robot? You create one in the drivesubsystem and one in robot.py, using two different ports. If you don’t actually have two NavX connected, definitely start by fixing that (it looks like you aren’t using the one in robot.py), as it’s possible the vendor code isn’t written to expect two devices, especially if one isn’t there.

I don’t have time to try it on my RoboRIO this morning, but I can give it a shot tonight. It seems likely that it’s either a RobotPy wrapping error or an issue in a vendor library. Here’s my recommendations for diagnosing it:

  • See above about NavX
  • First, definitely upgrade everything and try again. While I’m not aware of any issues that have been fixed recently, this is always my first recommendation.
    • FIRST is requiring image 2022v4.0 for competition, and it’s possible there are issues with wpilib < 2022.4.1 regarding that change
  • Re-image your RoboRIO, reinstall robotpy, try again
  • Comment out all of those print statements and see if you can get a more consistent crash message
  • Finally, it’s really good that this happens consistently. Recommend that you start commenting out commands and devices until the bug goes away, and comes back when you uncomment a specific thing. If you can identify the thing that is breaking, it’s likely that I’ll be able to identify why it’s breaking.

Funny you mention that. I was unaware that we defined the navx twice. When we ran the first test this morning, the navx was not plugged in. Later today I mounted and plugged in the navx, and tried deploying again, and the error and issues went away. I have not yet removed the second navx definition, but will definitely do that.

Thanks for the help!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.