Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

man - reorganized Python packages and imports

  The update required many changes throughout cmake files, directories, and
  Python sources.  In general, the changes are as follows:
    * Directory changes:
      * Removed duplicated Python source directories (i.e.
        'man/skull/noggin/noggin') and moved Python sources and subpackages
        into the main directory (with C++ files and headers)
      * Added some new package initilization modules, some bare, some with
        sparse import attempt and warning code
    * CMake changes:
      * Added MAN_PYTHON_TARGET_DIR and XXX_PYTHON_TARGET_DIR variables,
        along with XXX_PYTHON_SRCS if it didn't exist
      * Changed Python source location settings to mimic the man/ structure
      * Used above variables to install Python sources
      * In some packages, added some __init__.py or other new source files to
        the XXX_PYTHON_SRCS
    * In Python sources:
      * Changed Python import scheme across many files.  The full format will
        be posted online.  This consisted of:
        * Changing imports to account for new package structure ('motion' is
          now 'man.motion', 'sensors' is now 'man.corpus.sensors')
        * Changing imports to use approriate relative or absolute imports
        * Occasionally, changing import code to properly distinguish between
          package, module, and attribute imports

   The code will now install to a specified directory with the fully realized
   design structure specified by our initial discussions.  Python package
   directories and extension modules install coordinatedly, when shared
   extension modules are specified.  All the low-level C++/C code is contained
   in the libman.so or man executable, in lib/ or bin/ respectively, and, when
   shared extension modules are not specified, this contains all the module
   insertion code and Python embedding as well.
  • Loading branch information...
commit 6057b0baa82bfc6432d2397aa89030c41e2a915e 1 parent d18423d
Jeremy R. Fishman authored
Showing with 278 additions and 194 deletions.
  1. +3 −1 Makefile
  2. 0  {skull/noggin/noggin/playBook → }/__init__.py
  3. +29 −19 cmake.man/CMakeLists.txt
  4. +17 −8 cmake/FindNBCOMMON.cmake
  5. +8 −0 comm/__init__.py
  6. +10 −4 comm/cmake.comm/CMakeLists.txt
  7. 0  {skull/noggin/noggin → corpus}/__init__.py
  8. +5 −4 corpus/cmake.man.corpus/CMakeLists.txt
  9. +5 −1 corpus/leds.py
  10. +6 −6 corpus/sensors.py
  11. +6 −6 motion/{motion → }/MotionConstants.py
  12. 0  motion/{motion → }/SweetMoves.py
  13. +2 −0  motion/__init__.py
  14. +31 −30 motion/cmake.man.motion/CMakeLists.txt
  15. +0 −1  motion/{motion/__init__.py → walk.py}
  16. 0  skull/__init__.py
  17. +19 −17 skull/noggin/{noggin → }/Brain.py
  18. +5 −4 skull/noggin/{noggin → }/EKF.py
  19. +4 −5 skull/noggin/{noggin → }/GameController.py
  20. 0  skull/noggin/{noggin → }/GameStates.py
  21. +3 −3 skull/noggin/{noggin → }/HeadTracking.py
  22. +1 −1  skull/noggin/Makefile
  23. 0  skull/noggin/{noggin → }/NaoOutput.py
  24. 0  skull/noggin/{noggin → }/NavConstants.py
  25. +2 −2 skull/noggin/{noggin → }/NavStates.py
  26. +4 −4 skull/noggin/{noggin → }/Navigator.py
  27. 0  skull/noggin/{noggin → }/NogginConstants.py
  28. 0  skull/noggin/{noggin → }/PanningStates.py
  29. +2 −2 skull/noggin/{noggin → }/TrackingStates.py
  30. +8 −2 skull/noggin/{noggin → }/TypeDefs.py
  31. 0  skull/noggin/__init__.py
  32. +32 −10 skull/noggin/cmake.noggin/CMakeLists.txt
  33. +0 −2  skull/noggin/noggin/players/Switch.py.in
  34. +3 −3 skull/noggin/{noggin → }/playBook/Formations.py
  35. +12 −5 skull/noggin/{noggin → }/playBook/GoTeam.py
  36. +1 −1  skull/noggin/{noggin → }/playBook/PBConstants.py
  37. +2 −2 skull/noggin/{noggin → }/playBook/PBDefs.py
  38. +3 −3 skull/noggin/{noggin → }/playBook/Roles.py
  39. +3 −3 skull/noggin/{noggin → }/playBook/Strategies.py
  40. +1 −1  skull/noggin/{noggin → }/playBook/SubRoles.py
  41. 0  skull/noggin/playBook/__init__.py
  42. +3 −2 skull/noggin/{noggin → }/players/DistCalStates.py
  43. +2 −2 skull/noggin/{noggin → }/players/FirstGameStates.py
  44. 0  skull/noggin/{noggin → }/players/KeyControlStates.py
  45. +3 −3 skull/noggin/{noggin → }/players/NoneStates.py
  46. +3 −3 skull/noggin/{noggin → }/players/SecondGameStates.py
  47. 0  skull/noggin/{noggin → }/players/StandupStates.py
  48. 0  skull/noggin/{noggin → }/players/SuzhouConstants.py
  49. +7 −5 skull/noggin/{noggin → }/players/SuzhouStates.py
  50. +2 −0  skull/noggin/players/Switch.py.in
  51. 0  skull/noggin/{noggin → }/players/TrackBallStates.py
  52. 0  skull/noggin/{noggin → }/players/WalkLearning.py
  53. 0  skull/noggin/{noggin → }/players/__init__.py
  54. +1 −1  skull/noggin/{noggin → }/players/pBalance.py
  55. +2 −2 skull/noggin/{noggin → }/players/pControl.py
  56. 0  skull/noggin/{noggin → }/players/pDist.py
  57. +2 −2 skull/noggin/{noggin → }/players/pFirstGame.py
  58. 0  skull/noggin/{noggin → }/players/pKicker.py
  59. +3 −4 skull/noggin/{noggin → }/players/pNone.py
  60. 0  skull/noggin/{noggin → }/players/pOldWalker.py
  61. +1 −1  skull/noggin/{noggin → }/players/pRexec.py
  62. +3 −4 skull/noggin/{noggin → }/players/pSecondGame.py
  63. +2 −3 skull/noggin/{noggin → }/players/pStandup.py
  64. +4 −4 skull/noggin/{noggin → }/players/pSuzhou.py
  65. +2 −3 skull/noggin/{noggin → }/players/pTracker.py
  66. +2 −3 skull/noggin/{noggin → }/players/pWalker.py
  67. 0  skull/noggin/{noggin → }/robots/BirthCertificate.py
  68. +1 −1  skull/noggin/{noggin → }/robots/__init__.py
  69. 0  skull/{noggin/noggin/vision.py → vision/__init__.py}
  70. +8 −1 skull/vision/cmake.vision/CMakeLists.txt
