FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
vrepSimulatorCache/objectCache.lua at master · Xoffio/vrepSimulatorCache · GitHub
Xoffio
/
vrepSimulatorCache
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
vrepSimulatorCache
/
objectCache.lua
Copy path
More file actions
More file actions
Latest commit
History
History
History
104 lines (81 loc) · 2.9 KB
Breadcrumbs
vrepSimulatorCache
/
objectCache.lua
Copy path
File metadata and controls
104 lines (81 loc) · 2.9 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
function
split
(
str
,
character
)
result
=
{}
index
=
1
for
s
in
string.gmatch
(
str
,
"
[^
"
..
character
..
"
]+
"
)
do
result
[
index
]
=
s
index
=
index
+
1
end
return
result
end
function
invAngle
(
a
)
local
maxV
=
180
local
result
=
maxV
-
a
if
(
result
<
0
)
then
result
=
result
*
-
1
end
return
result
end
function
sysCall_init
()
--
do some initialization here:
fileName
=
"
cacheSimulation.txt
"
listOfjoints
=
{
"
backRLeg_Joint01
"
,
"
backRLeg_Joint02
"
,
"
backRLeg_Joint03
"
,
"
backLLeg_Joint01
"
,
"
backLLeg_Joint02
"
,
"
backLLeg_Joint03
"
,
"
frontRLeg_Joint01
"
,
"
frontRLeg_Joint02
"
,
"
frontRLeg_Joint03
"
,
"
frontLLeg_Joint01
"
,
"
frontLLeg_Joint02
"
,
"
frontLLeg_Joint03
"
}
--
backRLeg= inv:txx, off:xxx; backLLeg= inv:fxt, off: txf; frontRLeg= inv:txx, off:xxx; frontLeftLeg= inv: fxt, off:txf
--
{ BR }{ BL }{ FR }{ FL }
invList
=
{
true
,
false
,
false
,
false
,
false
,
true
,
true
,
false
,
false
,
false
,
false
,
true
}
offsetList
=
{
100
,
0
,
0
,
100
,
0
,
0
,
100
,
0
,
0
,
100
,
0
,
0
}
handleList
=
{}
--
Open open a file in write mode
outFile
=
io.open
(
fileName
,
"
w
"
)
io.output
(
outFile
)
--
io.write("INIT\n")
--
Get joints handles
for
count
=
1
,
#
listOfjoints
,
1
do
handleList
[
count
]
=
sim
.
getObjectHandle
(
listOfjoints
[
count
])
end
--
handle = sim.getObjectHandle("backLLeg_Joint01")
end
function
sysCall_actuation
()
--
put your actuation code here
--
--
For example:
--
--
local position=sim.getObjectPosition(handle,-1)
--
position[1]=position[1]+0.001
--
sim.setObjectPosition(handle,-1,position)
end
function
sysCall_sensing
()
--
put your sensing code here
currentTime
=
sim
.
getSimulationTime
()
--
Get current simulation time
local
outLine
=
currentTime
--
Get joints angles
--
jointAngle = sim.getJointPosition(handle)
for
count
=
1
,
#
listOfjoints
,
1
do
--
local joint = math.floor(math.deg(sim.getJointPosition(handleList[count]) + 3) + 8.14)
local
joint
=
sim
.
getJointPosition
(
handleList
[
count
])
outLine
=
outLine
..
"
;
"
..
joint
end
--
io.write(currentTime .. ";" .. jointAngle .. "\n")
io.write
(
outLine
..
"
\n
"
)
end
function
sysCall_cleanup
()
--
do some clean-up here
io.close
(
outFile
)
outFile
=
io.open
(
fileName
,
"
r
"
)
cacheFile
=
io.open
(
fileName
:
gsub
(
"
.txt
"
,
"
.cache
"
),
"
w
"
)
io.output
(
cacheFile
)
for
line
in
outFile
:
lines
()
do
local
tmp
=
split
(
line
,
"
;
"
)
local
outLine
=
tmp
[
1
]
for
count
=
2
,
#
tmp
,
1
do
local
angle
=
0
angle
=
math.floor
(
math.deg
(
tmp
[
count
]
+
3
)
+
8.14
)
-
offsetList
[
count
-
1
]
if
(
invList
[
count
-
1
])
then
angle
=
invAngle
(
angle
)
end
outLine
=
outLine
..
"
;
"
..
angle
end
io.write
(
outLine
..
"
\n
"
)
end
io.close
(
outFile
)
io.close
(
cacheFile
)
end
Back
|
FazBrowse Home
|
New Git URL