Skip to content

Commit e58564d

Browse files
committed
new traaining data
1 parent 3d89208 commit e58564d

File tree

84 files changed

+104
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+104
-45
lines changed

GymEnvironments/P10-RL-SingleJoint/P10_DRL_Mark_SingleJoint/envs/P10_DRL_Mark_SingleJointEnv.py

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
class P10_DRL_Mark_SingleJointEnv(gym.Env):
2626

2727
def __init__(self):
28-
28+
29+
30+
31+
2932
random.seed(1)
3033
self.id = "SAC - " + str(datetime.now())[:-7].replace(':','_') + '_P10_MarkEnv_SingleJoint - all joints'
3134
#self.id = '2021-04-15 09_44_43_SAC_P10_MarkEnv_SingleJoint_'
@@ -35,21 +38,21 @@ def __init__(self):
3538
self.TIME_STEP = int(self.supervisor.getBasicTimeStep())
3639
self.robot_node = self.supervisor.getFromDef("UR3")
3740
self.goal_node = self.supervisor.getFromDef("TARGET").getField("translation")
38-
39-
self.tcpx = self.supervisor.getFromDef("x")
41+
4042
self.tcpy = self.supervisor.getFromDef("y")
41-
self.tcpz = self.supervisor.getFromDef("z")
43+
self.tcpy2 = self.supervisor.getFromDef("y2")
44+
4245

43-
self.goalx = self.supervisor.getFromDef("goalx")
4446
self.goaly = self.supervisor.getFromDef("goaly")
45-
self.goalz = self.supervisor.getFromDef("goalz")
47+
self.goaly2 = self.supervisor.getFromDef("goaly2")
4648

47-
49+
4850
self.tcp = self.supervisor.getFromDef('TCP')
4951
self.robot_pos = np.array(self.robot_node.getPosition())
5052

51-
self.timeout = 300
53+
self.timeout = 1500
5254

55+
5356
self.joint_names = ['shoulder_pan_joint', 'shoulder_lift_joint', 'elbow_joint', 'wrist_1_joint', 'wrist_2_joint', 'wrist_3_joint']
5457
#self.joint_names = ['shoulder_pan_joint', 'shoulder_lift_joint', 'elbow_joint', 'wrist_1_joint', 'wrist_2_joint', 'wrist_3_joint']
5558

@@ -82,10 +85,12 @@ def __init__(self):
8285
self.distancez = 0
8386
self.tcp_pos_world = self.tcp.getPosition()
8487
self.counter = 0
85-
88+
89+
90+
8691
self.actionScale = 3
8792
self.action_space = spaces.Box(low=-1, high=1, shape=(len(self.joint_names),), dtype=np.float32)
88-
self.observation_space = spaces.Box(low=-10, high=10, shape=(33,), dtype=np.float32)
93+
self.observation_space = spaces.Box(low=-10, high=10, shape=(26,), dtype=np.float32)
8994

9095
self.documentation = "Action space: all joints State space: tcp pos (xyz), target pos (xyz), joint positions ."
9196
self.documentation += "{} - Rewards {} - Timeout at {}\n".format(self.id, self.rewardstr, str(self.timeout))
@@ -102,19 +107,17 @@ def reset(self):
102107
self.supervisor.simulationReset()
103108
self.counter = 0
104109

105-
self._getMotors()
106110
self._getSensors()
107-
111+
self._getMotors()
108112
self.supervisor.step(self.TIME_STEP)
109113

110114
self.supervisor.step(self.TIME_STEP)
111115
self.goal_node.setSFVec3f(self.target)
112116
self.supervisor.step(self.TIME_STEP)
113117
self.total_rewards = 0
114118
self.done = False
115-
self.prevdistx = distance.euclidean(self.tcpx.getPosition(), self.goalx.getPosition())
116119
self.prevdisty = distance.euclidean(self.tcpy.getPosition(), self.goaly.getPosition())
117-
self.prevdistz = distance.euclidean(self.tcpz.getPosition(), self.goalz.getPosition())
120+
self.prevdisty2 = distance.euclidean(self.tcpy2.getPosition(), self.goaly2.getPosition())
118121
state = self.getState()
119122
return np.asarray(state)
120123

