Skip to content

Commit 129a96d

Browse files
rename module to container
1 parent e8b561e commit 129a96d

32 files changed

+157
-155
lines changed

.github/ISSUE_TEMPLATE/bug-report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ assignees: nicolas-rabault
1111
A clear and concise description of what the bug is.
1212

1313
**Network configuration**
14-
- Add the routing table or list the nodes and their modules
14+
- Add the routing table or list the nodes and their containers
1515
- Power input configuration
1616

1717
**How to reproduce the bug**

examples/IMU.ipynb

+9-9
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@
8787
"renderer.shadowMap.type = 'PCFSoftShadowMap'\n",
8888
"display(renderer)\n",
8989
"\n",
90-
"# Connect your Luos network (here using an USB module)\n",
90+
"# Connect your Luos network (here using an USB container)\n",
9191
"r = Device('/dev/cu.usbserial-DN2JWZ3D')\n",
92-
"print(r.modules)\n",
92+
"print(r.containers)\n",
9393
"\n",
9494
"# Control the rotation of the cube with the rotation of the Imu sensor\n",
9595
"while(True):\n",
@@ -109,7 +109,7 @@
109109
"traceback": [
110110
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
111111
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
112-
"\u001b[0;32m<ipython-input-1-e5d253194cbc>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mIPython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdisplay\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdisplay\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0mr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mRobot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'/dev/cu.usbserial-DN38OIYT'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmodules\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
112+
"\u001b[0;32m<ipython-input-1-e5d253194cbc>\u001b[0m in \u001b[0;36m<container>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mIPython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdisplay\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdisplay\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0mr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mRobot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'/dev/cu.usbserial-DN38OIYT'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcontainers\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
113113
"\u001b[0;32m~/Documents/luos/pyluos/pyluos/robot.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, host, IO, log_conf, test_mode, *args, **kwargs)\u001b[0m\n\u001b[1;32m 58\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 59\u001b[0m self._io = io_from_host(host=host,\n\u001b[0;32m---> 60\u001b[0;31m *args, **kwargs)\n\u001b[0m\u001b[1;32m 61\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 62\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexists\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlog_conf\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
114114
"\u001b[0;32m~/Documents/luos/pyluos/pyluos/io/__init__.py\u001b[0m in \u001b[0;36mio_from_host\u001b[0;34m(host, *args, **kwargs)\u001b[0m\n\u001b[1;32m 55\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mcls\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mhost\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mhost\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 56\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 57\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'No corresponding IO found (among {}).'\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdiscover_hosts\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 58\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 59\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
115115
"\u001b[0;31mValueError\u001b[0m: No corresponding IO found (among <function discover_hosts at 0x10a2f7d90>)."
@@ -124,7 +124,7 @@
124124
"from IPython.display import display\n",
125125
"\n",
126126
"r = Robot('/dev/cu.usbserial-DN38OIYT')\n",
127-
"r.modules\n",
127+
"r.containers\n",
128128
"\n",
129129
"cube = Mesh(\n",
130130
" BoxBufferGeometry(3, 3, 3),\n",
@@ -180,7 +180,7 @@
180180
{
181181
"data": {
182182
"text/plain": [
183-
"<function pyluos.modules.imu.Imu.control.<locals>.change_config(accel, gyro, quat, compass, euler, rot_mat, pedo, linear_accel, gravity_vector, heading)>"
183+
"<function pyluos.containers.imu.Imu.control.<locals>.change_config(accel, gyro, quat, compass, euler, rot_mat, pedo, linear_accel, gravity_vector, heading)>"
184184
]
185185
},
186186
"execution_count": 2,
@@ -191,7 +191,7 @@
191191
"name": "stdout",
192192
"output_type": "stream",
193193
"text": [
194-
"{'modules': defaultdict(<function Robot._setup.<locals>.<lambda> at 0x11949f2f0>, {'Imu_mod': defaultdict(<function Robot._setup.<locals>.<lambda>.<locals>.<lambda> at 0x1122a5158>, {'imu_enable': 4})})}\n"
194+
"{'containers': defaultdict(<function Robot._setup.<locals>.<lambda> at 0x11949f2f0>, {'Imu_mod': defaultdict(<function Robot._setup.<locals>.<lambda>.<locals>.<lambda> at 0x1122a5158>, {'imu_enable': 4})})}\n"
195195
]
196196
},
197197
{
@@ -233,7 +233,7 @@
233233
"name": "stdout",
234234
"output_type": "stream",
235235
"text": [
236-
"{'modules': defaultdict(<function Robot._setup.<locals>.<lambda> at 0x10daaff28>, {'Imu_mod': defaultdict(<function Robot._setup.<locals>.<lambda>.<locals>.<lambda> at 0x10b22f598>, {'imu_enable': 4})})}\n"
236+
"{'containers': defaultdict(<function Robot._setup.<locals>.<lambda> at 0x10daaff28>, {'Imu_mod': defaultdict(<function Robot._setup.<locals>.<lambda>.<locals>.<lambda> at 0x10b22f598>, {'imu_enable': 4})})}\n"
237237
]
238238
},
239239
{
@@ -279,7 +279,7 @@
279279
"text": [
280280
"[False, False, False, False, False, False, False, True, False, False]\n",
281281
"[True, False, False, False, False, False, False, True, False, False]\n",
282-
"{'modules': defaultdict(<function Robot._setup.<locals>.<lambda> at 0x116670268>, {'Imu_mod': defaultdict(<function Robot._setup.<locals>.<lambda>.<locals>.<lambda> at 0x1166706a8>, {'imu_enable': 516})})}\n"
282+
"{'containers': defaultdict(<function Robot._setup.<locals>.<lambda> at 0x116670268>, {'Imu_mod': defaultdict(<function Robot._setup.<locals>.<lambda>.<locals>.<lambda> at 0x1166706a8>, {'imu_enable': 516})})}\n"
283283
]
284284
}
285285
],
@@ -363,7 +363,7 @@
363363
"name": "stdout",
364364
"output_type": "stream",
365365
"text": [
366-
"{'modules': defaultdict(<function Robot._setup.<locals>.<lambda> at 0x113732048>, {'Imu_mod': defaultdict(<function Robot._setup.<locals>.<lambda>.<locals>.<lambda> at 0x10c537510>, {'imu_enable': 132})})}\n"
366+
"{'containers': defaultdict(<function Robot._setup.<locals>.<lambda> at 0x113732048>, {'Imu_mod': defaultdict(<function Robot._setup.<locals>.<lambda>.<locals>.<lambda> at 0x10c537510>, {'imu_enable': 132})})}\n"
367367
]
368368
},
369369
{

examples/tools/Benchmark.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"import numpy as np\n",
3333
"\n",
3434
"device = Device('/dev/cu.usbserial-DN2JWZ3D')\n",
35-
"print(device.modules)\n",
35+
"print(device.containers)\n",
3636
" \n",
3737
"def plot_test_cmplt(baudrate_vector, results):\n",
3838
" fig1 = plt.figure(1)\n",

examples/tools/Motor_PID.ipynb

+69-69
Original file line numberDiff line numberDiff line change
@@ -15,105 +15,105 @@
1515
"import numpy as np\n",
1616
"from scipy.interpolate import interp1d\n",
1717
"\n",
18-
"# 1. Connect your Luos network (here using an USB module for example)\n",
18+
"# 1. Connect your Luos network (here using an USB container for example)\n",
1919
"r = Device('/dev/cu.usbserial-DN05NM1N')\n",
20-
"print(r.modules)\n",
20+
"print(r.containers)\n",
2121
"\n",
22-
"# 2. Select the module of your network you need to configure\n",
23-
"module = r.controlled_moto\n",
22+
"# 2. Select the container of your network you need to configure\n",
23+
"container = r.controlled_moto\n",
2424
"\n",
25-
"# 3. Setup module basic settings\n",
26-
"module.encoder_res = 3\n",
27-
"module.reduction = 210.59\n",
25+
"# 3. Setup container basic settings\n",
26+
"container.encoder_res = 3\n",
27+
"container.reduction = 210.59\n",
2828
"\n",
29-
"SAMPLERATE = 1.0/module.sampling_freq\n",
29+
"SAMPLERATE = 1.0/container.sampling_freq\n",
3030
"\n",
3131
"def run_speed_test(velocity_target):\n",
32-
" module.rot_position = False\n",
33-
" module.rot_speed = True\n",
34-
" module.current = True\n",
35-
" module.rot_position_mode = False\n",
36-
" module.rot_speed_mode = True\n",
37-
" module.target_rot_speed = 0.0\n",
38-
" module.compliant = False\n",
32+
" container.rot_position = False\n",
33+
" container.rot_speed = True\n",
34+
" container.current = True\n",
35+
" container.rot_position_mode = False\n",
36+
" container.rot_speed_mode = True\n",
37+
" container.target_rot_speed = 0.0\n",
38+
" container.compliant = False\n",
3939
" target = []\n",
4040
" real = []\n",
4141
" current = []\n",
4242
" test_time_vector = []\n",
4343
" test_start_time = time.time()\n",
44-
" target.append(module.target_rot_speed)\n",
45-
" real.append(module.rot_speed)\n",
46-
" current.append(module.current)\n",
44+
" target.append(container.target_rot_speed)\n",
45+
" real.append(container.rot_speed)\n",
46+
" current.append(container.current)\n",
4747
" test_time = time.time()\n",
4848
" test_time_vector.append(0.0)\n",
4949
" while (test_time < test_start_time + 0.5):\n",
5050
" time.sleep(SAMPLERATE)\n",
51-
" target.append(module.target_rot_speed)\n",
52-
" real.append(module.rot_speed)\n",
53-
" current.append(module.current)\n",
51+
" target.append(container.target_rot_speed)\n",
52+
" real.append(container.rot_speed)\n",
53+
" current.append(container.current)\n",
5454
" test_time_vector.append(test_time - test_start_time)\n",
5555
" test_time = time.time()\n",
56-
" module.target_rot_speed = velocity_target\n",
56+
" container.target_rot_speed = velocity_target\n",
5757
" while (test_time < test_start_time + 2.5):\n",
5858
" time.sleep(SAMPLERATE)\n",
59-
" target.append(module.target_rot_speed)\n",
60-
" real.append(module.rot_speed)\n",
61-
" current.append(module.current)\n",
59+
" target.append(container.target_rot_speed)\n",
60+
" real.append(container.rot_speed)\n",
61+
" current.append(container.current)\n",
6262
" test_time_vector.append(test_time - test_start_time)\n",
6363
" test_time = time.time()\n",
64-
" module.compliant = True\n",
64+
" container.compliant = True\n",
6565
" plot_test(test_time_vector, target, real, current)\n",
6666
"\n",
6767
"def run_pos_test(pos_target):\n",
68-
" module.rot_speed = False\n",
69-
" module.rot_position = True\n",
70-
" module.current = True\n",
71-
" module.rot_speed_mode = False\n",
72-
" module.rot_position_mode = True\n",
73-
" module.target_rot_position = 0.0\n",
74-
" module.compliant = False\n",
68+
" container.rot_speed = False\n",
69+
" container.rot_position = True\n",
70+
" container.current = True\n",
71+
" container.rot_speed_mode = False\n",
72+
" container.rot_position_mode = True\n",
73+
" container.target_rot_position = 0.0\n",
74+
" container.compliant = False\n",
7575
" target = []\n",
7676
" real = []\n",
7777
" current = []\n",
7878
" test_time_vector = []\n",
7979
" test_start_time = time.time()\n",
80-
" target.append(module.target_rot_position)\n",
81-
" real.append(module.rot_position)\n",
82-
" current.append(module.current)\n",
80+
" target.append(container.target_rot_position)\n",
81+
" real.append(container.rot_position)\n",
82+
" current.append(container.current)\n",
8383
" test_time = time.time()\n",
8484
" test_time_vector.append(0.0)\n",
8585
" while (test_time < test_start_time + 1):\n",
8686
" time.sleep(SAMPLERATE)\n",
87-
" target.append(module.target_rot_position)\n",
88-
" real.append(module.rot_position)\n",
89-
" current.append(module.current)\n",
87+
" target.append(container.target_rot_position)\n",
88+
" real.append(container.rot_position)\n",
89+
" current.append(container.current)\n",
9090
" test_time_vector.append(test_time - test_start_time)\n",
9191
" test_time = time.time()\n",
92-
" module.target_rot_position = pos_target\n",
92+
" container.target_rot_position = pos_target\n",
9393
" while (test_time < test_start_time + 2.5):\n",
9494
" time.sleep(SAMPLERATE)\n",
95-
" target.append(module.target_rot_position)\n",
96-
" real.append(module.rot_position)\n",
97-
" current.append(module.current)\n",
95+
" target.append(container.target_rot_position)\n",
96+
" real.append(container.rot_position)\n",
97+
" current.append(container.current)\n",
9898
" test_time_vector.append(test_time - test_start_time)\n",
9999
" test_time = time.time()\n",
100100
" \n",
101101
" # create a smooth trajectory\n",
102102
" moveduration = 2\n",
103103
" keypoints = np.array([90, 4, -10, -33, -87, -87, 10, -80, 0])\n",
104104
" x = np.linspace(0, 1, keypoints.shape[-1], endpoint=True)\n",
105-
" traj = interp1d(x, keypoints, 'cubic')(np.linspace(0, 1, int(moveduration*module.sampling_freq)))\n",
105+
" traj = interp1d(x, keypoints, 'cubic')(np.linspace(0, 1, int(moveduration*container.sampling_freq)))\n",
106106
" #send traj to motor\n",
107-
" module.target_rot_position = traj\n",
107+
" container.target_rot_position = traj\n",
108108
" # wait a bit for the motor to start\n",
109109
" time.sleep(0.03)\n",
110110
" traj_start_time = time.time()\n",
111111
" for i, sample in enumerate(traj):\n",
112112
" target.append(sample)\n",
113-
" real.append(module.rot_position)\n",
114-
" current.append(module.current)\n",
113+
" real.append(container.rot_position)\n",
114+
" current.append(container.current)\n",
115115
" test_time_vector.append(test_time - test_start_time)\n",
116-
" #time.sleep(1.0/module.sampling_freq)\n",
116+
" #time.sleep(1.0/container.sampling_freq)\n",
117117
" while(time.time() < traj_start_time + SAMPLERATE*(i+1)):\n",
118118
" time.sleep(0.004)\n",
119119
" test_time = time.time()\n",
@@ -122,11 +122,11 @@
122122
" while (test_time < traj_start_time + 0.5):\n",
123123
" time.sleep(SAMPLERATE)\n",
124124
" target.append(traj[len(traj)-1])\n",
125-
" real.append(module.rot_position)\n",
126-
" current.append(module.current)\n",
125+
" real.append(container.rot_position)\n",
126+
" current.append(container.current)\n",
127127
" test_time_vector.append(test_time - test_start_time)\n",
128128
" test_time = time.time()\n",
129-
" module.compliant = True\n",
129+
" container.compliant = True\n",
130130
" plot_test(test_time_vector, target, real, current)\n",
131131
"\n",
132132
"def plot_test(test_time_vector, target, real, current):\n",
@@ -149,26 +149,26 @@
149149
" \n",
150150
"#motor wiring test\n",
151151
"def wiring_test():\n",
152-
" module.setToZero()\n",
153-
" module.power_mode = True\n",
154-
" module.compliant = False\n",
155-
" module.power_ratio = 100.0\n",
152+
" container.setToZero()\n",
153+
" container.power_mode = True\n",
154+
" container.compliant = False\n",
155+
" container.power_ratio = 100.0\n",
156156
" time.sleep(0.5)\n",
157-
" module.power_ratio = 0\n",
158-
" module.compliant = True\n",
159-
" if (module.rot_position > 1):\n",
157+
" container.power_ratio = 0\n",
158+
" container.compliant = True\n",
159+
" if (container.rot_position > 1):\n",
160160
" print(\"Connection OK\")\n",
161-
" module.encoder_res = 3\n",
162-
" module.reduction = 150.0\n",
163-
" module.positionPid = [4.0,0.02,100] # position PID [P, I, D]\n",
164-
" module.setToZero()\n",
161+
" container.encoder_res = 3\n",
162+
" container.reduction = 150.0\n",
163+
" container.positionPid = [4.0,0.02,100] # position PID [P, I, D]\n",
164+
" container.setToZero()\n",
165165
" time.sleep(0.1)\n",
166-
" module.rot_position_mode = True\n",
167-
" module.compliant = False\n",
168-
" module.target_rot_position = 90\n",
166+
" container.rot_position_mode = True\n",
167+
" container.compliant = False\n",
168+
" container.target_rot_position = 90\n",
169169
" time.sleep(1)\n",
170-
" module.compliant = True\n",
171-
" if (module.rot_position > 80) :\n",
170+
" container.compliant = True\n",
171+
" if (container.rot_position > 80) :\n",
172172
" print (\"Sensor direction OK\")\n",
173173
" print (\"Motor OK\")\n",
174174
" else : \n",
@@ -194,7 +194,7 @@
194194
"outputs": [],
195195
"source": [
196196
"# Speed settings\n",
197-
"module.speedPid = [0.1,0.1,1.0] # speed PID [P, I, D]\n",
197+
"container.speedPid = [0.1,0.1,1.0] # speed PID [P, I, D]\n",
198198
"run_speed_test(200.0)"
199199
]
200200
},
@@ -207,7 +207,7 @@
207207
"outputs": [],
208208
"source": [
209209
"# position settings\n",
210-
"module.positionPid = [3.0, 0.02, 90] # position PID [P, I, D]\n",
210+
"container.positionPid = [3.0, 0.02, 90] # position PID [P, I, D]\n",
211211
"run_pos_test(90.0)"
212212
]
213213
}

