source: remote_control/puzzlebox_brainstorms_configuration.py @ 94

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

remote_control/puzzlebox_brainstorms_network_client_thinkgear.py:

  • adjustment to debug output for clarity

remote_control/puzzlebox_brainstorms_network_client.py:

  • warning output on timeout waiting for server connections
  • adjustment to debug output for clarity

remote_control/puzzlebox_brainstorms_remote_control.py:

  • adjustment to debug output for clarity

remote_control/puzzlebox_brainstorms_client_interface.py:

  • forward driving halted when disconnected from ThinkGear? server
  • keyboard shortcuts added to direction buttons
  • virtual button presses drawn when driving activated by direction
  • better handling of speed changes in updateSpeed
  • speed dropped to 100 if NXT power threshold exceeded

remote_control/puzzlebox_brainstorms_configuration.ini:

  • ThinkGear? Connect Server Emulator configuration added
  • default Relaxation speed boosts tweaked

remote_control/interface/qt4_form.py:

  • faulty keyboard shortcuts removed

remote_control/puzzlebox_brainstorms_configuration.py:

  • ThinkGear? Connect Server Emulator configuration
  • default Relaxation speed boosts tweaked

remote_control/puzzlebox_brainstorms_client_interface_network.py:

  • initial checkin

remote_control/puzzlebox_brainstorms_client_interface_local.py:

  • initial checking
  • not properly establishing client/server communications

remote_control/puzzlebox_brainstorms_network_server_thinkgear.py

  • adjustment to debug output for clarity
  • some configuration settings moved to configuration module

remote_control/puzzlebox_brainstorms_network_server.py:

  • adjustment to debug output for clarity
