diff --git a/config.py b/config.py index 03f93ee..6d43578 100644 --- a/config.py +++ b/config.py @@ -105,7 +105,7 @@ R_MAX = 0.75 THETA_MIN= -TABLE_ARC/2 THETA_MAX = TABLE_ARC/2 Z_MIN = TABLE_Z + 0.5*BLOCK_DIM -Z_MAX = TABLE_Z + 4.5*BLOCK_DIM #4 blocks high +Z_MAX = TABLE_Z + 2*BLOCK_DIM @@ -123,19 +123,7 @@ Z_MAX = TABLE_Z + 4.5*BLOCK_DIM #4 blocks high # RB:5 # Back:6 # Start:7 -BUTTON_MAP = { - 4: (0, 0, -1), - 5: (0, 0, 1) -} -# Hat switch:0 (All or nothing for direction). returns (+-1, +-1) = (+-x. +-y) -# hx, hy = hat -HATCODE = 0 #set to -1 to avoid polling hat -HX = 10 -HY = 11 -HAT_MAP = { - HX: (0, 1, 0), - HY: (-1, 0, 0) #inverted -} +# # Axes (Not supported) # Joystick left, x-axis:0 # Joystick left, y-axis:1 @@ -143,7 +131,30 @@ HAT_MAP = { # Joystick right, x-axis:4 # Left trigger:2 # Right trigger:5 +# +# Hat switch:0 (All or nothing for direction). returns (+-1, +-1) = (+-x. +-y) +# hx, hy = hat +HATCODE = -1 #set to -1 to avoid polling hat +HX = 10 +HY = 11 +HAT_MAP = { + HX: (0,1,0), + HY: (-1,0,0) #inverted +} + +#BUTTON_MAP = { +# 4: (0,0,-1), +# 5: (0,0,1) +#} +BUTTON_MAP = { #Buttons only (no hat) + 0: (1,0,0), + 3: (-1,0,0), + 1: (0,1,0), + 2: (0,-1,0), + 4: (0,0,-1), + 5: (0,0,1) +} # AUTO/LOOP CONTROL diff --git a/config.py.bak b/config.py.bak index 3559b0f..5325db7 100644 --- a/config.py.bak +++ b/config.py.bak @@ -1,5 +1,5 @@ -# This config file is the one tested and tuned during development. -# Revert to this to reset parameters. +# This is a backup of a working demo configuration. +# Reset parameters by reverting to this. import math DEBUG = True @@ -88,6 +88,9 @@ T_FORCE_VIOLATION = 0.3 # Note that the angular velocity is also [m/s], not [rad/s], to ensure that the robot # moves with constant speed regardless of direction in the polar plane. # IMPORTANT: VEL_Z should be tuned to Z_MIN to avoid smashing into the table. +# +# T_DIR_CHANGE_COOLDOWN is a cooldown between change of commands. With this, the robot +# have a chance to decelerate before changing direction, which smooths out motion. VEL = 0.1 #[m/s] VEL_Z = 0.05 #[m/s] ACC = 0.5 #[m/s^2] @@ -104,10 +107,58 @@ R_MAX = 0.75 THETA_MIN= -TABLE_ARC/2 THETA_MAX = TABLE_ARC/2 Z_MIN = TABLE_Z + 0.5*BLOCK_DIM -Z_MAX = TABLE_Z + 4.5*BLOCK_DIM #4 blocks high +Z_MAX = TABLE_Z + 2*BLOCK_DIM +# GAMEPAD MAP +# +# For the Microsoft xBox 360 controller. Button/axes codes are listed +# below for reference. +# +# Buttons +# A:0 +# B:1 +# X:2 +# Y:3 +# LB:4 +# RB:5 +# Back:6 +# Start:7 +# +# Axes (Not supported) +# Joystick left, x-axis:0 +# Joystick left, y-axis:1 +# Joystick right, x-axis:3 +# Joystick right, x-axis:4 +# Left trigger:2 +# Right trigger:5 +# +# Hat switch:0 (All or nothing for direction). returns (+-1, +-1) = (+-x. +-y) +# hx, hy = hat + +HATCODE = -1 #set to -1 to avoid polling hat +HX = 10 +HY = 11 +HAT_MAP = { + HX: (0,1,0), + HY: (-1,0,0) #inverted +} + +#BUTTON_MAP = { +# 4: (0,0,-1), +# 5: (0,0,1) +#} +BUTTON_MAP = { #Buttons only (no hat) + 0: (1,0,0), + 3: (-1,0,0), + 1: (0,1,0), + 2: (0,-1,0), + 4: (0,0,-1), + 5: (0,0,1) +} + + # AUTO/LOOP CONTROL # # When looping, the robot use the same velocity for r, theta and z. diff --git a/config.pyc b/config.pyc index 311f253..4ccbc39 100644 Binary files a/config.pyc and b/config.pyc differ diff --git a/ur5controller.py b/ur5controller.py index 56cda5e..ece511b 100644 --- a/ur5controller.py +++ b/ur5controller.py @@ -292,7 +292,7 @@ class DemoController(object): v = [pose1[i]-pose0[i] for i in range(len(pose0))] if self.debug: _sum = sum(map(abs, v)) - print "Velocity vector, dt=%.2f: %s. SUM %.3f" % (dt, str([('%.2f' % i) for i in v]), _sum) + print "dt = %.2f, v = ds/dt = %s, |v| = %.3f" % (dt, str([('%.2f' % i) for i in v]), _sum) return sum(map(abs, v)) > threshold diff --git a/ur5controller.pyc b/ur5controller.pyc index 7a34ed5..fb30325 100644 Binary files a/ur5controller.pyc and b/ur5controller.pyc differ