@@ -123,7 +126,6 @@ def step(self, action):
123126
#print(self.counter)
124127

125128
self._getMotors()
126-
self._getSensors()
127129
for i in range(len(self.joint_names)):
128130
self.motors[i].setVelocity(float(action[i]))
129131

@@ -134,21 +136,19 @@ def step(self, action):
134136
state = self.getState()
135137

136138

137-
distDifferencex = self.prevdistx - self.distancex
138139
distDifferencey = self.prevdisty - self.distancey
139-
distDifferencez = self.prevdistz - self.distancez
140+
distDifferencey2 = self.prevdisty2 - self.distancey2
140141

141142

142143

143144

144145
#print(self.distance)
145-
self.prevdistx = self.distancex
146146
self.prevdisty = self.distancey
147-
self.prevdistz = self.distancez
147+
self.prevdisty2 = self.distancey2
148148
#print("Distance: {}".format(np.linalg.norm(np.array(self.tcp.getPosition()) - self.robot_pos)))
149149

150150
# Normalize the distance by the maximum robot reach so it's between 0 and 1
151-
reward = (self.distanceDeltaReward * distDifferencex) + (self.distanceDeltaReward * distDifferencey) + (self.distanceDeltaReward * distDifferencez) + self.constPunishment
151+
reward = (self.distanceDeltaReward * distDifferencey) + (self.distanceDeltaReward * distDifferencey2) #+ self.constPunishment
152152
#print(self.total_rewards)
153153
self.counter = self.counter + 1
154154

@@ -157,7 +157,7 @@ def step(self, action):
157157
print("Timeout")
158158
self.done = True
159159
self._setTarget()
160-
if self.distancex < 0.05 and self.distancey < 0.05 and self.distancez < 0.05:
160+
if self.distancey < 0.01 and self.distancey2 < 0.01:
161161
self.epOutcome = "Success"
162162
print("Success")
163163
self._setTarget()
@@ -209,14 +209,17 @@ def _getMotors(self):
209209

210210
def _setTarget(self):
211211
# generate a point around the circle 0.75m far from the robot, making sure it's far away
212-
distance = 0
213-
while distance <= 0.2 :
214-
x = random.choice([random.uniform(-0.4, -0.3), random.uniform(0.3, 0.4)])
215-
z = random.choice([random.uniform(-0.4, -0.3), random.uniform(0.3, 0.4)])
216-
y = random.uniform(0.1, 0.3)
212+
213+
214+
positions = [[-0.4, -0.2, 0, 0.2, 0.4], [0.4, 0.425, 0.45]]
215+
216+
x = positions[0][random.randint(0, 4)]
217+
218+
z = positions[1][random.randint(0, 2)]
219+
y = 0.15
217220

218-
self.target = list(self.robot_pos + np.array([x, y, z]))
219-
distance = np.linalg.norm(np.array(self.tcp.getPosition()) - self.target)
221+
self.target = list(self.robot_pos + np.array([x, y, z]))
222+
220223

221224
self.goal_node.setSFVec3f(self.target)
222225

@@ -232,10 +235,9 @@ def saveEpisode(self, reward):
232235
def getState(self):
233236

234237

235-
self.distancex = distance.euclidean(self.tcpx.getPosition(), self.goalx.getPosition())
236238
self.distancey = distance.euclidean(self.tcpy.getPosition(), self.goaly.getPosition())
237-
self.distancez = distance.euclidean(self.tcpz.getPosition(), self.goalz.getPosition())
238-
return [self.sensors[i].getValue() for i in range(len(self.sensors))] + [self.motors[i].getVelocity() for i in range(len(self.motors))] + self.tcpx.getPosition() + self.tcpy.getPosition() + self.tcpz.getPosition() + self.goalx.getPosition() + self.goaly.getPosition() + self.goalz.getPosition() + [self.distancex, self.distancey, self.distancez]
239+
self.distancey2 = distance.euclidean(self.tcpy2.getPosition(), self.goaly2.getPosition())
240+
return [self.sensors[i].getValue() for i in range(len(self.sensors))] + [self.motors[i].getVelocity() for i in range(len(self.motors))] + self.tcpy.getPosition() + self.tcpy2.getPosition() + self.goaly.getPosition() + self.goaly2.getPosition() + [self.distancey, self.distancey2]
239241
#return self.tcp.getPosition() + self.target
240242

