tborg.examples package¶
tborg.examples.mborg_approxeng¶
- class tborg.examples.mborg_approxeng.JoyStickControl(bus_num=1, address=21, borg=True, log_level=20, voltage_in=12, debug=False)[source]¶
Bases:
DaemonThe ApproxEng.input library is used to control the Thunder Borg.
- _BASE_LOGGER_NAME = 'examples'¶
- _LOGGER_NAME = 'examples.mborg-approxeng'¶
- _LOG_PATH = '/home/docs/borg_cube/logs/mborg_approxeng.log'¶
- _MAX_VOLTAGE_MULT = 1.145¶
- _PIDFILE = '/home/docs/borg_cube/run/mborg_approxeng.pid'¶
- _ROTATE_TURN_SPEED = 0.5¶
- _SLOW_SPEED = 0.5¶
- _TBORG_LOGGER_NAME = 'examples.tborg'¶
- _VOLTAGE_IN = 12¶
- _VOLTAGE_OUT = 11.399999999999999¶
- property fwd_rev_invert¶
- property max_power¶
- property quit¶
- property quit_hold_time¶
- property turn_invert¶
tborg.examples.mborg_pygame¶
- class tborg.examples.mborg_pygame.JoyStickControl(bus_num=1, address=21, log_level=20, debug=False)[source]¶
Bases:
PYGameController,DaemonThis class allows control of the MonsterBorg by a PS3/4 controller.
- _BASE_LOGGER_NAME = 'examples'¶
- _CTRL_LOGGER_NAME = 'examples.controller'¶
- _LOGGER_NAME = 'examples.mborg-pygame'¶
- _LOG_PATH = '/home/docs/borg_cube/logs/mborg_pygame.log'¶
- _MAX_POWER = 0.9499999999999998¶
- _PIDFILE = '/home/docs/borg_cube/run/mborg_pygame.pid'¶
- _PROCESS_INTERVAL = 0.0¶
- _ROTATE_TURN_SPEED = 0.5¶
- _SLOW_SPEED = 0.5¶
- _TBORG_LOGGER_NAME = 'examples.tborg'¶
- _VOLTAGE_IN = 12.0¶
- _VOLTAGE_OUT = 11.399999999999999¶
- set_defaults(**kwargs)[source]¶
Set some default values. This method can be set while running. For example if the robot flips over which could be determined with a sensor the axis invert values can be changed.
- Parameters:
axis_y_invert (bool) – If set to True the up/down control is inverted. Default is False. Can be used if the robot flips over.
axis_x_invert (bool) – If set to True the left/right control is inverted. Default is False. Can be used if the robot flips over.
rotate_turn_button (int) – Choose the button for rotation. The default is R1 (5).
rotate_turn_speed (float) – Choose the speed for rotation. The default is 0.5.
drive_slow_button – Choose the button for driving slow. The default is R2 (6).
drive_slow_speed (bool) – Choose the speed to decrease to when the drive-slow button is held.
- class tborg.examples.mborg_pygame.PYGameController(logger_name='', log_level=20, debug=False)[source]¶
Bases:
objectInitializes the attached controller.
- _DEFAULT_CTRL_WAIT = 0.1¶
- _DEFAULT_EVENT_WAIT = 0.0¶
- __METHODS = {256: <function PYGameController.set_quit>, 1536: <function PYGameController.__set_axis>, 1537: <function PYGameController.__set_ball>, 1538: <function PYGameController.__set_hat>, 1539: <function PYGameController.__set_button_down>, 1540: <function PYGameController.__set_button_up>}¶
- __set_axis(event)¶
- __set_ball(event)¶
- __set_button_down(event)¶
- __set_button_up(event)¶
- __set_hat(event)¶
- property ctrl_wait_time¶
Property that gets or sets the controller wait time. This wait time is used when looping during the controller detection period.
- Parameters:
sleep (float) – The period of time to sleep between checks. Defaults to 0.1 seconds.
- property event_wait_time¶
Property that gets or sets the event wait time. This wait time is used when looping during the event processing period.
- Parameters:
sleep (float) – The period of time to sleep between event processing. Defaults to 0.0 seconds.
- property is_ctrl_init¶
A property that returns True or False if the controller is initialized.
tborg.examples.web¶
- class tborg.examples.web.monster_web.ImageCapture(camera, processor, running, log_name, *args, **kwargs)[source]¶
Bases:
ThreadImage capture thread
- run()[source]¶
Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
- class tborg.examples.web.monster_web.MonsterWeb(options, port=9000, address=21, log_level=20, *args, **kwargs)[source]¶
Bases:
Daemon- FLIPPED_CAMERA = True¶
bool: Swap between True and False if the camera image is rotated by 180.
- FRAME_RATE = 20¶
int: Number of images to capture per second
- IMAGE_HEIGHT = 192¶
int: Height of the captured image in pixels
- IMAGE_WIDTH = 240¶
int: Width of the captured image in pixels
- JPEG_QUALITY = 80¶
int: JPEG quality level, smaller is faster, higher looks better (0 to 100)
- LAST_FRAME = None¶
- LOCK_FRAME = <unlocked _thread.lock object>¶
- MAX_POWER = 0¶
- _BASE_LOGGER_NAME = 'examples'¶
- _LOGGER_NAME = 'examples.monster_web'¶
- _LOG_PATH = '/home/docs/borg_cube/logs/monster_web.log'¶
- _PIDFILE = '/home/docs/borg_cube/run/monster_web.pid'¶
- _TBORG_LOGGER_NAME = 'examples.tborg'¶
- run()[source]¶
You should override this method when you subclass Daemon. It will be called after the process has been daemonized by start() or restart().
- Parameters:
args (tuple) – Any positional arguments to pass to the user’s run method.
kwargs (dict) – Any keyword arguments to pass to the user’s run method.
- class tborg.examples.web.monster_web.StreamProcessor(global_data, *args, **kwargs)[source]¶
Bases:
ThreadImage stream processing thread
- run()[source]¶
Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
- class tborg.examples.web.monster_web.ThreadingTCPServer(server_address, RequestHandlerClass, bind_and_activate=True)[source]¶
Bases:
ThreadingMixIn,TCPServer- allow_reuse_address = True¶
- daemon_threads = True¶
- class tborg.examples.web.monster_web.Watchdog(tb, log_name, *args, **kwargs)[source]¶
Bases:
ThreadTimeout thread
- run()[source]¶
Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.