View Single Post
  #7   Spotlight this post!  
Unread 04-03-2016, 02:56
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 269
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
Re: Analog Gyro .getAngle() function occasionally giving massive random values

Quote:
Originally Posted by Maxwell777 View Post
Thanks! I'll try that out. I figured that .getAngle() was thread safe because it returned a primitive type and I didn't think that there was anything too crazy running in the background. Do you know if any other common wpilib stuff that isn't thread safe? I might start going around and locking everything I can lol
Generally speaking, it should be thread-safe except for setup-type functions. E.g. it's not safe to call gyro calibrate() in a separate thread from gyro getAngle(). That said, most robot code doesn't use threads outside of PIDController so there are probably other places where locking may have been missed.
__________________
Author of cscore - WPILib CameraServer for 2017+
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)