A class for grabbing frames from the camera. In order to grab frames, you need to install Opencv, and python-opencv (Python bindings for the computer vision library).
This class was tested with Opencv 2.0.0 and Ubuntu 10.04 LTS.
High-level interface to the Player client libraries.
The Player client libraries allow Python code to communicate with hardware devices such as robots, cameras, and range sensors.
This is a temporary home for this file until it finds a permanent home (maybe in the PlayerStage project or in PLASTK?)
Bases: topo.hardware.playerrobot.PlayerDevice
A Player camera device.
The synchronized method get_image grabs an uncompressed snapshot, along with the additional formatting information needed to make an image.
Where data is a copy of the uncompressed image data.
Where data is a copy of the uncompressed image data.
Bases: topo.hardware.playerrobot.PlayerDevice
Player Pan/Tilt/Zoom (PTZ) device.
Adds the following to the original proxy interface:
state = The tuple (pan,tilt,zoom) indicating the current state of the PTZ device.
state_deg = Same as state, but returns values in degrees instead of radians
set_deg() and set_ws_deg() methods. Same as .set() and .set_ws(), using degrees instead of radians.
Bases: topo.hardware.playerrobot.PlayerObject
Player object wrapper for playerc.client objects.
Bases: topo.hardware.playerrobot.PlayerObject
Generic Player device object.
Overrides the default proxy .subscribe method so that the mode defaults to PLAYERC_OPEN_MODE.
Bases: object
A generic threadsafe wrapper for client and proxy objects from the playerc library.
PlayerObject wrappers are constructed automatically by PlayerRobot objects. Each PlayerObject instance wraps a playerc device proxy or client object, and publishes a thread-safe version of each of proxy’s methods, that is synchronized with the PlayerRobot instance’s run-loop thread, and that catches playerc error conditions and raises them as PlayerExceptions. The original playerc proxy object is available via the attribute .proxy. Specialized subclasses of PlayerObject can have additional interfaces for getting device state or setting commands specific to that device.
Developer note: the PlayerObject base class __init__ method automatically wraps each method on the proxy that (a) doesn’t begin with ‘__’ and (b) is not already in dir(self). This way, subclasses can override the wrapping process by defining their own wrappers before the base class __init__ method is called.
Bases: object
Player Robot interface.
A PlayerRobot instance encapsulates an interface to a Player robot. It creates and manages a playerc.client object and a set of device proxies wrapped in PlayerDevice objects. In addition, it maintains a run-loop in a separate thread that calls the client’s .read() method at regular intervals. The devices are published through standard interfaces on the PlayerRobot instance, and their methods and properties are synchronized with the run thread through a mutex.
Example:
# set up a robot object with position, laser, and camera objects robot = PlayerRobot(host=’myrobot.mydomain.edu’,port=6665,
- devices = [(‘position2d’,0),
- (‘laser’,0), (‘camera’,1)])
# start the run thread, devices will be subscribed # automatically. robot.start()
# start the robot turning at 30 deg/sec robot.position2d[0].set_cmd_vel(0, 0, 30*pi/180)
# wait for a while time.sleep(5.0)
# all stop robot.position2d[0].set_cmd_vel(0,0,0)
# shut down the robot’s thread, unsubscribing all devices and # disconnecting the client robot.stop()
Player function decorator. Adds error checking.
Takes an operator and a value, and compares the result of the function call with the value using the operator. If the result is true, a PlayerException is raised. The default error condition is error_op = ne, error_value = 0, which raises an exception if fn(*args) != 0.
Synchronized method decorator.
Like synchronized() decorator, except synched_method assumes that the first argument of the function is an instance containing a Lock object, and this lock is used for synchronization.
Simple synchronization decorator.
Takes an existing lock and synchronizes a function or method on that lock. Code taken from the Python Wiki PythonDecoratorLibrary:
A class for controlling pan/tilt and pan/tilt reset of a camera. In order to move the camera, you need to install UVCDYNCTRL, it is a Logitech software for webcam.
This class was tested with uvcdynctrl and Ubuntu 10.04 LTS.
Classes for using robotic or other hardware using Topographica.
This module contains several classes for constructing robotics interfaces to Topographica simulations. It includes modules that read input from or send output to robot devices, and a (quasi) real-time simulation object that attempts to maintain a correspondence between simulation time and real time.
This module requires the PlayerStage robot interface system (from playerstage.sourceforge.net), and the playerrobot module for high-level communications with Player robots.
Bases: imagen.image.GenericImage
An image pattern generator that gets its image from a Player camera device.
duration: The temporal duration to animate in the units defined on the global time function.
offset: The temporal offset from which the animation is generated given the supplied pattern
timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.
label: A label string to override the label of the global time function (if not None).
unit: The unit string to override the unit value of the global time function (if not None).
time_fn: The global time function object that is shared across the time-varying objects that are being sampled.
Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.
Restore the state of the output functions saved by state_push.
Save the state of the output functions, to be restored with state_pop.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.hardware.robotics.CameraImage
A version of CameraImage that gets the image from the camera’s image queue, rather than directly from the camera object. Using queues is necessary when running the playerrobot in a separate process without shared memory. When getting an image, this pattern generator will fetch every image in the image queue and use the most recent as the current pattern.
duration: The temporal duration to animate in the units defined on the global time function.
offset: The temporal offset from which the animation is generated given the supplied pattern
timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.
label: A label string to override the label of the global time function (if not None).
unit: The unit string to override the unit value of the global time function (if not None).
time_fn: The global time function object that is shared across the time-varying objects that are being sampled.
Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.
Restore the state of the output functions saved by state_push.
Save the state of the output functions, to be restored with state_pop.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.simulation.EventProcessor
Pan/Tilt/Zoom control.
This event processor takes input events on its ‘Saccade’ input port in the form of (amplitude,direction) saccade commands (as produced by the topo.sheet.saccade.SaccadeController class) and appropriately servoes the attached PTZ object. There is not currently any dynamic zoom control, though the static zoom level can be set as a parameter.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Called by the simulation before advancing the simulation time. Allows the event processor to do any computation that requires that all events for this time have been delivered. Computations performed in this method should not generate any events with a zero time delay, or else causality could be violated. (By default, does nothing.)
Generate a runnable command for creating this EventProcessor.
Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.