-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e079bf
commit 6c5095c
Showing
6 changed files
with
928 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"cells": [], | ||
"metadata": {}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import time\n", | ||
"import numpy as np\n", | ||
"\n", | ||
"from pyluos import Device\n", | ||
"from glob import glob" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"-------------------------------------------------\n", | ||
"Type Alias ID \n", | ||
"-------------------------------------------------\n", | ||
"Gate r_head 1 \n", | ||
"ControlledMotor disk_top 2 \n", | ||
"ControlledMotor disk_middle 3 \n", | ||
"ControlledMotor disk_bottom 4 \n", | ||
"DynamixelMotor dxl_30 5 \n", | ||
"DynamixelMotor dxl_31 6 " | ||
] | ||
}, | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"io = Device(glob('/dev/cu.usbserial-*')[0])\n", | ||
"io.modules" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"(5.0, 0.0)" | ||
] | ||
}, | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"s = []\n", | ||
"\n", | ||
"for _ in range(1000):\n", | ||
" try:\n", | ||
" s.append(io._state['modules'].keys())\n", | ||
" except KeyError:\n", | ||
" print(io._state)\n", | ||
" time.sleep(0.01)\n", | ||
"\n", | ||
"l = [len(ss) for ss in s]\n", | ||
"l = np.array(l)\n", | ||
"\n", | ||
"l.mean(), l.std()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"defaultdict(int,\n", | ||
" {'disk_top': 1000,\n", | ||
" 'disk_middle': 1000,\n", | ||
" 'disk_bottom': 1000,\n", | ||
" 'dxl_30': 1000,\n", | ||
" 'dxl_31': 1000})" | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"from collections import defaultdict\n", | ||
"\n", | ||
"occ = defaultdict(int)\n", | ||
"\n", | ||
"for ss in s:\n", | ||
" for mod in ss:\n", | ||
" occ[mod] += 1\n", | ||
" \n", | ||
"occ" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"{'modules': {'disk_top': {'rot_position': 109.16},\n", | ||
" 'disk_middle': {'rot_position': 158.0},\n", | ||
" 'disk_bottom': {'rot_position': 6.206},\n", | ||
" 'dxl_30': {'rot_position': 0.147},\n", | ||
" 'dxl_31': {'rot_position': -150.0}},\n", | ||
" 'timestamp': 1595842274.621845}" | ||
] | ||
}, | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"io._state" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Oops, something went wrong.