241243

controllers/experiment/tmp.jpg

299 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Action space: all joints State space: tcp pos (xyz), target pos (xyz), joint positions .SAC - 2021-05-11 12_44_51_P10_MarkEnv_SingleJoint - all joints - Rewards success 1000, collision -300 distance 100 - Timeout at 800
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Action space: all joints State space: tcp pos (xyz), target pos (xyz), joint positions .SAC - 2021-05-11 12_45_15_P10_MarkEnv_SingleJoint - all joints - Rewards success 1000, collision -300 distance 100 - Timeout at 800
2+
-8;-37;1;77;77;-280;-223;66;-235;69;-194;-195;-258;-233;43;37;83;67;121;104;89;112;105;97;118;123;115;139;131;82;88;113;115;77;114;115;118;132;136;104;146;122;109;121;160;145;154;130;1177;136;182;106;132;114;146;110;160;101;112;126;1120;113;101;95;138;138;128;106;125;121;1124;141;134;125;109;130;128;1128;144;157;115;117;122;140;101;116;124;114;126;154;164;114;162;111;116;123;103;144;1127;101;147;151;89;134;121;128;132;185;130;113;133;139;1122;95;135;153;113;100;106;158;1143;146;114;132;132;142;140;143;140;146;1131;1132;134;123;155;157;150;139;1148;114;85;148;66;102;160;35;135;149;112;80;-206;134;-252;143;150;167;112;152;1170;100;-232;-228;139;-211;123;-215;119;150;135;1147;123;157;122;126;82;102;125;162;1149;1129;134;133;113;101;105;145;113;145;137;157;1140;123;141;138;133;1126;122;122;153;1142;134;111;1142;155;97;108;134;1125;147;144;137;141;145;112;145;1137;139;148;1130;127;100;118;1143;126;120;126;149;127;1139;148;1135;1138;125;133;126;139;146;110;1131;96;136;137;118;118;132;134;100;156;129;1124;150;123;1136;165;116;106;126;139;144;1141;148;116;158;122;107;102;134;114;113;144;123;130;105;144;149;141;121;140;158;1151;144;125;102;103;118;1138;114;137;1141;148;148;127;123;119;142;143;139;126;131;106;103;130;138;144;149;137;1126;1157;116;140;120;157;155;99;107;123;1148;160;117;1155;116;164;1152;169;144;1134;122;130;119;162;132;110;128;126;149;122;151;119;143;100;125;138;129;131;155;120;121;128;162;128;121;138;129;133;154;138;151;121;122;147;1124;135;128;126;1133;163;152;141;137;143;126;122;1122;156;130;1122;138;117;137;100;134;136;141;123;161;161;137;102;127;1132;128;97;136;1133;132;135;123;1123;129;102;143;128;102;136;130;136;124;149;156;128;154;122;117;134;112;124;114;154;1142;114;126;115;137;144;168;1160;120;127;136;132;138;113;129;156;131;1154;125;118;138;169;1124;125;156;1152;152;118;164;129;1130;144;1150;113;132;115;121;114;153;157;138;1125;1135;127;164;135;158;125;123;1150;1165;1159;132;110;1157;147;121;101;109;141;124;129;130;1127;1145;119;154;141;122;117;125;134;157;1131;129;138;154;128;157;152;152;140;109;153;115;152;1151;160;1121;159;129;1156;1153;157;129;118;159;136;134;125;99;139;154;129;131;136;123;125;111;129;121;129;146;140;1134;1142;141;114;137;1150;132;154;149;107;111;135;147;145;157;133;143;106;160;143;1145;123;126;145;160;118;121;152;117;129;154;149;146;151;134;156;132;143;1144;156;139;138;148;133;152;154;148;145;150;1146;135;130;121;151;99;116;141;134;152;128;133;124;159;1140;110;163;116;1157;1124;129;170;1153;1160;153;161;176;150;1163;111;118;131;154;161;1170;165;144;132;131;124;142;149;144;1142;125;145;143;159;129;1154;123;123;130;1144;1153;1145;118;161;125;111;1133;152;1127;143;1147;135;135;120;119;144;159;127;155;152;154;145;1141;1142;169;1150;1129;150;1134;134;1141;121;128;108;138;102;147;145;143;112;1145;149;159;146;159;142;157;121;153;1144;138;1137;1145;128;148;153;139;90;144;1128;1143;140;145;91;1147;116;1154;165;1132;1134;1138;117;160;106;159;1142;162;147;110;133;155;158;128;1124;157;1129;156;1135;136;1148;139;158;160;146;143;144;116;108;158;138;1129;145;159;157;113;123;126;117;128;135;129;166;123;118;124;126;145;146;116;141;138;1134;1131;124;144;99;142;138;101;1140;113;1139;166;148;121;1133;111;131;157;159;123;118;129;160;1116;163;1139;166;133;117;110;152;124;132;129;128;1157;102;137;1125;152;116;139;130;1129;143;1125;164;136;155;1119;154;125;1134;144;1121;168;124;128;125;138;135;162;144;128;138;1134;97;125;147;128;159;145;1142;133;149;145;140;163;127;164;130;147;152;155;127;143;134;118;100;168;134;164;123;163;141;139;162;132;167;141;1131;168;147;153;120;126;138;120;109;119;122;1131;101;166;1132;128;100;128;160;118;120;108;113;120;1130;158;125;148;154;136;119;125;112;117;122;160;141;107;137;160;108;158;1125;150;105;136;130;106;122;114;1128;130;1139;147;123;163;103;130;129;150;1133;159;1132;146;128;127;1141;141;147;141;138;141;159;1135;1123;155;133;125;140;117;153;123;159;150;115;118;159;1127;157;140;122;138;116;1122;134;1142;101;1129;149;118;136;1138;113;1122;146;130;120;1123;1142;132;126;149;137;107;151;153;151;145;116;147;104;1141;1125;128;170;165;135;115;160;128;125;123;122;1122;157;151;157;128;149;162;138;1123;167;161;124;121;115;131;115;150;125;115;1125;143;142;1152;119;1141;117;148;140;121;110;149;105;1137;115;148;147;160;162;1149;131;152;153;119;168;138;133;163;171;1150;131;126;120;160;162;107;1141;108;132;164;128;114;161;159;148;118;152;159;138;179;162;117;131;148;130;101;147;161;126;1146;141;164;133;133;155;157;140;1143;134;112;126;129;135;156;123;166;117;133;134;151;1126;139;118;158;145;165;121;126;1135;162;161;164;161;160;155;148;147;158;146;1134;1139;164;130;1129;1129;1135;1136;108;121;131;161;143;159;156;130;164;154;133;155;134;1144;1149;1153;158;116;174;128;1157;113;131;1141;147;1147;119;1123;1156;118;179;133;1139;150;153;153;144;1153;159;138;118;152;164;104;1136;108;163;152;149;1165;156;1124;155;140;112;168;131;157;168;152;121;130;168;135;116;112;178;110;1121;158;168;112;161;157;128;153;160;108;123;1164;132;174;131;148;134;136;104;136;1135;1175;1147;1137;168;120;132;124;150;131;130;141;167;1167;1130;157;172;1154;1161;160;133;111;130;1164;137;139;114;134;107;1148;1178;1151;127;1128;108;117;149;182;123;110;144;137;141;116;99;1126;159;129;122;118;1142;175;159;148;124;1183;1136;139;1126;1175;151;130;1178;122;139;117;123;114;110;1128;128;127;125;1134;155;156;127;173;111;120;123;119;126;1132;155;133;136;144;152;1142;126;1137;1132;1141;156;114;137;133;147;1140;140;1124;152;-123;160;165;135;124;1143;137;1126;133;109;1132;1132;140;126;159;126;142;125;1132;116;151;151;136;108;126;156;112;153;144;152;108;119;120;149;163;1127;121;123;111;123;117;117;147;132;1121;104;1126;129;104;114;112;164;151;96;1132;139;137;161;103;133;119;123;142;160;134;147;1127;172;1136;1131;156;143;144;154;113;159;1122;141;1131;120;1143;154;120;115;1128;1148;124;133;148;128;157;117;113;149;1127;110;1124;160;1151;135;136;152;161;117;1131;165;173;139;159;144;1139;129;155;109;129;168;157;1155;146;137;143;1166;1170;119;146;119;1175;114;141;152;122;143;122;109;130;1132;164;132;1144;103;1145;125;110;168;107;-123;153;1127;143;116;159;132;1166;1157;1140;143;141;97;130;128;127;1134;1147;1123;1183;147;153;142;168;1146;113;1126;153;1144;118;160;104;128;105;111;155;131;112;119;170;1120;130;146;1189;165;1149;1142;95;1141;1130;139;140;168;156;1168;1138;131;134;155;134;167;1144;145;110;164;145;176;1161;110;1142;1151;168;1173;1147;155;117;174;1135;128;1182;158;133;170;1152;1150;104;1164;123;1138;94;133;149;153;99;110;105;132;1145;152;153;107;145;138;129;1121;123;1171;144;113;111;1152;1142;-144;125;146;156;1139;1127;1150;156;111;125;133;122;117;1136;142;125;102;137;1133;135;138;116;130;120;168;1177;1137;135;156;153;134;1139;113;1122;141;128;149;1135;1139;124;130;98;133;155;147;161;149;149;1134;149;1129;124;158;146;149;149;120;-136;1151;137;104;92;157;129;143;1161;1147;155;1139;155;141;1144;110;166;1139;1127;1138;158;156;116;129;1127;131;169;1148;157;116;1135;1153;1160;1124;1132;167;1147;88;1158;1160;141;128;1132;1128;1157;1126;102;153;-133;152;146;-142;161;122;136;127;165;1143;1151;138;155;142;108;161;1169;111;109;163;115;1134;156;127;123;146;145;-139;139;142;149;114;1130;159;142;141;126;112;1158;1148;119;122;1145;148;1128;1135;117;149;-131;120;119;156;116;128;131;152;100;116;107;128;154;1125;1134;1123;126;141;157;119;135;127;-146;132;142;142;98;118;134;107;119;-139;135;133;141;157;139;133;124;129;110;128;118;124;136;1142;1168;107;148;135;123;119;116;156;111;152;1133;1147;154;152;164;94;1138;146;150;151;1161;128;121;119;118;115;119;141;118;116;130;112;104;1124;1148;122;135;151;165;132;113;130;111;103;-135;107;122;136;135;136;134;1138;150;102;146;153;147;149;164;142;140;115;167;155;163;115;128;160;-127;-127;106;137;157;127;157;1156;137;101;129;137;111;142;113;154;131;117;1147;1143;1166;112;97;136;102;1135;1169;153;1122;121;172;126;108;162;135;1144;151;124;138;1136;130;97;1159;119;153;140;-119;160;1147;1140;144;116;170;135;1128;-131;160;147;125;150;109;160;163;107;136;158;124;159;118;135;123;155;133;1133;130;146;125;131;148;113;147;123;119;129;139;163;119;-124;149;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Action space: all joints State space: tcp pos (xyz), target pos (xyz), joint positions .SAC - 2021-05-11 14_24_02_P10_MarkEnv_SingleJoint - all joints - Rewards success 1000, collision -300 distance 100 - Timeout at 800
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Action space: all joints State space: tcp pos (xyz), target pos (xyz), joint positions .SAC - 2021-05-11 14_24_05_P10_MarkEnv_SingleJoint - all joints - Rewards success 1000, collision -300 distance 100 - Timeout at 800
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Action space: all joints State space: tcp pos (xyz), target pos (xyz), joint positions .SAC - 2021-05-11 14_24_15_P10_MarkEnv_SingleJoint - all joints - Rewards success 1000, collision -300 distance 100 - Timeout at 2000
2+
-38;-194;-236;-162;-261;-289;63;87;130;96;88;122;71;94;129;75;107;71;133;114;134;78;120;137;121;116;90;128;111;118;71;90;92;105;104;116;113;126;88;-254;101;125;112;111;148;139;149;138;157;126;168;73;118;86;145;86;147;91;123;129;92;106;100;106;140;127;132;113;1155;115;70;1153;121;119;91;1143;113;100;131;-172;108;106;109;126;95;113;114;112;111;123;147;104;132;116;93;135;90;139;91;104;131;129;85;135;106;1158;1133;130;123;101;131;1144;77;85;-211;112;98;87;102;-192;115;109;104;1149;113;130;136;134;1158;130;102;100;1145;87;-174;-182;-191;-193;112;99;95;132;86;1132;146;108;119;133;108;119;117;111;104;114;134;132;101;120;126;99;110;113;130;1117;115;105;1130;138;124;107;122;136;111;117;91;105;116;139;126;1118;1132;1136;1120;100;1132;122;99;109;1143;135;104;118;120;126;116;107;119;113;133;121;121;110;117;152;83;110;119;1124;134;137;128;140;138;101;140;112;132;135;1128;117;74;106;120;98;107;1136;131;112;112;158;116;115;1135;122;110;128;137;102;101;86;134;1138;107;104;114;129;97;152;117;95;138;1130;104;152;80;98;104;135;143;1139;138;114;151;116;117;73;99;108;94;129;117;121;95;134;147;144;117;144;154;128;1158;89;90;92;98;1135;113;113;91;136;142;104;117;102;127;138;128;1133;117;88;82;117;1153;143;1154;131;96;137;105;1147;101;153;156;86;104;96;125;160;118;1154;103;151;1149;156;135;106;99;110;106;160;105;100;109;114;1165;98;150;110;135;88;120;1154;110;126;150;111;116;122;164;111;123;134;132;123;169;144;167;99;110;140;102;1144;1134;122;93;164;1163;140;132;131;114;118;95;154;110;92;139;103;118;96;117;124;129;115;161;159;124;100;123;110;116;91;114;114;122;1141;115;85;116;67;135;112;69;1140;1144;122;110;139;135;1143;135;106;97;130;88;1144;98;135;113;109;117;106;121;1155;154;135;105;119;128;114;131;105;114;144;133;124;1142;97;1139;154;108;114;149;115;138;1132;148;1124;1130;123;119;107;111;110;107;91;140;137;131;101;105;116;155;132;140;109;1136;121;141;131;100;89;137;135;90;82;105;130;102;128;1135;87;119;106;156;127;116;96;105;119;141;1130;104;135;1163;1155;149;146;147;1153;89;142;100;143;129;148;81;145;123;127;1143;149;86;102;152;125;126;119;83;137;146;1142;115;115;77;1133;96;113;109;105;144;1151;109;110;1151;86;110;1141;95;142;137;94;94;1138;1157;136;143;120;135;52;160;137;111;119;115;136;150;79;81;143;103;88;144;156;142;1166;125;1170;123;134;113;157;103;97;124;113;1164;140;1167;139;1166;120;115;118;104;140;95;107;119;121;129;107;118;109;147;115;97;151;109;131;96;118;148;114;129;1159;138;166;139;1162;89;97;110;133;152;1167;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Action space: all joints State space: tcp pos (xyz), target pos (xyz), joint positions .SAC - 2021-05-11 15_09_53_P10_MarkEnv_SingleJoint - all joints - Rewards success 1000, collision -300 distance 100 - Timeout at 2000

0 commit comments

Comments
 (0)