-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefine_robot.py
137 lines (113 loc) · 3.97 KB
/
define_robot.py
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
import pyrosim_modded.pyrosim_modded as pyrosim
def define_robot(body_size: int, leg_size: int):
pyrosim.Send_Cube(
name="torso",
pos=[0, 0, body_size],
size=[body_size,body_size, 0.5*body_size])
create_right_back_leg(body_size, 2*leg_size)
create_right_front_leg(body_size, 2*leg_size)
create_left_back_leg(body_size, 2*leg_size)
create_left_front_leg(body_size, 2*leg_size)
def create_right_back_leg(body_size: int, leg_size: int):
pyrosim.Send_Joint(
name="torso_rightbackcoxa",
parent="torso",
child="rightbackcoxa",
type="revolute",
position=[0.5*body_size, -.4*body_size, body_size],
axis=[0, 1, 0])
pyrosim.Send_Cube(
name="rightbackcoxa",
pos=[0.1*body_size, 0, 0],
size=[.2*body_size, .2*body_size, .1*body_size])
pyrosim.Send_Joint(
name="rightbackcoxa_rightbackfemur",
parent="rightbackcoxa",
child="rightbackfemur",
type="revolute",
position=[0.2*body_size, 0, 0],
axis=[0, 0, 1])
pyrosim.Send_Cube(
name="rightbackfemur",
pos=[0.5*leg_size, 0, 0],
size=[leg_size, .2*body_size, .2*body_size])
# pyrosim.Send_Joint(
# name="rightbackfemur_rightbacktibia",
# parent="rightbackfemur",
# child="rightbacktibia",
# type="revolute",
# position=[leg_size, 0, 0],
# axis=[0, 1, 0])
# pyrosim.Send_Cube(
# name="rightbacktibia",
# pos=[0, 0, -0.5*body_size],
# size=[.4*body_size, .4*body_size, body_size])
def create_right_front_leg(body_size: int, leg_size: int):
pyrosim.Send_Joint(
name="torso_rightfrontcoxa",
parent="torso",
child="rightfrontcoxa",
type="revolute",
position=[0.5*body_size, .4*body_size, body_size],
axis=[0, 1, 0])
pyrosim.Send_Cube(
name="rightfrontcoxa",
pos=[0.1*body_size, 0, 0],
size=[.2*body_size, .2*body_size, .1*body_size])
pyrosim.Send_Joint(
name="rightfrontcoxa_rightfrontfemur",
parent="rightfrontcoxa",
child="rightfrontfemur",
type="revolute",
position=[0.2*body_size, 0, 0],
axis=[0, 0, 1])
pyrosim.Send_Cube(
name="rightfrontfemur",
pos=[0.5*leg_size, 0, 0],
size=[leg_size, .2*body_size, .2*body_size])
def create_left_back_leg(body_size: int, leg_size: int):
pyrosim.Send_Joint(
name="torso_leftbackcoxa",
parent="torso",
child="leftbackcoxa",
type="revolute",
position=[-0.5*body_size, -.4*body_size, body_size],
axis=[0, 1, 0])
pyrosim.Send_Cube(
name="leftbackcoxa",
pos=[-0.1*body_size, 0, 0],
size=[.2*body_size, .2*body_size, .1*body_size])
pyrosim.Send_Joint(
name="leftbackcoxa_leftbackfemur",
parent="leftbackcoxa",
child="leftbackfemur",
type="revolute",
position=[-0.2*body_size, 0, 0],
axis=[0, 0, 1])
pyrosim.Send_Cube(
name="leftbackfemur",
pos=[-0.5*leg_size, 0, 0],
size=[leg_size, .2*body_size, .2*body_size])
def create_left_front_leg(body_size: int, leg_size: int):
pyrosim.Send_Joint(
name="torso_leftfrontcoxa",
parent="torso",
child="leftfrontcoxa",
type="revolute",
position=[-0.5*body_size, .4*body_size, body_size],
axis=[0, 1, 0])
pyrosim.Send_Cube(
name="leftfrontcoxa",
pos=[-0.1*body_size, 0, 0],
size=[.2*body_size, .2*body_size, .1*body_size])
pyrosim.Send_Joint(
name="leftfrontcoxa_leftfrontfemur",
parent="leftfrontcoxa",
child="leftfrontfemur",
type="revolute",
position=[-0.2*body_size, 0, 0],
axis=[0, 0, 1])
pyrosim.Send_Cube(
name="leftfrontfemur",
pos=[-0.5*leg_size, 0, 0],
size=[leg_size, .2*body_size, .2*body_size])