Skip to content

Make necessary changes for Python 3 in joint_control #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions joint_control/add_training_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"\n",
"pose_name = 'Back'\n",
"data_file = path.join('robot_pose_data', pose_name)\n",
"data = pickle.load(open(data_file))"
"data = pickle.load(open(data_file, 'rb'))"
]
},
{
Expand All @@ -102,7 +102,7 @@
}
],
"source": [
"print data"
"print(data)"
]
},
{
Expand All @@ -122,7 +122,7 @@
"source": [
"new_data = [0, 0, 0, 0, 0, 0, 0, 0, 0, -1.5707963267948966]\n",
"data.append(new_data)\n",
"pickle.dump(data, open(data_file, 'w'))"
"pickle.dump(data, open(data_file, 'wb'))"
]
},
{
Expand Down
12 changes: 6 additions & 6 deletions joint_control/keyframes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'''Keyframes from Aldebaran
'''

from leftBackToStand import leftBackToStand
from leftBellyToStand import leftBellyToStand
from rightBackToStand import rightBackToStand
from rightBellyToStand import rightBellyToStand
from keyframes.leftBackToStand import leftBackToStand
from keyframes.leftBellyToStand import leftBellyToStand
from keyframes.rightBackToStand import rightBackToStand
from keyframes.rightBellyToStand import rightBellyToStand

from hello import hello
from wipe_forehead import wipe_forehead
from keyframes.hello import hello
from keyframes.wipe_forehead import wipe_forehead
50 changes: 32 additions & 18 deletions joint_control/learn_posture.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
}
],
"source": [
"classes = listdir(ROBOT_POSE_DATA_DIR)\n",
"print classes"
"classes = sorted(listdir(ROBOT_POSE_DATA_DIR))\n",
"print(classes)"
]
},
{
Expand All @@ -103,7 +103,7 @@
" # YOUR CODE HERE\n",
" \n",
" filename = path.join(ROBOT_POSE_DATA_DIR, classes[i])\n",
" data = pickle.load(open(filename))\n",
" data = pickle.load(open(filename, 'rb'))\n",
" target = [i] * len(data)\n",
" return data, target"
]
Expand All @@ -119,7 +119,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"total number of data 200\n"
"Loaded 222 items\n"
]
}
],
Expand All @@ -129,21 +129,35 @@
"all_target = []\n",
"# YOUR CODE HERE\n",
"\n",
"print 'total number of data', len(all_data)"
"print(f\"Loaded {len(all_data)} items\")"
]
},
{
"cell_type": "code",
"execution_count": 86,
"metadata": {
"collapsed": false
},
"outputs": [],
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Using 155 items for training and 67 for testing\n"
]
}
],
"source": [
"# shuffule data\n",
"# shuffle data\n",
"permutation = np.random.permutation(len(all_data))\n",
"shuffled_data = [all_data[i] for i in permutation]\n",
"shuffled_target = [all_target[i] for i in permutation]\n",
"n_training_data = int(len(all_data) * 0.7)\n",
"training_data = permutation[:n_training_data]"
"\n",
"training_data = shuffled_data[:n_training_data]\n",
"training_target = shuffled_target[:n_training_data]\n",
"testing_data = shuffled_data[n_training_data:]\n",
"testing_target = shuffled_target[n_training_data:]\n",
"\n",
"print(f\"Using {len(training_data)} items for training and {len(testing_data)} for testing\")"
]
},
{
Expand Down Expand Up @@ -214,7 +228,7 @@
{
"data": {
"text/plain": [
"(array([10]), 10)"
"(array([10]), [10])"
]
},
"execution_count": 58,
Expand All @@ -223,7 +237,7 @@
}
],
"source": [
"clf.predict(all_data[-1]), all_target[-1]"
"clf.predict(all_data[-1:]), all_target[-1:]"
]
},
{
Expand Down Expand Up @@ -370,7 +384,7 @@
"source": [
"import pickle\n",
"ROBOT_POSE_CLF = 'robot_pose.pkl'\n",
"pickle.dump(clf, open(ROBOT_POSE_CLF, 'w'))"
"pickle.dump(clf, open(ROBOT_POSE_CLF, 'wb'))"
]
},
{
Expand All @@ -390,7 +404,7 @@
{
"data": {
"text/plain": [
"(array([10]), 10)"
"(array([10]), [10])"
]
},
"execution_count": 71,
Expand All @@ -399,8 +413,8 @@
}
],
"source": [
"clf2 = pickle.load(open(ROBOT_POSE_CLF))\n",
"clf2.predict(all_data[-1]), all_target[-1]"
"clf2 = pickle.load(open(ROBOT_POSE_CLF, 'rb'))\n",
"clf2.predict(all_data[-1:]), all_target[-1:]"
]
},
{
Expand Down
2 changes: 0 additions & 2 deletions software_installation/sexpr.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#!/usr/bin/env python
##
## sexpr.py - by Yusuke Shinyama
##
## * public domain *
##
import future

## AbstractFilter
##
Expand Down