source: remote_control/puzzlebox_brainstorms_configuration.py @ 108

Last change on this file since 108 was 108, checked in by sc, 11 years ago

remote_control/puzzlebox_brainstorms_network_client.py:

  • voltage display fix

remote_control/puzzlebox_brainstorms_configuration:

  • system based defaults for NXT Bluetooth device

remote_control/puzzlebox_brainstorms_client_interface.py:

  • user define NXT Bluetooth device support added

remote_control/puzzlebox_brainstorms_network_server.py:

  • user define NXT Bluetooth device support fixed
File size: 8.2 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Puzzlebox - Brainstorms - Configuration
5#
6# Copyright Puzzlebox Productions, LLC (2010)
7#
8# This code is released under the GNU Pulic License (GPL) version 2
9# For more information please refer to http://www.gnu.org/copyleft/gpl.html
10#
11# Last Update: 2010.07.10
12#
13#####################################################################
14
15import os, sys
16import pygame
17
18#####################################################################
19# General configuration
20#####################################################################
21
22DEBUG = 1
23
24BRAINSTORMS_CONFIGURATION_FILE_PATH = 'puzzlebox_brainstorms_configuration.ini'
25
26#####################################################################
27# Logging
28#####################################################################
29
30LOG_LEVEL_DEBUG = 2
31LOG_LEVEL_INFO = 1
32LOG_LEVEL_ERROR = 0
33LOG_LEVEL_DISABLE = -1
34
35DEFAULT_LOG_LEVEL = LOG_LEVEL_DEBUG
36DEFAULT_LOGFILE = 'brainstorms'
37
38LOGFILE_DIR = '/var/log/puzzlebox'
39LOGFILE_SUFFIX = '.log'
40LOGFILE_SUFFIX_DEBUG = '_debug.log'
41LOGFILE_SUFFIX_INFO = '_info.log'
42LOGFILE_SUFFIX_ERROR = '_error.log'
43
44SPLIT_LOGFILES = False
45
46
47#####################################################################
48# Network addresses
49#####################################################################
50
51BRAINSTORMS_SERVER_INTERFACE = '' # listen on all of server's network interfaces
52BRAINSTORMS_SERVER_HOST = '127.0.0.1' # localhost
53BRAINSTORMS_SERVER_PORT = 8194
54
55THINKGEAR_SERVER_INTERFACE = '' # listen on all of server's network interfaces
56THINKGEAR_SERVER_HOST = '127.0.0.1'
57THINKGEAR_SERVER_PORT = 13854
58
59
60#####################################################################
61# Remote Control configuration
62#####################################################################
63
64# Discrete control drives the robot for a set time period per detection.
65# Setting Variable control to "True" will drive the robot in a
66# particular direction for as long as the detection occurs
67VARIABLE_CONTROL_DURATION = True
68
69DEFAULT_NXT_POWER_LEVEL = 80
70
71DEFAULT_NXT_BLUETOOTH_DEVICE_WINDOWS = 'COM1'
72DEFAULT_NXT_BLUETOOTH_DEVICE_LINUX = '/dev/rfcomm0'
73
74if (sys.platform == 'win32'):
75        NXT_BLUETOOTH_DEVICE = DEFAULT_NXT_BLUETOOTH_DEVICE_WINDOWS
76else:
77        NXT_BLUETOOTH_DEVICE = DEFAULT_NXT_BLUETOOTH_DEVICE_LINUX
78
79NXT_MOTORS_MOUNTED_BACKWARDS = True
80NXT_MOTOR_PORT_RIGHT = 'a'
81NXT_MOTOR_PORT_LEFT = 'b'
82NXT_DEFAULT_RC_COMMAND = 'test_drive'
83
84
85#####################################################################
86# Server configuration
87#####################################################################
88
89BRAINSTORMS_DELIMITER = '\r'
90
91TWISTED_SERVER_MAX_COMPONENTS = 16
92
93
94#####################################################################
95# Client configuration
96#####################################################################
97
98CLIENT_NO_REPLY_WAIT = 5 # how many seconds before considering a component dead
99
100TWISTED_CLIENT_MAX_CONNECTION_ATTEMPTS = 5
101
102
103#####################################################################
104# ThinkGear Connect configuration
105#####################################################################
106
107THINKGEAR_DELIMITER = '\r'
108
109THINKGEAR_CONFIGURATION_PARAMETERS = {"enableRawOutput": False, "format": "Json"}
110
111THINKGEAR_AUTHORIZATION_ENABLED = False
112
113THINKGEAR_AUTHORIZATION_REQUEST = { \
114        "appName": "Puzzlebox Brainstorms", \
115        "appKey": "2e285d7bd5565c0ea73e7e265c73f0691d932408"
116}
117
118
119#####################################################################
120# ThinkGear Connect Server Emulator configuration
121#####################################################################
122
123THINKGEAR_ENABLE_SIMULATE_HEADSET_DATA = True
124
125THINKGEAR_BLINK_FREQUENCY_TIMER = 6 # blink every 6 seconds
126                                    # (6 seconds is listed by Wikipedia
127                                    # as being the average number of times
128                                    # an adult blinks in a laboratory setting)
129
130THINKGEAR_DEFAULT_SAMPLE_WAVELENGTH = 30 # number of seconds from 0 to max
131                                         # and back to 0 for any given
132                                         # detection value below
133
134
135#####################################################################
136# Client Interface configuration [Qt]
137#####################################################################
138
139THINKGEAR_POWER_THRESHOLDS = { \
140       
141        'concentration': { \
142                0: 0, \
143                10: 0, \
144                20: 0, \
145                30: 0, \
146                40: 60, \
147                50: 65, \
148                60: 70, \
149                70: 75, \
150                75: 80, \
151                80: 85, \
152                90: 90, \
153                100: 90, \
154                }, \
155       
156        'relaxation': { \
157                0: 0, \
158                10: 0, \
159                20: 0, \
160                30: 0, \
161                40: 0, \
162                50: 10, \
163                60: 10, \
164                70: 15, \
165                80: 15, \
166                90: 20, \
167                100: 20, \
168                }, \
169       
170} # THINKGEAR_POWER_THRESHOLDS
171
172
173#####################################################################
174# Client Interface configuration [Pygame]
175#####################################################################
176
177CLIENT_PYGAME_DISPLAY_WINDOW_X_COORDINATE = 0
178CLIENT_PYGAME_DISPLAY_WINDOW_Y_COORDINATE = 0
179CLIENT_PYGAME_DISPLAY_WINDOW_X_DIMENSION = 254
180CLIENT_PYGAME_DISPLAY_WINDOW_Y_DIMENSION = 424
181
182#CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (255,255,255) # white background
183#CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (128,128,128) # grey background
184#CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (64,64,64)    # dark grek background
185CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (0,0,0)       # black background
186
187CLIENT_PYGAME_IMAGE_DIRECTORY = os.path.join(os.getcwd(), 'images')
188
189# Keyboard key reference at http://www.pygame.org/docs/ref/key.html#pygame.key
190CLIENT_PYGAME_BUTTON_LAYOUT = { \
191       
192        'left': { \
193                'command': 'turn_left', \
194                'active': False, \
195                'button_image': '1-upper_left-white.png', \
196                'activated_image': '1-upper_left-orange.png', \
197                'image_x': 0, \
198                'image_y': 0, \
199                'match_keys': [pygame.K_LEFT, pygame.K_a, pygame.K_q]
200                }, \
201       
202        'forward': { \
203                'command': 'drive_forward', \
204                'active': False, \
205                'button_image': '2-up-white.png', \
206                'activated_image': '2-up-orange.png', \
207                'image_x': 98, \
208                'image_y': 0, \
209                'match_keys': [pygame.K_UP, pygame.K_w]
210                }, \
211       
212        'right': { \
213                'command': 'turn_right', \
214                'active': False, \
215                'button_image': '3-upper_right-white.png', \
216                'activated_image': '3-upper_right-orange.png', \
217                'image_x': 157, \
218                'image_y': 0, \
219                'match_keys': [pygame.K_RIGHT, pygame.K_d, pygame.K_e]
220                }, \
221       
222        'reverse_left': { \
223                'command': 'turn_left_in_reverse', \
224                'active': False, \
225                'button_image': '7-lower_left-white.png', \
226                'activated_image': '7-lower_left-orange.png', \
227                'image_x': 0, \
228                'image_y': 220, \
229                'match_keys': [pygame.K_z]
230                }, \
231       
232        'reverse': { \
233                'command': 'drive_reverse', \
234                'active': False, \
235                'button_image': '8-down-white.png', \
236                'activated_image': '8-down-orange.png', \
237                'image_x': 98, \
238                'image_y': 220, \
239                'match_keys': [pygame.K_DOWN, pygame.K_s, pygame.K_x]
240                }, \
241       
242        'reverse_right': { \
243                'command': 'turn_right_in_reverse', \
244                'active': False, \
245                'button_image': '9-lower_right-white.png', \
246                'activated_image': '9-lower_right-orange.png', \
247                'image_x': 157, \
248                'image_y': 220, \
249                'match_keys': [pygame.K_PAGEDOWN, pygame.K_c]
250                }, \
251       
252} # BUTTON_LAYOUT
253
254
255#####################################################################
256# Flash socket policy handling
257#####################################################################
258
259FLASH_POLICY_FILE_REQUEST = \
260        '<policy-file-request/>%c' % 0 # NULL byte termination
261FLASH_SOCKET_POLICY_FILE = '''<?xml version="1.0"?>
262<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
263<cross-domain-policy>
264   <site-control permitted-cross-domain-policies="all" />
265   <allow-access-from domain="*" to-ports="%i" />
266</cross-domain-policy>%c''' % (THINKGEAR_SERVER_PORT, 0)
267
268
269#####################################################################
270# Configuration File Parser
271#####################################################################
272
273if os.path.exists(BRAINSTORMS_CONFIGURATION_FILE_PATH):
274       
275        file = open(BRAINSTORMS_CONFIGURATION_FILE_PATH, 'r')
276       
277        for line in file.readlines():
278                line = line.strip()
279                if len(line) == 0:
280                        continue
281                if line[0] == '#':
282                        continue
283                if line.find('=') == -1:
284                        continue
285                if (line == "NXT_BLUETOOTH_DEVICE = ''"):
286                        # use operating system default if device not set manually
287                        continue
288                try:
289                        exec line
290                except:
291                        if DEBUG:
292                                print "Error recognizing Puzzlebox Brainstorms configuration option:",
293                                print line
294
Note: See TracBrowser for help on using the repository browser.