Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 6 commits
  • 6 files changed
  • 0 commit comments
  • 2 contributors
@@ -70,16 +70,26 @@ your RoboRIO.
* Connect your RoboRIO to the internet
* SSH in, and copy the following to /etc/opkg/robotpy.conf::
- src/gz robotpy http://www.tortall.net/~robotpy/feeds/2014
+ src/gz robotpy http://www.tortall.net/~robotpy/feeds/2014
* Run this::
- opkg install python3
+ opkg install python3
* Then run this::
- pip3 install robotpy-hal-roborio wpilib
-
+ pip3 install pynivision robotpy-hal-roborio wpilib
+
+.. note:: When powered off, your RoboRIO does not keep track of the correct
+ date, and as a result pip may fail with an SSL related error message.
+ To set the date, you can either:
+
+ * Set the date via the web interface
+ * You can login to your roboRIO via SSH, and set the date via the
+ date command::
+
+ date -s "2015-01-03 00:00:00"
+
Upgrading requires you to run the same commands, but with the appropriate
flags set to tell pip3/opkg to upgrade the packages for you.
@@ -9,8 +9,6 @@ Now that you've created your first Python robot program, you probably want to kn
On the robot (using pyfrc)
--------------------------
-.. note:: pyfrc support for uploading to a RoboRIO is not complete yet, and will be working by the end of the weekend
-
The easiest way to install code on the robot is to use pyfrc.
1. Make sure you have RobotPy installed on the robot
@@ -40,7 +38,7 @@ If you don't have (or don't want) to install pyfrc, running code manually is pre
Your driver station should be able to connect to your code, and it will be able to operate your robot!
-.. note:: This is good for running experimental code, but it won't start the code when the robot starts up. In the future we'll add notes on how to properly do this.
+.. note:: This is good for running experimental code, but it won't start the code when the robot starts up. Use pyfrc to do that.
On your computer
@@ -16,7 +16,7 @@ def robotInit(self):
camera = wpilib.USBCamera()
camera.setExposureManual(50)
camera.setBrightness(80)
- camera.updateSetting() # force update before we start thread
+ camera.updateSettings() # force update before we start thread
server = wpilib.CameraServer.getInstance()
server.startAutomaticCapture(camera)
@@ -22,8 +22,16 @@ def _STATUSFUNC(name, restype, *params, out=None, library=_dll,
handle_missing=False):
realparams = list(params)
realparams.append(("status", C.POINTER(C.c_int32)))
+ if restype is not None and out is not None:
+ outindexes = [i for i, p in enumerate(params) if p[0] in out]
+ def errcheck(rv, f, args):
+ out = [rv]
+ out.extend(args[i].value for i in outindexes)
+ return tuple(out)
+ else:
+ errcheck = None
_inner = _RETFUNC(name, restype, *realparams, out=out, library=library,
- handle_missing=handle_missing)
+ errcheck=errcheck, handle_missing=handle_missing)
def outer(*args, **kwargs):
status = C.c_int32(0)
rv = _inner(*args, status=status, **kwargs)
@@ -22,6 +22,17 @@ external packages, so use them at your own risk.
the RobotPy installer to install packages, then you can easily
reinstall them on your robot in the case you need to reimage it.
+ If you choose to install packages manually via pip, keep in mind that
+ when powered off, your RoboRIO does not keep track of the correct
+ date, and as a result pip may fail with an SSL related error message.
+ To set the date, you can either:
+
+ * Set the date via the web interface
+ * You can login to your roboRIO via SSH, and set the date via the
+ date command::
+
+ date -s "2015-01-03 00:00:00"
+
Each of the commands supports various options, which you can read about by
invoking the --help command.
@@ -17,7 +17,7 @@ class CameraServer:
kSize320x240 = 1
kSize160x120 = 2
kHardwareCompression = -1
- kMaxImageSize = 20000
+ kMaxImageSize = 200000
intStruct = struct.Struct("!i")
@@ -114,11 +114,11 @@ def startAutomaticCapture(self, camera):
self.camera = camera
self.camera.startCapture()
- self.captureThread = threading.Thread(target=lambda: self._autoCapture(cameraName), name="CaptureThread")
+ self.captureThread = threading.Thread(target=self._autoCapture, name="CaptureThread")
self.captureThread.daemon = True
self.captureThread.start()
- def _autoCapture(self, name):
+ def _autoCapture(self):
frame = nivision.imaqCreateImage(nivision.IMAQ_IMAGE_RGB, 0)
while True:
@@ -127,12 +127,18 @@ def _autoCapture(self, name):
if hwClient:
data = self.dataPool[-1]
self.dataPool.pop()
- if hwClient:
- size = self.camera.getImageData(data, self.kMaxImageSize)
- self._setImageData(data, size)
- else:
- self.camera.getImage(frame)
- self.setImage(frame)
+ try:
+ if hwClient:
+ size = self.camera.getImageData(data, self.kMaxImageSize)
+ self._setImageData(data, size)
+ else:
+ self.camera.getImage(frame)
+ self.setImage(frame)
+ except (ValueError, IndexError):
+ logger.exception("getting image")
+ if hwClient and not self.ready.is_set():
+ self.dataPool.append(data)
+ time.sleep(0.1)
def isAutoCaptureStarted(self):
"""check if auto capture is started

No commit comments for this range