View
4 Makefile
@@ -14,6 +14,8 @@ CONFIG_FILE = manconfig.h
CROSS_FILE = $(BUILD_DIR)/cross
STRAIGHT_FILE = $(BUILD_DIR)/straight
+PYC_FILES = $(shell find . -name "*.pyc")
+
CROSS_TOOLCHAIN = $(abspath $(CURDIR)/cmake/geode.cmake)
CMAKE_DEFS = -DOE_CROSS_BUILD=OFF
CMAKE_CROSS_DEFS = -DCMAKE_TOOLCHAIN_FILE=$(CROSS_TOOLCHAIN) -DOE_CROSS_BUILD=ON
@@ -93,6 +95,6 @@ clean:
@$(MAKE) -C skull/noggin clean
@$(MAKE) -C skull/vision clean
@$(MAKE) -C comm clean
- $(RM) -r install/*
+ $(RM) -r install/* $(PYC_FILES)
View
0  skull/noggin/noggin/playBook/__init__.py → __init__.py
File renamed without changes
View
48 cmake.man/CMakeLists.txt
@@ -150,6 +150,8 @@ SET( MAN_SRCS ${MAN_INCLUDE_DIR}/Man
${MAN_INCLUDE_DIR}/_ledsmodule
)
+SET( MAN_PYTHON_SRCS ${MAN_INCLUDE_DIR}/__init__.py )
+SET( SKULL_PYTHON_SRCS ${SKULL_INCLUDE_DIR}/__init__.py )
############################ CHECK LIBRARY / EXECUTABLE OPTION
# Configure the output execuatable or shared library, and the install
@@ -157,26 +159,34 @@ SET( MAN_SRCS ${MAN_INCLUDE_DIR}/Man
GET_TARGET_PROPERTY( MAN_LOCATION ${MAN_TARGET} LOCATION )
-IF( ROBOT_NAO )
- IF( MAN_IS_REMOTE )
- ADD_EXECUTABLE(
- ${MAN_TARGET}
- ${MAN_SRCS}
- )
- ELSE( MAN_IS_REMOTE )
- ADD_LIBRARY(
- ${MAN_TARGET}
- SHARED
- ${MAN_SRCS}
- )
- ENDIF( MAN_IS_REMOTE )
- INSTALL(
- TARGETS ${MAN_TARGET}
- RUNTIME DESTINATION ${OUTPUT_ROOT_DIR_BIN}
- LIBRARY DESTINATION ${OUTPUT_ROOT_DIR_LIB}
- CONFIGURATIONS "" Debug Release
+IF( MAN_IS_REMOTE )
+ ADD_EXECUTABLE(
+ ${MAN_TARGET}
+ ${MAN_SRCS}
)
-ENDIF( ROBOT_NAO )
+ELSE( MAN_IS_REMOTE )
+ ADD_LIBRARY(
+ ${MAN_TARGET}
+ SHARED
+ ${MAN_SRCS}
+ )
+ENDIF( MAN_IS_REMOTE )
+INSTALL(
+ TARGETS ${MAN_TARGET}
+ RUNTIME DESTINATION ${OUTPUT_ROOT_DIR_BIN}
+ LIBRARY DESTINATION ${OUTPUT_ROOT_DIR_LIB}
+ CONFIGURATIONS "" Debug Release
+ )
+INSTALL(
+ FILES ${MAN_PYTHON_SRCS}
+ DESTINATION ${MAN_PYTHON_TARGET_DIR}
+ CONFIGURATIONS "" Debug Release
+ )
+INSTALL(
+ FILES ${SKULL_PYTHON_SRCS}
+ DESTINATION ${SKULL_PYTHON_TARGET_DIR}
+ CONFIGURATIONS "" Debug Release
+ )
############################ SET LIBRARIES TO LINK WITH
View
25 cmake/FindNBCOMMON.cmake
@@ -30,20 +30,21 @@ SET( NBCOMMON_INCLUDE_DIR "${TRUNK_PATH}/common/include" )
SET( NBCOMMON_LIBRARIES "" )
SET( NBCOMMON_LIB_DIR "${TRUNK_PATH}/common/lib" )
-SET( VISION_INCLUDE_DIR ${TRUNK_PATH}/skull/vision )
-SET( NOGGIN_INCLUDE_DIR ${TRUNK_PATH}/skull/noggin )
-SET( COMM_INCLUDE_DIR ${TRUNK_PATH}/comm )
-SET( CORPUS_INCLUDE_DIR ${TRUNK_PATH}/corpus )
-SET( MOTION_INCLUDE_DIR ${TRUNK_PATH}/motion )
+SET( MAN_INCLUDE_DIR ${TRUNK_PATH} )
+SET( COMM_INCLUDE_DIR ${MAN_INCLUDE_DIR}/comm )
+SET( CORPUS_INCLUDE_DIR ${MAN_INCLUDE_DIR}/corpus )
+SET( MOTION_INCLUDE_DIR ${MAN_INCLUDE_DIR}/motion )
+SET( SKULL_INCLUDE_DIR ${MAN_INCLUDE_DIR}/skull )
+SET( NOGGIN_INCLUDE_DIR ${SKULL_INCLUDE_DIR}/noggin )
+SET( VISION_INCLUDE_DIR ${SKULL_INCLUDE_DIR}/vision )
-SET( MAN_INCLUDE_DIR ${TRUNK_PATH} )
-SET( VISION_CMAKE_DIR ${VISION_INCLUDE_DIR}/cmake.vision )
-SET( NOGGIN_CMAKE_DIR ${NOGGIN_INCLUDE_DIR}/cmake.noggin )
SET( COMM_CMAKE_DIR ${COMM_INCLUDE_DIR}/cmake.comm )
SET( CORPUS_CMAKE_DIR ${CORPUS_INCLUDE_DIR}/cmake.man.corpus )
SET( MAN_CMAKE_DIR ${MAN_INCLUDE_DIR}/cmake.man )
SET( MOTION_CMAKE_DIR ${MOTION_INCLUDE_DIR}/cmake.man.motion )
+SET( NOGGIN_CMAKE_DIR ${NOGGIN_INCLUDE_DIR}/cmake.noggin )
+SET( VISION_CMAKE_DIR ${VISION_INCLUDE_DIR}/cmake.vision )
SET( COMM_TARGET _comm )
@@ -54,6 +55,14 @@ SET( NOGGIN_TARGET noggin )
SET( SENSORS_TARGET _sensors )
SET( VISION_TARGET vision )
+SET( MAN_PYTHON_TARGET_DIR ${OUTPUT_ROOT_DIR_LIB}/man )
+SET( COMM_PYTHON_TARGET_DIR ${MAN_PYTHON_TARGET_DIR}/comm )
+SET( CORPUS_PYTHON_TARGET_DIR ${MAN_PYTHON_TARGET_DIR}/corpus )
+SET( MOTION_PYTHON_TARGET_DIR ${MAN_PYTHON_TARGET_DIR}/motion )
+SET( SKULL_PYTHON_TARGET_DIR ${MAN_PYTHON_TARGET_DIR}/skull )
+SET( NOGGIN_PYTHON_TARGET_DIR ${SKULL_PYTHON_TARGET_DIR}/noggin )
+SET( VISION_PYTHON_TARGET_DIR ${SKULL_PYTHON_TARGET_DIR}/vision )
+
SET( TRUNK_REVISION r$ENV{TRUNK_REVISION} CACHE STRING "SVN Revision number" )
View
8 comm/__init__.py
@@ -0,0 +1,8 @@
+
+try:
+ from _comm import *
+except ImportError:
+ import sys
+ print >>sys.stderr, "**** WARNING - No backend _comm module located ****"
+ inst = None
+
View
14 comm/cmake.comm/CMakeLists.txt
@@ -142,12 +142,13 @@ SET( COMM_SRCS ${COMM_INCLUDE_DIR}/Comm
${COMM_INCLUDE_DIR}/TOOLConnect
)
-IF( PYTHON_SHARED_COMM AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" )
+IF( PYTHON_SHARED_COMM )
LIST( APPEND COMM_SRCS ${CORPUS_INCLUDE_DIR}/Sensors
${CORPUS_INCLUDE_DIR}/NaoPose
)
-ENDIF( PYTHON_SHARED_COMM AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" )
+ENDIF( PYTHON_SHARED_COMM )
+SET( COMM_PYTHON_SRCS ${COMM_INCLUDE_DIR}/__init__.py )
############################ CHECK LIBRARY / EXECUTABLE OPTION
# Configure the output execuatable or shared library, and the install
@@ -165,8 +166,8 @@ IF( PYTHON_SHARED_COMM )
)
INSTALL(
FILES ${COMM_TARGET_LOCATION}
- DESTINATION ${OUTPUT_ROOT_DIR_LIB}
- CONFIGURATIONS Debug
+ DESTINATION ${COMM_PYTHON_TARGET_DIR}
+ CONFIGURATIONS "" Debug Release
RENAME ${COMM_TARGET}module.so
)
ELSE( PYTHON_SHARED_COMM )
@@ -178,6 +179,11 @@ ELSE( PYTHON_SHARED_COMM )
# No INSTALL target when static
ENDIF( PYTHON_SHARED_COMM )
+INSTALL(
+ FILES ${COMM_PYTHON_SRCS}
+ DESTINATION ${COMM_PYTHON_TARGET_DIR}
+ CONFIGURATIONS "" Debug Release
+ )
############################ SET LIBRARIES TO LINK WITH
IF( ROBOT_NAO )
View
0  skull/noggin/noggin/__init__.py → corpus/__init__.py
File renamed without changes
View
9 corpus/cmake.man.corpus/CMakeLists.txt
@@ -101,7 +101,8 @@ IF( PYTHON_SHARED_CORPUS )
)
ENDIF( PYTHON_SHARED_CORPUS )
-SET( CORPUS_PYTHON_SRCS ${CORPUS_INCLUDE_DIR}/leds.py
+SET( CORPUS_PYTHON_SRCS ${CORPUS_INCLUDE_DIR}/__init__.py
+ ${CORPUS_INCLUDE_DIR}/leds.py
${CORPUS_INCLUDE_DIR}/sensors.py
)
@@ -128,13 +129,13 @@ IF( PYTHON_SHARED_CORPUS )
# Install to TARGETmodule.so, instead of lib_TARGET.so
INSTALL(
FILES ${SENSORS_TARGET_LOCATION}
- DESTINATION ${OUTPUT_ROOT_DIR_LIB}
+ DESTINATION ${CORPUS_PYTHON_TARGET_DIR}
CONFIGURATIONS "" Debug Release
RENAME ${SENSORS_TARGET}module.so
)
INSTALL(
FILES ${LEDS_TARGET_LOCATION}
- DESTINATION ${OUTPUT_ROOT_DIR_LIB}
+ DESTINATION ${CORPUS_PYTHON_TARGET_DIR}
CONFIGURATIONS "" Debug Release
RENAME ${LEDS_TARGET}module.so
)
@@ -154,7 +155,7 @@ ENDIF( PYTHON_SHARED_CORPUS )
INSTALL(
FILES ${CORPUS_PYTHON_SRCS}
- DESTINATION ${OUTPUT_ROOT_DIR_LIB}
+ DESTINATION ${CORPUS_PYTHON_TARGET_DIR}
CONFIGURATIONS "" Debug Release
)
View
6 corpus/leds.py
@@ -1,2 +1,6 @@
-import _leds
+try:
+ import _leds
+except ImportError:
+ import sys
+ print >>sys.stderr, "**** WARNING - no backend _leds module located ****"
View
12 corpus/sensors.py
@@ -1,15 +1,15 @@
import sys
-import _sensors
+try:
+ import _sensors
+except ImportError:
+ print >>sys.stderr,"**** WARNING - no backend _sensors module located ****"
+ _sensors = None
-if not hasattr(_sensors, "inst"):
+if _sensors and not hasattr(_sensors, "inst"):
raise ImportError("C++ _sensors backend is not initialized. Did you mean "
"to compile with USE_PYSENSORS_FAKE_BACKEND?")
-#class Sensors(_sensors.Sensors):
-# def __init__(self):
-# _sensors.Sensors.__init__(self, _sensors.inst)
-
def Sensors():
return _sensors.inst
View
12 motion/motion/MotionConstants.py → motion/MotionConstants.py
@@ -3,12 +3,12 @@
"""
# Import all hard-coded C++ constants from extension module
-from _motion import (WALK_STRAIGHT,
- WALK_SIDEWAYS,
- WALK_TURN,
- WALK_ARC,
- DEFAULT_SAMPLES_PER_STEP,
- )
+#from _motion import (WALK_STRAIGHT,
+# WALK_SIDEWAYS,
+# WALK_TURN,
+# WALK_ARC,
+# DEFAULT_SAMPLES_PER_STEP,
+# )
#currently, there are 40 ms time steps
View
0  motion/motion/SweetMoves.py → motion/SweetMoves.py
File renamed without changes
View
2  motion/__init__.py
@@ -0,0 +1,2 @@
+
+
View
61 motion/cmake.man.motion/CMakeLists.txt
@@ -105,7 +105,10 @@ IF( PYTHON_SHARED_MOTION AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" )
LIST( APPEND MOTION_SRCS ${MAN_INCLUDE_DIR}/Sensors )
ENDIF( PYTHON_SHARED_MOTION AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" )
-SET( MOTION_PYTHON_DIRS ${MOTION_INCLUDE_DIR}/motion )
+SET( MOTION_PYTHON_SRCS ${MOTION_INCLUDE_DIR}/__init__.py
+ ${MOTION_INCLUDE_DIR}/MotionConstants.py
+ ${MOTION_INCLUDE_DIR}/SweetMoves.py
+ )
SET( MOTION_TEST_DIR ${MOTION_INCLUDE_DIR}/test )
@@ -116,37 +119,35 @@ SET( MOTION_TEST_DIR ${MOTION_INCLUDE_DIR}/test )
GET_TARGET_PROPERTY( MOTION_LOCATION ${MOTION_TARGET} LOCATION )
-IF( ROBOT_NAO )
- IF( PYTHON_SHARED_MOTION )
- ADD_LIBRARY(
- ${MOTION_TARGET}
- SHARED
- ${MOTION_SRCS}
- )
- # Install to _motionmodule.so, instead of lib_motion.so
- GET_TARGET_PROPERTY(
- MOTION_TARGET_LOCATION ${MOTION_TARGET} LOCATION
- )
- INSTALL(
- FILES ${MOTION_TARGET_LOCATION}
- DESTINATION ${OUTPUT_ROOT_DIR_LIB}
- CONFIGURATIONS Debug
- RENAME ${MOTION_TARGET}module.so
- )
- ELSE( PYTHON_SHARED_MOTION )
- ADD_LIBRARY(
- ${MOTION_TARGET}
- STATIC
- ${MOTION_SRCS}
- )
- # No INSTALL target when static
- ENDIF( PYTHON_SHARED_MOTION )
-ENDIF( ROBOT_NAO )
+IF( PYTHON_SHARED_MOTION )
+ ADD_LIBRARY(
+ ${MOTION_TARGET}
+ SHARED
+ ${MOTION_SRCS}
+ )
+ # Install to _motionmodule.so, instead of lib_motion.so
+ GET_TARGET_PROPERTY(
+ MOTION_TARGET_LOCATION ${MOTION_TARGET} LOCATION
+ )
+ INSTALL(
+ FILES ${MOTION_TARGET_LOCATION}
+ DESTINATION ${MOTION_PYTHON_TARGET_DIR}
+ CONFIGURATIONS "" Debug Release
+ RENAME ${MOTION_TARGET}module.so
+ )
+ELSE( PYTHON_SHARED_MOTION )
+ ADD_LIBRARY(
+ ${MOTION_TARGET}
+ STATIC
+ ${MOTION_SRCS}
+ )
+ # No INSTALL target when static
+ENDIF( PYTHON_SHARED_MOTION )
+
INSTALL(
- DIRECTORY ${MOTION_PYTHON_DIRS}
- DESTINATION ${OUTPUT_ROOT_DIR_LIB}
+ FILES ${MOTION_PYTHON_SRCS}
+ DESTINATION ${MOTION_PYTHON_TARGET_DIR}
CONFIGURATIONS "" Debug Release
- PATTERN .svn EXCLUDE
)
INSTALL(
FILES ${MOTION_TEST_DIR}/test_motion.py
View
1  motion/motion/__init__.py → motion/walk.py
@@ -1,5 +1,4 @@
-
from _motion import (MotionInterface,
BodyJointCommand,
HeadJointCommand,
View
0  skull/__init__.py
No changes.
View
36 skull/noggin/noggin/Brain.py → skull/noggin/Brain.py
@@ -1,23 +1,25 @@
import time
-import comm
-import sensors
-import motion
-import motion.MotionConstants as MotionConstants
-import leds
-import robots
-import vision
-
-import players.Switch as Switch
-import NogginConstants as Constants
-import NaoOutput
-import EKF
-import TypeDefs
-import HeadTracking
-import GameController
-import Navigator
-import playBook.GoTeam as GoTeam
+# Packages and modules from super-directories
+from man import comm
+from man import motion
+from man.corpus import leds, sensors
+from man.motion import MotionConstants
+from man.skull import vision
+# Modules from this directory
+from . import EKF
+from . import GameController
+from . import HeadTracking
+from . import Navigator
+from . import NaoOutput
+from . import NogginConstants as Constants
+from . import TypeDefs
+# Packages and modules from sub-directories
+from . import robots
+from .playBook import GoTeam
+from .players import Switch
+
DEBUG_OBJS = False
DEBUG_LOC = False
View
9 skull/noggin/noggin/EKF.py → skull/noggin/EKF.py
@@ -4,7 +4,7 @@
"""
from math import pi, sin, cos, atan2, fabs, hypot, e, log
-from util.MyMath import sub180Angle, sub180Diff, dist, safe_atan2, sign
+
# Try to import the c++ matrix library. If this import fails,
# it means we are testing offline, so then use the python library.
@@ -12,13 +12,14 @@
import matrix
OFFLINE = False
except ImportError:
- import util.Matrix as matrix
+ from .util import Matrix as matrix
OFFLINE = True
#jf- whats the point of this? can we just remove all OFFLINE stuff?
OFFLINE = False
-import NogginConstants as Constants
-import motion.MotionConstants as MotionConstants
+from man.motion import MotionConstants
+from . import NogginConstants as Constants
+from .util.MyMath import sub180Angle, sub180Diff, dist, safe_atan2, sign
class EKF:
"""
View
9 skull/noggin/noggin/GameController.py → skull/noggin/GameController.py
@@ -1,10 +1,9 @@
-import util.FSA as FSA
+from man import comm
-import comm
-import NogginConstants as Constants
-
-import noggin.GameStates
+from . import NogginConstants as Constants
+from . import GameStates
+from .util import FSA
class GameController(FSA.FSA):
def __init__(self, brain):
View
0  skull/noggin/noggin/GameStates.py → skull/noggin/GameStates.py
File renamed without changes
View
6 skull/noggin/noggin/HeadTracking.py → skull/noggin/HeadTracking.py
@@ -1,7 +1,7 @@
-import util.FSA as FSA
-import TrackingStates
-#import PanningStates
+from . import TrackingStates
+#from . import PanningStates
+from .util import FSA
#constants need to go in another file.
#maybe auto generated on boot?
View
2  skull/noggin/Makefile
@@ -12,7 +12,7 @@ CMAKE_SRCS = \
nogginconfig.h
CMAKE_SRC := $(addprefix $(CMAKE_DIR),$(CMAKE_SRC))
CONFIG_FILE = nogginconfig.h
-SWITCH_FILE = noggin/players/Switch.py
+SWITCH_FILE = players/Switch.py
VISION_DIR = $(abspath $(CUR_DIR)/../vision)
TRUNK_REVISION = r0 #$(shell svn info | grep Revision | awk 'FS=" " {print $$2}')
View
0  skull/noggin/noggin/NaoOutput.py → skull/noggin/NaoOutput.py
File renamed without changes
View
0  skull/noggin/noggin/NavConstants.py → skull/noggin/NavConstants.py
File renamed without changes
View
4 skull/noggin/noggin/NavStates.py → skull/noggin/NavStates.py
@@ -1,7 +1,7 @@
''' States for finding our way on the field '''
-import motion
-import motion.MotionConstants as MotionConstants
+from man import motion
+from man.motion import MotionConstants
def nothing(nav):
return nav.stay()
View
8 skull/noggin/noggin/Navigator.py → skull/noggin/Navigator.py
@@ -1,7 +1,7 @@
-import util.FSA as FSA
-import util.MyMath as MyMath
-import NavStates
-import NavConstants
+from .util import FSA
+from .util import MyMath
+from . import NavStates
+from . import NavConstants
class Navigator(FSA.FSA):
def __init__(self,brain):
View
0  skull/noggin/noggin/NogginConstants.py → skull/noggin/NogginConstants.py
File renamed without changes
View
0  skull/noggin/noggin/PanningStates.py → skull/noggin/PanningStates.py
File renamed without changes
View
4 skull/noggin/noggin/TrackingStates.py → skull/noggin/TrackingStates.py
@@ -1,7 +1,7 @@
import math
-import motion as motionCore
-import motion.MotionConstants as MotionConstants
+from man import motion as motionCore
+from man.motion import MotionConstants
DEBUG = True
View
10 skull/noggin/noggin/TypeDefs.py → skull/noggin/TypeDefs.py
@@ -1,9 +1,15 @@
from math import fabs, radians, sin, cos
import time
-from util.MyMath import *
-import NogginConstants as Constants
+from .util.MyMath import (dist,
+ getRelativeBearing,
+ getRelativeVelocityX,
+ getRelativeVelocityY,
+ getRelativeX,
+ getRelativeY)
+
+from . import NogginConstants as Constants
class MyInfo:
'''
View
0  skull/noggin/__init__.py
No changes.
View
42 skull/noggin/cmake.noggin/CMakeLists.txt
@@ -85,8 +85,8 @@ CONFIGURE_FILE(
ESCAPE_QUOTES
)
CONFIGURE_FILE(
- "${NOGGIN_INCLUDE_DIR}/noggin/players/Switch.py.in"
- "${NOGGIN_INCLUDE_DIR}/noggin/players/Switch.py"
+ "${NOGGIN_INCLUDE_DIR}/players/Switch.py.in"
+ "${NOGGIN_INCLUDE_DIR}/players/Switch.py"
)
@@ -113,8 +113,26 @@ SET( NOGGIN_SRCS ${NOGGIN_INCLUDE_DIR}/Noggin.cpp
)
-SET( NOGGIN_PYTHON_DIRS ${NOGGIN_INCLUDE_DIR}/noggin
- ${NOGGIN_INCLUDE_DIR}/util )
+SET( NOGGIN_PYTHON_SRCS ${NOGGIN_INCLUDE_DIR}/__init__.py
+ ${NOGGIN_INCLUDE_DIR}/Brain.py
+ ${NOGGIN_INCLUDE_DIR}/EKF.py
+ ${NOGGIN_INCLUDE_DIR}/GameController.py
+ ${NOGGIN_INCLUDE_DIR}/GameStates.py
+ ${NOGGIN_INCLUDE_DIR}/HeadTracking.py
+ ${NOGGIN_INCLUDE_DIR}/PanningStates.py
+ ${NOGGIN_INCLUDE_DIR}/NaoOutput.py
+ ${NOGGIN_INCLUDE_DIR}/NavConstants.py
+ ${NOGGIN_INCLUDE_DIR}/NavStates.py
+ ${NOGGIN_INCLUDE_DIR}/Navigator.py
+ ${NOGGIN_INCLUDE_DIR}/NogginConstants.py
+ ${NOGGIN_INCLUDE_DIR}/TrackingStates.py
+ ${NOGGIN_INCLUDE_DIR}/TypeDefs.py
+ )
+
+SET( NOGGIN_PYTHON_SUBDIRS ${NOGGIN_INCLUDE_DIR}/playBook
+ ${NOGGIN_INCLUDE_DIR}/players
+ ${NOGGIN_INCLUDE_DIR}/robots
+ ${NOGGIN_INCLUDE_DIR}/util )
SET( NOGGIN_EXT_SRCS ${NOGGIN_INCLUDE_DIR}/_ext/comm.py
${NOGGIN_INCLUDE_DIR}/_ext/naovision.py
@@ -131,16 +149,20 @@ ADD_LIBRARY(
STATIC
${NOGGIN_SRCS}
)
+#INSTALL(
+# TARGETS ${NOGGIN_TARGET}
+# ARCHIVE DESTINATION ${OUTPUT_ROOT_DIR_LIB}
+# CONFIGURATIONS Debug
+# )
INSTALL(
- TARGETS ${NOGGIN_TARGET}
- ARCHIVE DESTINATION ${OUTPUT_ROOT_DIR_LIB}
- CONFIGURATIONS Debug
+ FILES ${NOGGIN_PYTHON_SRCS}
+ DESTINATION ${NOGGIN_PYTHON_TARGET_DIR}
+ CONFIGURATIONS "" Debug Release
)
INSTALL(
- DIRECTORY ${NOGGIN_PYTHON_DIRS}
- DESTINATION ${OUTPUT_ROOT_DIR_LIB}
+ DIRECTORY ${NOGGIN_PYTHON_SUBDIRS}
+ DESTINATION ${NOGGIN_PYTHON_TARGET_DIR}/
CONFIGURATIONS "" Debug Release
- PATTERN .svn EXCLUDE
)
INSTALL(
FILES ${NOGGIN_EXT_SRCS}
View
2  skull/noggin/noggin/players/Switch.py.in
@@ -1,2 +0,0 @@
-
-import ${PYTHON_PLAYER} as selectedPlayer
View
6 skull/noggin/noggin/playBook/Formations.py → skull/noggin/playBook/Formations.py
@@ -1,7 +1,7 @@
-import Roles
-import SubRoles
-import PBConstants
+from . import Roles
+from . import SubRoles
+from . import PBConstants
def fDefend(team):
"""
View
17 skull/noggin/noggin/playBook/GoTeam.py → skull/noggin/playBook/GoTeam.py
@@ -1,11 +1,18 @@
from math import fabs
-import potentialfield
-
-import PBDefs
-import PBConstants
-import Strategies
+try:
+ import potentialfield
+except ImportError:
+ import sys
+ print >>sys.stderr, '****************************************************'
+ print >>sys.stderr, '**** WARNING - no potentialfield module located ****'
+ print >>sys.stderr, '**** GoTeam module will FAIL upon running! ****'
+ print >>sys.stderr, '****************************************************'
+
+from . import PBDefs
+from . import PBConstants
+from . import Strategies
class GoTeam:
"""
View
2  skull/noggin/noggin/playBook/PBConstants.py → skull/noggin/playBook/PBConstants.py
@@ -2,7 +2,7 @@
File to hold all of the cross fiel constants for the cooperative behavior system
"""
-import noggin.NogginConstants as NogginConstants
+from .. import NogginConstants
# Test switches to force one role to always be given out
TEST_DEFENDER = False
View
4 skull/noggin/noggin/playBook/PBDefs.py → skull/noggin/playBook/PBDefs.py
@@ -1,7 +1,7 @@
from math import hypot
-import PBConstants
-import noggin.NogginConstants as NogginConstants
+from .. import NogginConstants
+from . import PBConstants
class Teammate:
'''class for keeping track of teammates' info'''
View
6 skull/noggin/noggin/playBook/Roles.py → skull/noggin/playBook/Roles.py
@@ -1,7 +1,7 @@
-import noggin.NogginConstants as NogginConstants
-import PBConstants
-import SubRoles
+from .. import NogginConstants
+from . import PBConstants
+from . import SubRoles
def rChaser(team):
"""
View
6 skull/noggin/noggin/playBook/Strategies.py → skull/noggin/playBook/Strategies.py
@@ -1,7 +1,7 @@
-import noggin.NogginConstants as NogginConstants
-import PBConstants
-import Formations
+from .. import NogginConstants
+from . import PBConstants
+from . import Formations
def sSpread(team):
'''
View
2  skull/noggin/noggin/playBook/SubRoles.py → skull/noggin/playBook/SubRoles.py
@@ -1,5 +1,5 @@
-import PBConstants
+from . import PBConstants
# SubRoles for ready state
def pReadyChaser(team):
View
0  skull/noggin/playBook/__init__.py
No changes.
View
5 skull/noggin/noggin/players/DistCalStates.py → skull/noggin/players/DistCalStates.py
@@ -10,10 +10,11 @@
"""
-import motion
-from sensors import inst as sensors
import math
+import man.motion as motion
+from man.corpus.sensors import inst as sensors
+
def nothing(player):
"""
Do nothing
View
4 skull/noggin/noggin/players/FirstGameStates.py → skull/noggin/players/FirstGameStates.py
@@ -2,8 +2,8 @@
import math
-import motion
-from sensors import inst as sensors
+import man.motion as motion
+from man.corpus.sensors import inst as sensors
###### PLAYER STATES ########
def player(player):
View
0  skull/noggin/noggin/players/KeyControlStates.py → skull/noggin/players/KeyControlStates.py
File renamed without changes
View
6 skull/noggin/noggin/players/NoneStates.py → skull/noggin/players/NoneStates.py
@@ -1,9 +1,9 @@
import math
-import motion
-import motion.SweetMoves as SweetMoves
-import motion.MotionConstants as MotionConstants
+import man.motion as motion
+import man.motion.SweetMoves as SweetMoves
+import man.motion.MotionConstants as MotionConstants
GOTO_BALL_REFIND_THRESH = 25
View
6 skull/noggin/noggin/players/SecondGameStates.py → skull/noggin/players/SecondGameStates.py
@@ -1,9 +1,9 @@
import math
-import motion
-import motion.SweetMoves as SweetMoves
-import motion.MotionConstants as MotionConstants
+import man.motion as motion
+from man.motion import SweetMoves
+from man.motion import MotionConstants
GOTO_BALL_REFIND_THRESH = 25
View
0  skull/noggin/noggin/players/StandupStates.py → skull/noggin/players/StandupStates.py
File renamed without changes
View
0  skull/noggin/noggin/players/SuzhouConstants.py → skull/noggin/players/SuzhouConstants.py
File renamed without changes
View
12 skull/noggin/noggin/players/SuzhouStates.py → skull/noggin/players/SuzhouStates.py
@@ -1,10 +1,12 @@
-import motion
#import sensors.inst as sensors
import math
-import noggin.NogginConstants as NogginConstants
-import SuzhouConstants as PlayerConstants
-import motion.MotionConstants as MotionConstants
-import motion.SweetMoves as SweetMoves
+
+import man.motion
+from man.motion import MotionConstants
+from man.motion import SweetMoves
+
+from .. import NogginConstants
+from . import SuzhouConstants as PlayerConstants
def initial(player):
return player.stay()
View
2  skull/noggin/players/Switch.py.in
@@ -0,0 +1,2 @@
+
+from . import ${PYTHON_PLAYER} as selectedPlayer
View
0  skull/noggin/noggin/players/TrackBallStates.py → skull/noggin/players/TrackBallStates.py
File renamed without changes
View
0  skull/noggin/noggin/players/WalkLearning.py → skull/noggin/players/WalkLearning.py
File renamed without changes
View
0  skull/noggin/noggin/players/__init__.py → skull/noggin/players/__init__.py
File renamed without changes
View
2  skull/noggin/noggin/players/pBalance.py → skull/noggin/players/pBalance.py
@@ -1,6 +1,6 @@
import code
-import motion
+import man.motion as motion
for var in nao.deviceNames:
globals()[var] = getattr(nao.motion, var)
View
4 skull/noggin/noggin/players/pControl.py → skull/noggin/players/pControl.py
@@ -1,7 +1,7 @@
-import util.FSA as FSA
+from ..util import FSA
-import KeyControlStates
+from . import KeyControlStates
class SoccerPlayer(FSA.FSA):
def __init__(self, brain):
View
0  skull/noggin/noggin/players/pDist.py → skull/noggin/players/pDist.py
File renamed without changes
View
4 skull/noggin/noggin/players/pFirstGame.py → skull/noggin/players/pFirstGame.py
@@ -1,7 +1,7 @@
-import util.FSA as FSA
-import FirstGameStates
+from ..util import FSA
+from . import FirstGameStates
class SoccerPlayer(FSA.FSA):
def __init__(self, brain):
View
0  skull/noggin/noggin/players/pKicker.py → skull/noggin/players/pKicker.py
File renamed without changes
View
7 skull/noggin/noggin/players/pNone.py → skull/noggin/players/pNone.py
@@ -1,8 +1,7 @@
-import util.FSA as FSA
-import motion
-
-import NoneStates
+import man.motion as motion
+from ..util import FSA
+from . import NoneStates
class SoccerPlayer(FSA.FSA):
def __init__(self, brain):
View
0  skull/noggin/noggin/players/pOldWalker.py → skull/noggin/players/pOldWalker.py
File renamed without changes
View
2  skull/noggin/noggin/players/pRexec.py → skull/noggin/players/pRexec.py
@@ -1,10 +1,10 @@
-import util.FSA as FSA
import errno
import socket
import sys
import traceback
+from ..util import FSA
class SoccerPlayer(FSA.FSA):
PORT = 4010
View
7 skull/noggin/noggin/players/pSecondGame.py → skull/noggin/players/pSecondGame.py
@@ -1,8 +1,7 @@
-import util.FSA as FSA
-import motion
-
-import SecondGameStates
+import man.motion as motion
+from ..util import FSA
+from . import SecondGameStates
class SoccerPlayer(FSA.FSA):
def __init__(self, brain):
View
5 skull/noggin/noggin/players/pStandup.py → skull/noggin/players/pStandup.py
@@ -1,8 +1,7 @@
import math
-import util.FSA as FSA
-
-import StandupStates
+from ..util import FSA
+from . import StandupStates
class SoccerPlayer(FSA.FSA):
def __init__(self, brain):
View
8 skull/noggin/noggin/players/pSuzhou.py → skull/noggin/players/pSuzhou.py
@@ -7,11 +7,11 @@
#
#
#
-import util.FSA as FSA
import math
-import SuzhouStates
-import util.MyMath as MyMath # For getting shooting pos
-import SuzhouConstants as PlayerConstants
+from ..util import FSA
+from ..util import MyMath # For getting shooting pos
+from . import SuzhouStates
+from . import SuzhouConstants as PlayerConstants
class SoccerPlayer(FSA.FSA):
def __init__(self,brain):
View
5 skull/noggin/noggin/players/pTracker.py → skull/noggin/players/pTracker.py
@@ -1,7 +1,6 @@
-import util.FSA as FSA
-
-import TrackBallStates
+from ..util import FSA
+from . import TrackBallStates
class SoccerPlayer(FSA.FSA):
def __init__(self, brain):
View
5 skull/noggin/noggin/players/pWalker.py → skull/noggin/players/pWalker.py
@@ -1,7 +1,6 @@
-import util.FSA as FSA
-
-import WalkLearning
+from ..util import FSA
+from . import WalkLearning
class SoccerPlayer(FSA.FSA):
def __init__(self, brain):
View
0  skull/noggin/noggin/robots/BirthCertificate.py → skull/noggin/robots/BirthCertificate.py
File renamed without changes
View
2  skull/noggin/noggin/robots/__init__.py → skull/noggin/robots/__init__.py
@@ -2,7 +2,7 @@
import socket
import os
-import BirthCertificate
+from . import BirthCertificate
marvin = BirthCertificate.BirthCertificate(
name='marvin',
View
0  skull/noggin/noggin/vision.py → skull/vision/__init__.py
File renamed without changes
View
9 skull/vision/cmake.vision/CMakeLists.txt
@@ -142,6 +142,8 @@ SET( VISION_SRCS ${VISION_INCLUDE_DIR}/Ball
#${VISION_INCLUDE_DIR}/Zlib
)
+SET( VISION_PYTHON_SRCS ${VISION_INCLUDE_DIR}/__init__.py )
+
############################ CHECK LIBRARY / EXECUTABLE OPTION
# Configure the output execuatable or shared library, and the install
@@ -159,7 +161,7 @@ IF( PYTHON_SHARED_VISION )
GET_TARGET_PROPERTY( VISION_TARGET_LOCATION ${VISION_TARGET} LOCATION )
INSTALL(
FILES ${VISION_TARGET_LOCATION}
- DESTINATION ${OUTPUT_ROOT_DIR_LIB}
+ DESTINATION ${VISION_PYTHON_TARGET_DIR}
CONFIGURATIONS "" Debug Release
RENAME ${ROBOT_PREFIX}${VISION_TARGET}module.so
)
@@ -173,6 +175,11 @@ ELSE( PYTHON_SHARED_VISION )
)
ENDIF( PYTHON_SHARED_VISION )
+INSTALL(
+ FILES ${VISION_PYTHON_SRCS}
+ DESTINATION ${VISION_PYTHON_TARGET_DIR}
+ CONFIGURATIONS "" Debug Release
+ )
############################ SET LIBRARIES TO LINK WITH
TARGET_LINK_LIBRARIES( ${VISION_TARGET} ${PYTHON_LIBRARIES} z )
Please sign in to comment.
Something went wrong with that request. Please try again.