-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinclude.lua
More file actions
131 lines (94 loc) · 3.45 KB
/
include.lua
File metadata and controls
131 lines (94 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
-- (c) 2014 Stephen McGill
-- Include script to be run at the top of each file
-- This mainly sets the paths
-- It also adds very useful globals
if DONE_INCLUDE then return end
math.randomseed(10)
-- Locate the Modules
--CWD = assert(os.getenv'PWD','No PWD variable set!')
CWD= os.getenv'PWD'
CWD=CWD or '/home/sj/Desktop/ARAICodes' --TEMPORARY HACK
IS_WEBOTS = false
HOME = CWD:gsub('sur','UPennDev')
HOME = HOME:gsub('Player.*$','')
HOME = HOME:gsub('Run.*$','')
HOME = HOME:gsub('Robots.*$','')
HOME = HOME:gsub('Operate.*$','')
HOME = HOME:gsub('Modules.*$','')
HOME = HOME:gsub('Tools.*$','')
HOME = HOME:gsub('Util.*$','')
HOME = HOME:gsub('LibUtil.*$','')
HOME = HOME:gsub('Test.*$','')
if HOME:find'Webots' ~= nil then
HOME = HOME:gsub('Webots.*$','')
IS_WEBOTS = true
--print('Current path',package.path)
package.path = './?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua'
end
-- Useful constants
DEG_TO_RAD = math.pi / 180
RAD_TO_DEG = 180 / math.pi
-- SJ: This removes the output buffer
io.stdout:setvbuf'no'
-- include C modules to cpath
-- For copying to the Nao and just dumping into one directory
--package.cpath = HOME..'/Lib/?.so;'..package.cpath
-- getch.so is in Modules/getch/ (Modules/unix/unix.so -> Modules/?/?.so)
package.cpath = HOME..'/Modules/?/?.so;'..package.cpath
-- Sometimes there are helper lua files (even for ffi, but still experimental)
package.path = HOME..'/Modules/?.lua;'..package.path
-- include Lua utilities to path
package.path = HOME..'/Util/?.lua;'..package.path
-- include Lua utilities to path
package.path = HOME..'/LibUtil/?.lua;'..package.path
-- include Shared Memory files to path
package.path = HOME..'/Memory/?.lua;'..package.path
-- include Robot Agnostic wrappers
--package.path = HOME..'/Player/Run/?.lua;'..package.path
-- include World files to the path
--package.path = HOME..'/Player/World/?.lua;'..package.path
-- include Vision files to the path
--package.path = HOME..'/Player/Vision/?.lua;'..package.path
-- include Config files to path
package.path = HOME..'/Config/?.lua;'..package.path
-- include Player wizards for webots require
--package.path = HOME..'/Player/?.lua;'..package.path
package.path = HOME..'/Run/?.lua;'..package.path
-- include test scripts to path
package.path = HOME..'/Test/?.lua;'..package.path
-- Unix should be global; the ffi.lua file provides a fallback
unix = require'unix.ffi'
-- Save the hostname
HOSTNAME = unix.gethostname()
--print("HOSTNAME:",HOSTNAME)
OPERATING_SYSTEM = unix.uname():lower()
-- Some other directories
KEYFRAME_DIR = HOME.."/Player/Keyframes"
LOG_DIR = HOME.."/Logs"
-- Use functional idioms
--require "fun" ()
-- include platform specific modules
require'Config'
PLATFORM_NAME = Config.PLATFORM_NAME
ROBOT_HOME = HOME..'/Robots/'..PLATFORM_NAME
package.path = ROBOT_HOME..'/?.lua;'..package.path
package.cpath = ROBOT_HOME..'/?.so;'..package.cpath
DONE_INCLUDE = true
collectgarbage()
-- Print out the globally available variables, when using include.lua
--[[
function print_env()
print( 'Working Dir:', CWD )
print( 'Home Dir:', HOME )
print( 'Operating Sys:', OPERATING_SYSTEM )
print( 'Host:', HOSTNAME )
print( 'Webots:', IS_WEBOTS )
print( 'Child thread:', IS_CHILD )
print( 'Platform:', Config.PLATFORM_NAME )
print( 'Keyframes directory:', KEYFRAME_DIR )
print( 'package path:', package.path )
print( 'package cpath:', package.cpath )
end
print_env()
--]]
return Config