computecol_free.py 3.17 KB
Newer Older
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
from hpp.corbaserver.rbprm.rbprmbuilder import Builder
from hpp.gepetto import Viewer
from hpp.corbaserver.rbprm.problem_solver import ProblemSolver
import sys

#~ print sys.args

rootJointType = 'freeflyer'
packageName = 'hpp-rbprm-corba'
meshPackageName = 'hpp-rbprm-corba'
urdfNameTested = 'hrp2_trunk_flexible'
urdfNameRoms =  ['hrp2_larm_rom','hrp2_rarm_rom','hrp2_lleg_rom','hrp2_rleg_rom']
urdfSuffix = ""
srdfSuffix = ""


scene = sys.argv[len(sys.argv)-1]

tested = Builder ()
tested.loadModel(urdfNameTested, urdfNameRoms, rootJointType, meshPackageName, packageName, urdfSuffix, srdfSuffix)


#~ tested.setNormalFilter('hrp2_lleg_rom', [0,0,1], 0.9)
#~ tested.setFilter(['hrp2_lleg_rom','hrp2_rleg_rom'])

ps = ProblemSolver( tested )
r = Viewer (ps)
r.loadObstacleModel (packageName, scene, "planning")
tested.setJointBounds ("base_joint_xyz", [-10.,10,-10,10,0,20])
ps.client.problem.selectConFigurationShooter("RbprmShooter")

q_init = tested.getCurrentConfig ();
q_init [0:3] = [-10, -0.82, 1.25]; tested.setCurrentConfig (q_init); r (q_init)
q_goal = q_init [::]
q_goal [0:3] = [-9, -0.65, 1.25]; r (q_goal)

ps.setInitialConfig (q_init)
ps.addGoalConfig (q_goal)
t = ps.solve ()

res = {}
x_start = 0
y_start = 0
x_max = 2
y_max = 1.64
iter_step = 0.01

res = {}
x_start = -1.5
y_start = 0
x_max = 2.84
y_max = 2.65
iter_step = 0.01

res = {}

import numpy as np

nbStepsX = int((x_max - x_start) / iter_step)
nbStepsY = int((y_max - y_start) / iter_step)

x_t = []
y_t = []

for x in np.linspace(x_start,x_max, num=nbStepsX):
	ys = {}
	for y in np.linspace(y_start,y_max, num=nbStepsY):
		q = q_init
		q[0] = x
		q[1] = -0.82
		q[1] = 0
		q[2] = y
		if (tested.isReachable(q)):
			x_t.append(x)
			y_t.append(y)
			ys[y] = True
	res[x] = ys

x_t.append(0)
y_t.append(0) #for scale

#~ x_t.append(0.25)
#~ y_t.append(0)
#~ 
#~ x_t.append(0.3)
#~ y_t.append(0.15)
#~ x_t.append(0.6)
#~ y_t.append(0.15)
#~ 
#~ x_t.append(0.6)
#~ y_t.append(0.30)
#~ x_t.append(0.9)
#~ y_t.append(0.30)
#~ 
#~ x_t.append(0.9)
#~ y_t.append(0.45)
#~ x_t.append(1.2)
#~ y_t.append(0.45)
#~ 
#~ x_t.append(1.2)
#~ y_t.append(0.6)
#~ x_t.append(1.80)
#~ y_t.append(0.6)
#~ 
#~ x_t.append(0.4)
#~ y_t.append(0.81)
#~ x_t.append(2)
#~ y_t.append(1.6)

#~ x_t.append(2.5)
#~ y_t.append(2.65) #for scale
#~ 
#~ x_t.append(-1.5)
#~ y_t.append(0) #for scale

#~ x_t.append(-0.87)
#~ y_t.append(0.2) #for scale
#~ x_t.append(-0.67)
#~ y_t.append(0.2) #for scale
#~ 
#~ x_t.append(-0.23)
#~ y_t.append(0.4) #for scale
#~ x_t.append(-0.03)
#~ y_t.append(0.4) #for scale
#~ 
#~ x_t.append(0.77)
#~ y_t.append(0.6) #for scale
#~ x_t.append(0.97)
#~ y_t.append(0.6) #for scale
#~ 
#~ x_t.append(2.2)
#~ y_t.append(1) #for scale
#~ x_t.append(2.4)
#~ y_t.append(1) #for scale
#~ 
#~ x_t.append(0.62)
#~ y_t.append(2.35) #for scale
#~ x_t.append(1.12)
#~ y_t.append(2.35) #for scale


import pickle
sFile = "creach_2DGrid_"+scene+'.pkl'
output = open(sFile, 'wb')
pickle.dump(res, output)
output.close()

q[2] = y_t[0]
q[0] = x_t[0]
r(q)


import numpy as np
import matplotlib.pyplot as plt

#~ plt.scatter(x_t, y_t, s=170, marker='s', edgecolors='none')
plt.scatter(x_t, y_t, edgecolors='none')
#~ plt.scatter(x_t, y_t ,color ='c', edgecolors='none')
plt.show()