source: remote_control/puzzlebox_brainstorms_configuration.py @ 84

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

remote_control/puzzlebox_brainstorms_network_client.py:

  • power transmission settings added

remote_control/puzzlebox_brainstorms_remote_control.py:

  • custom power settings added

remote_control/puzzlebox_brainstorms_client_interface.py:

  • power transmission settings added
  • udpateSpeed method tracks and calculates power settings
  • power transmission settings added

remote_control/puzzlebox_brainstorms_configuration.ini:

  • DEFAULT_NXT_POWER_LEVEL added and set to 80

remote_control/interface/qt4_form.py:

  • font sizes tweaked

remote_control/puzzlebox_brainstorms_configuration.py:

  • DEFAULT_NXT_POWER_LEVEL added and set to 80

remote_control/puzzlebox_brainstorms_network_server.py

  • power transmission settings added
File size: 7.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.01
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 = True
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# Client Interface configuration [Qt]
117#####################################################################
118
119THINKGEAR_POWER_THRESHOLDS = { \
120       
121        'concentration': { \
122                0: 0, \
123                10: 0, \
124                20: 0, \
125                30: 0, \
126                40: 0, \
127                50: 0, \
128                60: 60, \
129                70: 70, \
130                75: 75, \
131                80: 80, \
132                90: 85, \
133                100: 90, \
134                }, \
135       
136        'relaxation': { \
137                0: 0, \
138                10: 0, \
139                20: 0, \
140                30: 0, \
141                40: 0, \
142                50: 0, \
143                60: 0, \
144                70: 0, \
145                80: 10, \
146                90: 15, \
147                100: 20, \
148                }, \
149       
150} # THINKGEAR_POWER_THRESHOLDS
151
152
153#####################################################################
154# Client Interface configuration [Pygame]
155#####################################################################
156
157CLIENT_PYGAME_DISPLAY_WINDOW_X_COORDINATE = 0
158CLIENT_PYGAME_DISPLAY_WINDOW_Y_COORDINATE = 0
159CLIENT_PYGAME_DISPLAY_WINDOW_X_DIMENSION = 254
160CLIENT_PYGAME_DISPLAY_WINDOW_Y_DIMENSION = 424
161
162#CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (255,255,255) # white background
163#CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (128,128,128) # grey background
164#CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (64,64,64)    # dark grek background
165CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (0,0,0)       # black background
166
167CLIENT_PYGAME_IMAGE_DIRECTORY = os.path.join(os.getcwd(), 'images')
168
169# Keyboard key reference at http://www.pygame.org/docs/ref/key.html#pygame.key
170CLIENT_PYGAME_BUTTON_LAYOUT = { \
171       
172        'left': { \
173                'command': 'turn_left', \
174                'active': False, \
175                'button_image': '1-upper_left-white.png', \
176                'activated_image': '1-upper_left-orange.png', \
177                'image_x': 0, \
178                'image_y': 0, \
179                'match_keys': [pygame.K_LEFT, pygame.K_a, pygame.K_q]
180                }, \
181       
182        'forward': { \
183                'command': 'drive_forward', \
184                'active': False, \
185                'button_image': '2-up-white.png', \
186                'activated_image': '2-up-orange.png', \
187                'image_x': 98, \
188                'image_y': 0, \
189                'match_keys': [pygame.K_UP, pygame.K_w]
190                }, \
191       
192        'right': { \
193                'command': 'turn_right', \
194                'active': False, \
195                'button_image': '3-upper_right-white.png', \
196                'activated_image': '3-upper_right-orange.png', \
197                'image_x': 157, \
198                'image_y': 0, \
199                'match_keys': [pygame.K_RIGHT, pygame.K_d, pygame.K_e]
200                }, \
201       
202        'reverse_left': { \
203                'command': 'turn_left_in_reverse', \
204                'active': False, \
205                'button_image': '7-lower_left-white.png', \
206                'activated_image': '7-lower_left-orange.png', \
207                'image_x': 0, \
208                'image_y': 220, \
209                'match_keys': [pygame.K_z]
210                }, \
211       
212        'reverse': { \
213                'command': 'drive_reverse', \
214                'active': False, \
215                'button_image': '8-down-white.png', \
216                'activated_image': '8-down-orange.png', \
217                'image_x': 98, \
218                'image_y': 220, \
219                'match_keys': [pygame.K_DOWN, pygame.K_s, pygame.K_x]
220                }, \
221       
222        'reverse_right': { \
223                'command': 'turn_right_in_reverse', \
224                'active': False, \
225                'button_image': '9-lower_right-white.png', \
226                'activated_image': '9-lower_right-orange.png', \
227                'image_x': 157, \
228                'image_y': 220, \
229                'match_keys': [pygame.K_PAGEDOWN, pygame.K_c]
230                }, \
231       
232} # BUTTON_LAYOUT
233
234
235#####################################################################
236# Flash socket policy handling
237#####################################################################
238
239FLASH_POLICY_FILE_REQUEST = \
240        '<policy-file-request/>%c' % 0 # NULL byte termination
241FLASH_SOCKET_POLICY_FILE = '''<?xml version="1.0"?>
242<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
243<cross-domain-policy>
244   <site-control permitted-cross-domain-policies="all" />
245   <allow-access-from domain="*" to-ports="%i" />
246</cross-domain-policy>%c''' % (THINKGEAR_SERVER_PORT, 0)
247
248
249#####################################################################
250# Configuration File Parser
251#####################################################################
252
253if os.path.exists(BRAINSTORMS_CONFIGURATION_FILE_PATH):
254       
255        file = open(BRAINSTORMS_CONFIGURATION_FILE_PATH, 'r')
256       
257        for line in file.readlines():
258                line = line.strip()
259                if len(line) == 0:
260                        continue
261                if line[0] == '#':
262                        continue
263                if line.find('=') == -1:
264                        continue
265                try:
266                        exec line
267                except:
268                        if DEBUG:
269                                print "Error recognizing Puzzlebox Brainstorms configuration option:",
270                                print line
271
Note: See TracBrowser for help on using the repository browser.