pyluos/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22

33
from .device import Device
4-
from .modules import *
4+
from .containers import *
55

66
nh = logging.NullHandler()
77
logging.getLogger(__name__).addHandler(nh)

pyluos/containers/angle.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .module import Container
1+
from .container import Container
22

33

44
class Angle(Container):

pyluos/containers/color.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .module import Container, interact
1+
from .container import Container, interact
22
import numpy as np
33

44

pyluos/containers/container.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ def _update(self, new_state):
6464

6565
def _kill(self):
6666
self._killed = True
67-
print ("module", self.alias, "have been excluded from the network due to no responses.")
67+
print ("container", self.alias, "have been excluded from the network due to no responses.")
6868

6969
def _push_value(self, key, new_val):
7070
if (self._killed) :
71-
print("module", self.alias,"is excluded.")
71+
print("container", self.alias,"is excluded.")
7272
else :
7373
if isinstance(new_val, float) :
7474
self._delegate.update_cmd(self.alias, key, float(str("%.3f" % new_val)))
@@ -77,7 +77,7 @@ def _push_value(self, key, new_val):
7777

7878
def _push_data(self, key, new_val, data):
7979
if (self._killed) :
80-
print("module", self.alias,"is excluded.")
80+
print("container", self.alias,"is excluded.")
8181
else :
8282
self._delegate.update_data(self.alias, key, new_val, data)
8383

0 commit comments

Comments
 (0)