File size: 7.9 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.06
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
64BRAINSTORMS_DISCRETE_CONTROL_COMMANDS = False
65DEFAULT_NXT_POWER_LEVEL = 80
66
67DEFAULT_NXT_BLUETOOTH_DEVICE_WINDOWS = 'COM1'
68DEFAULT_NXT_BLUETOOTH_DEVICE_LINUX = '/dev/rfcomm0'
69
70if (sys.platform == 'win32'):
71        NXT_BLUETOOTH_DEVICE = DEFAULT_NXT_BLUETOOTH_DEVICE_WINDOWS
72else:
73        NXT_BLUETOOTH_DEVICE = DEFAULT_NXT_BLUETOOTH_DEVICE_LINUX
74
75NXT_MOTORS_MOUNTED_BACKWARDS = True
76NXT_MOTOR_PORT_RIGHT = 'a'
77NXT_MOTOR_PORT_LEFT = 'b'
78NXT_DEFAULT_RC_COMMAND = 'test_drive'
79
80
81#####################################################################
82# Server configuration
83#####################################################################
84
85BRAINSTORMS_DELIMITER = '\r'
86
87TWISTED_SERVER_MAX_COMPONENTS = 16
88
89
90#####################################################################
91# Client configuration
92#####################################################################
93
94CLIENT_NO_REPLY_WAIT = 5 # how many seconds before considering a component dead
95
96TWISTED_CLIENT_MAX_CONNECTION_ATTEMPTS = 5
97
98
99#####################################################################
100# ThinkGear Connect configuration
101#####################################################################
102
103THINKGEAR_DELIMITER = '\r'
104
105THINKGEAR_CONFIGURATION_PARAMETERS = {"enableRawOutput": False, "format": "Json"}
106
107THINKGEAR_AUTHORIZATION_ENABLED = False
108
109THINKGEAR_AUTHORIZATION_REQUEST = { \
110        "appName": "Puzzlebox Brainstorms", \
111        "appKey": "2e285d7bd5565c0ea73e7e265c73f0691d932408"
112}
113
114
115#####################################################################
116# ThinkGear Connect Server Emulator configuration
117#####################################################################
118
119THINKGEAR_ENABLE_SIMULATE_HEADSET_DATA = True
120
121THINKGEAR_BLINK_FREQUENCY_TIMER = 6 # blink every 6 seconds
122                                    # (6 seconds is listed by Wikipedia
123                                    # as being the average number of times
124                                    # an adult blinks in a laboratory setting)
125
126THINKGEAR_DEFAULT_SAMPLE_WAVELENGTH = 30 # number of seconds from 0 to max
127                                         # and back to 0 for any given
128                                         # detection value below
129
130
131#####################################################################
132# Client Interface configuration [Qt]
133#####################################################################
134
135THINKGEAR_POWER_THRESHOLDS = { \
136       
137        'concentration': { \
138                0: 0, \
139                10: 0, \
140                20: 0, \
141                30: 0, \
142                40: 0, \
143                50: 0, \
144                60: 60, \
145                70: 70, \
146                75: 75, \
147                80: 80, \
148                90: 85, \
149                100: 90, \
150                }, \
151       
152        'relaxation': { \
153                0: 0, \
154                10: 0, \
155                20: 0, \
156                30: 0, \
157                40: 0, \
158                50: 0, \
159                60: 10, \
160                70: 10, \
161                80: 15, \
162                90: 20, \
163                100: 20, \
164                }, \
165       
166} # THINKGEAR_POWER_THRESHOLDS
167
168
169#####################################################################
170# Client Interface configuration [Pygame]
171#####################################################################
172
173CLIENT_PYGAME_DISPLAY_WINDOW_X_COORDINATE = 0
174CLIENT_PYGAME_DISPLAY_WINDOW_Y_COORDINATE = 0
175CLIENT_PYGAME_DISPLAY_WINDOW_X_DIMENSION = 254
176CLIENT_PYGAME_DISPLAY_WINDOW_Y_DIMENSION = 424
177
178#CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (255,255,255) # white background
179#CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (128,128,128) # grey background
180#CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (64,64,64)    # dark grek background
181CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (0,0,0)       # black background
182
183CLIENT_PYGAME_IMAGE_DIRECTORY = os.path.join(os.getcwd(), 'images')
184
185# Keyboard key reference at http://www.pygame.org/docs/ref/key.html#pygame.key
186CLIENT_PYGAME_BUTTON_LAYOUT = { \
187       
188        'left': { \
189                'command': 'turn_left', \
190                'active': False, \
191                'button_image': '1-upper_left-white.png', \
192                'activated_image': '1-upper_left-orange.png', \
193                'image_x': 0, \
194                'image_y': 0, \
195                'match_keys': [pygame.K_LEFT, pygame.K_a, pygame.K_q]
196                }, \
197       
198        'forward': { \
199                'command': 'drive_forward', \
200                'active': False, \
201                'button_image': '2-up-white.png', \
202                'activated_image': '2-up-orange.png', \
203                'image_x': 98, \
204                'image_y': 0, \
205                'match_keys': [pygame.K_UP, pygame.K_w]
206                }, \
207       
208        'right': { \
209                'command': 'turn_right', \
210                'active': False, \
211                'button_image': '3-upper_right-white.png', \
212                'activated_image': '3-upper_right-orange.png', \
213                'image_x': 157, \
214                'image_y': 0, \
215                'match_keys': [pygame.K_RIGHT, pygame.K_d, pygame.K_e]
216                }, \
217       
218        'reverse_left': { \
219                'command': 'turn_left_in_reverse', \
220                'active': False, \
221                'button_image': '7-lower_left-white.png', \
222                'activated_image': '7-lower_left-orange.png', \
223                'image_x': 0, \
224                'image_y': 220, \
225                'match_keys': [pygame.K_z]
226                }, \
227       
228        'reverse': { \
229                'command': 'drive_reverse', \
230                'active': False, \
231                'button_image': '8-down-white.png', \
232                'activated_image': '8-down-orange.png', \
233                'image_x': 98, \
234                'image_y': 220, \
235                'match_keys': [pygame.K_DOWN, pygame.K_s, pygame.K_x]
236                }, \
237       
238        'reverse_right': { \
239                'command': 'turn_right_in_reverse', \
240                'active': False, \
241                'button_image': '9-lower_right-white.png', \
242                'activated_image': '9-lower_right-orange.png', \
243                'image_x': 157, \
244                'image_y': 220, \
245                'match_keys': [pygame.K_PAGEDOWN, pygame.K_c]
246                }, \
247       
248} # BUTTON_LAYOUT
249
250
251#####################################################################
252# Flash socket policy handling
253#####################################################################
254
255FLASH_POLICY_FILE_REQUEST = \
256        '<policy-file-request/>%c' % 0 # NULL byte termination
257FLASH_SOCKET_POLICY_FILE = '''<?xml version="1.0"?>
258<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
259<cross-domain-policy>
260   <site-control permitted-cross-domain-policies="all" />
261   <allow-access-from domain="*" to-ports="%i" />
262</cross-domain-policy>%c''' % (THINKGEAR_SERVER_PORT, 0)
263
264
265#####################################################################
266# Configuration File Parser
267#####################################################################
268
269if os.path.exists(BRAINSTORMS_CONFIGURATION_FILE_PATH):
270       
271        file = open(BRAINSTORMS_CONFIGURATION_FILE_PATH, 'r')
272       
273        for line in file.readlines():
274                line = line.strip()
275                if len(line) == 0:
276                        continue
277                if line[0] == '#':
278                        continue
279                if line.find('=') == -1:
280                        continue
281                try:
282                        exec line
283                except:
284                        if DEBUG:
285                                print "Error recognizing Puzzlebox Brainstorms configuration option:",
286                                print line
287
Note: See TracBrowser for help on using the repository browser.