Completed the robots URDF tutorials and notes

This commit is contained in:
levdoescode
2022-12-09 17:35:20 -05:00
parent 88344f8b52
commit 58e84c2fb8
17 changed files with 2520 additions and 0 deletions

View File

@ -0,0 +1,139 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "43832635-49f6-45d0-9a5f-14d4d634731d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pybullet as p\n",
"p.connect(p.GUI)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "e374f315-b9ab-42d1-b33d-518c74f95c43",
"metadata": {},
"outputs": [],
"source": [
"floor_shape = p.createCollisionShape(p.GEOM_PLANE)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "f844a0fb-efa5-4461-9589-31ba09f526b8",
"metadata": {},
"outputs": [],
"source": [
"floor = p.createMultiBody(floor_shape, floor_shape) #(vision geometry, collision geometry)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "fb392ce2-d95b-4481-9246-08ca71adeb12",
"metadata": {},
"outputs": [],
"source": [
"# Create a new geometry, box instead of a plane\n",
"box_shape = p.createCollisionShape(p.GEOM_BOX, halfExtents = [1, 1, 1])"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "c50db6e4-d784-4924-8751-da704e376352",
"metadata": {},
"outputs": [],
"source": [
"box = p.createMultiBody(box_shape, box_shape) #create a box at (0.0.0)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "857c7c29-7bf0-486b-8aa4-9deb5e0a76e5",
"metadata": {},
"outputs": [],
"source": [
"p.setGravity(0, 0, -10) #(x, z, y) forces\n",
"p.setRealTimeSimulation(1)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "c6c09422-92f2-4eef-8c22-55fb86c1c1b0",
"metadata": {},
"outputs": [],
"source": [
"box_object1 = p.createMultiBody(box_shape,box_shape)\n",
"box_object2 = p.createMultiBody(box_shape,box_shape)\n",
"p.resetBasePositionAndOrientation(box_object1, [0, -1, 2], [0, 0, 0, 1])\n",
"p.resetBasePositionAndOrientation(box_object2, [0, 1, 2], [0, 0, 0, 1])\n",
"p.setGravity(0, 0, -10)\n",
"p.setRealTimeSimulation(1)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "e3e857c9-d3e4-4028-8abf-3ad25b4cbc63",
"metadata": {},
"outputs": [],
"source": [
"fruits = [p.createMultiBody(box_shape,box_shape)] * 9\n",
"for index in range(9):\n",
" p.resetBasePositionAndOrientation(fruits[index], [index, index * 3, 4], [0, 0, 0, 1])\n",
"p.setGravity(0, 0, -10)\n",
"p.setRealTimeSimulation(1)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "7834922b-8671-4997-a14d-696ddd217805",
"metadata": {},
"outputs": [],
"source": [
"box_object3 = p.createMultiBody(box_shape,box_shape)\n",
"p.resetBasePositionAndOrientation(box_object1, [5, 5, 5], [3, 3, 3, 1])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -0,0 +1,94 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "75ce20a6-75e2-488a-8bf9-fb77a28b67dc",
"metadata": {},
"source": [
"# Let's load a premade model"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "b4ef4a73-341b-4069-97ea-f112ca016113",
"metadata": {},
"outputs": [],
"source": [
"import pybullet_data as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "19eb502d-a4e4-48f8-aadd-e62f608f5dd4",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'C:\\\\Users\\\\Lev\\\\venvs\\\\pybullet-1\\\\lib\\\\site-packages\\\\pybullet_data'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd.getDataPath()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "990ca6c6-2ad0-4ac2-9dad-1c3604ad9d89",
"metadata": {},
"outputs": [],
"source": [
"run starter.py"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "b0457b7d-eb89-4170-aaa6-e0183cfb40f6",
"metadata": {},
"outputs": [],
"source": [
"robot = p.loadURDF(\"C:/Users/Lev/venvs/pybullet-1/Lib/site-packages/pybullet_data/r2d2.urdf\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "6573fad6-3e0a-4c6c-b9af-dedabc043c51",
"metadata": {},
"outputs": [],
"source": [
"samurai = p.loadURDF(\"C:/Users/Lev/venvs/pybullet-1/Lib/site-packages/pybullet_data/samurai.urdf\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -0,0 +1,116 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "bf434024-1856-402d-83d2-83ea018a15b3",
"metadata": {},
"outputs": [],
"source": [
"run starter.py"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9a2fdca7-e44d-48ab-9094-bcbdccb9c24f",
"metadata": {},
"outputs": [],
"source": [
"more test.urdf"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5dd58498-852b-4e05-8cdb-b0ca81ce2a36",
"metadata": {},
"outputs": [],
"source": [
"rob = p.loadURDF(\"C:/Users/Lev/venvs/pybullet-1/Lib/site-packages/pybullet_data/r2d2.urdf\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cc47478e-bdf6-47da-8b12-0c9a83cd09eb",
"metadata": {},
"outputs": [],
"source": [
"robo1 = p.loadURDF(\"test.urdf\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fcc550f3-08c0-41bf-bc2c-fe66a76840b6",
"metadata": {},
"outputs": [],
"source": [
"p.setRealTimeSimulation(1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8421e1a6-a0a9-48ea-803e-a10061a98749",
"metadata": {},
"outputs": [],
"source": [
"robo2 = p.loadURDF(\"test2.urdf\") # Collision"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5176eddf-f4e2-4bc7-88a6-084e9d240f66",
"metadata": {},
"outputs": [],
"source": [
"robo2 = p.loadURDF(\"test3.urdf\") # Inertia"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "271311c5-2151-4c18-a2e5-fc7a49436dbe",
"metadata": {},
"outputs": [],
"source": [
"robo3 = p.loadURDF(\"test4.urdf\") # multiple links and one joint\n",
"#rpy is roll pitch and y, rotation in different axis"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4213edfc-c8d3-435f-a7ac-c852e24d454b",
"metadata": {},
"outputs": [],
"source": [
"robo3 = p.loadURDF(\"humanoid.urdf\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -0,0 +1,185 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "4ab5ff34-e912-4cab-8381-de7ec26b65fc",
"metadata": {},
"outputs": [],
"source": [
"run starter.py"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "fc0c016e-af2f-4424-a8c1-a6cc33681b22",
"metadata": {},
"outputs": [],
"source": [
"robo1 = p.loadURDF(\"test5.urdf\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "6f93de75-3fc1-4eaa-957d-19883f9b7d97",
"metadata": {},
"outputs": [],
"source": [
"p.setRealTimeSimulation(1)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "8c7b4ae6-994e-415a-9904-55c108af9ec7",
"metadata": {},
"outputs": [],
"source": [
"p.resetBasePositionAndOrientation(robo1, [0, 0, 0.1], [0, 0, 0, 1]) # reset position"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "571ef95b-aa71-4b67-a930-d6549561e703",
"metadata": {},
"outputs": [],
"source": [
"p.setJointMotorControl2(robo1, 0, controlMode = p.VELOCITY_CONTROL, targetVelocity = 10)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "4ece4ccc-e6f4-4190-8d8c-42120f37ee94",
"metadata": {},
"outputs": [],
"source": [
"p.setJointMotorControl2(robo1, 0, controlMode = p.POSITION_CONTROL, targetVelocity = 10, targetPosition = 10)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "5b025d5b-a240-4bd4-8587-0d28449233ea",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(0,\n",
" b'base_to_sub',\n",
" 0,\n",
" 7,\n",
" 6,\n",
" 1,\n",
" 0.0,\n",
" 0.0,\n",
" 10.0,\n",
" 0.0,\n",
" 0.0,\n",
" 1.0,\n",
" b'sub_link',\n",
" (1.0, 0.0, 0.0),\n",
" (0.0, 0.0, 0.6),\n",
" (0.0, 0.0, 0.0, 1.0),\n",
" -1)"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"p.getJointInfo(robo1, 0)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "5375a85d-63be-4f0b-95c1-aa89c214151c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"p.JOINT_REVOLUTE"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "09dd3456-6c9b-4ba9-aaff-e907b215ba5c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"p.JOINT_PRISMATIC"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "e65f8858-85d5-402e-855c-0972613ea529",
"metadata": {},
"outputs": [],
"source": [
"robo2 = p.loadURDF(\"test6.urdf\")"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "7124ae81-cbe3-4ca7-bf6a-16c3905f5dcf",
"metadata": {},
"outputs": [],
"source": [
"p.setJointMotorControl2(robo2, 0, controlMode = p.VELOCITY_CONTROL, targetVelocity = 0.5)\n",
"p.setJointMotorControl2(robo2, 1, controlMode = p.VELOCITY_CONTROL, targetVelocity = 0.5)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -0,0 +1,120 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "0b2e213c-9b00-4632-9d5b-85eb8b210b4f",
"metadata": {},
"outputs": [],
"source": [
"run starter.py"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "589b742b-cf39-4d26-9237-7f3bee95fba2",
"metadata": {},
"outputs": [],
"source": [
"robo1 = p.loadURDF(\"C:/Users/Lev/venvs/pybullet-1/Lib/site-packages/pybullet_data/humanoid/humanoid.urdf\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "05e0eddd-8e54-42cb-8739-229e14dbf56e",
"metadata": {},
"outputs": [],
"source": [
"p.setRealTimeSimulation(1)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "b113dbf1-903c-4a54-aa9a-a9a3ee6ee3e7",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"15"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"p.getNumJoints(robo1)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "21c48b17-c5ea-4fb3-9a1e-17e5e817f74b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4\n",
"2\n",
"2\n",
"2\n",
"0\n",
"4\n",
"2\n",
"0\n",
"4\n",
"2\n",
"0\n",
"2\n",
"2\n",
"0\n",
"2\n"
]
}
],
"source": [
"for i in range(p.getNumJoints(robo1)):\n",
" print(p.getJointInfo(robo1, i) [2])"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "969b3f01-ba40-4018-bc1c-efbd6a6d4ef6",
"metadata": {},
"outputs": [],
"source": [
"for i in range(p.getNumJoints(robo1)):\n",
" p.setJointMotorControl2(robo1, i, controlMode = p.VELOCITY_CONTROL, targetVelocity = -0.25)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -0,0 +1,79 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "2042474a-37dc-4469-81e0-37d9b0ff47b5",
"metadata": {},
"outputs": [],
"source": [
"run starter.py"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "c9af8a87-ec34-461e-bd7d-cf35d42df2c1",
"metadata": {},
"outputs": [],
"source": [
"robots = []"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "55df7549-1d34-43be-b7a0-0460feb8a95c",
"metadata": {},
"outputs": [],
"source": [
"robots.append(p.loadURDF(\"test6.urdf\"))\n",
"robots.append(p.loadURDF(\"steven-chiu.urdf\"))\n",
"robots.append(p.loadURDF(\"zalalem-alemu.urdf\"))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "fa028b3d-bd3e-4f6d-b531-ae334f4a6cfd",
"metadata": {},
"outputs": [],
"source": [
"for i in range(len(robots)):\n",
" for j in range(p.getNumJoints(robots[i])):\n",
" p.setJointMotorControl2(robots[i], j, controlMode = p.VELOCITY_CONTROL, targetVelocity = 5)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "7d4840be-e06f-4dca-a589-a0e5d634fd97",
"metadata": {},
"outputs": [],
"source": [
"p.setRealTimeSimulation(1)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,9 @@
import pybullet as p
import pybullet_data as pd
p.connect(p.GUI)
p.setPhysicsEngineParameter(enableFileCaching = 0)
p.configureDebugVisualizer(p.COV_ENABLE_GUI, 0)
floor_shape = p.createCollisionShape(p.GEOM_PLANE)
floor = p.createMultiBody(floor_shape, floor_shape)
p.setGravity(0, 0, -10)

View File

@ -0,0 +1,69 @@
<?xml version="1.0"?>
<robot name="myfirst">
<link name="base_link">
<visual>
<geometry>
<cylinder length="1" radius="0.2"/>
</geometry>
<origin xyz="0 0 0"/>
</visual>
<collision>
<geometry>
<cylinder length="1" radius="0.2"/>
</geometry>
</collision>
<inertial>
<mass value="0.25"/>
<inertia ixx="0.0003" iyy="0.0003" izz="0.0003" ixy="0" ixz="0" iyz="0"/>
</inertial>
</link>
<link name="sub_link">
<visual>
<geometry>
<cylinder length=".5" radius="0.2"/>
</geometry>
<origin xyz="0 0 0"/>
</visual>
<collision>
<geometry>
<cylinder length=".5" radius="0.2"/>
</geometry>
</collision>
<inertial>
<mass value="0.25"/>
<inertia ixx="0.0003" iyy="0.0003" izz="0.0003" ixy="0" ixz="0" iyz="0"/>
</inertial>
</link>
<link name="sub_link2">
<visual>
<geometry>
<cylinder length=".5" radius="0.2"/>
</geometry>
<origin xyz="0 0 0"/>
</visual>
<collision>
<geometry>
<cylinder length=".5" radius="0.2"/>
</geometry>
</collision>
<inertial>
<mass value="0.25"/>
<inertia ixx="0.0003" iyy="0.0003" izz="0.0003" ixy="0" ixz="0" iyz="0"/>
</inertial>
</link>
<joint name="base_to_sub" type="revolute">
<parent link="base_link"/>
<child link="sub_link"/>
<axis xyz="0 1 0"/>
<limit effort="10" upper="0" lower="10" velocity="1"/>
<origin rpy="0 0 0" xyz="0 0.5 0"/>
</joint>
<joint name="base_to_sub2" type="revolute">
<parent link="base_link"/>
<child link="sub_link2"/>
<axis xyz="0 1 0"/>
<limit effort="10" upper="0" lower="10" velocity="1"/>
<origin rpy="0 0 0" xyz="0 -0.5 0"/>
</joint>
</robot>

View File

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<robot name="physics">
<link name="base_link">
<visual>
<geometry>
<cylinder length="0.6" radius="0.2"/>
</geometry>
<material name="blue">
<color rgba="0 0 .8 1"/>
</material>
</visual>
<collision>
<geometry>
<cylinder length="0.6" radius="0.17"/>
</geometry>
</collision>
<inertial>
<mass value="10"/>
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
</inertial>
</link>
</robot>

View File

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<robot name="physics">
<link name="base_link">
<visual>
<geometry>
<cylinder length="0.6" radius="0.2"/>
</geometry>
<material name="blue">
<color rgba="0 0 .8 1"/>
</material>
</visual>
<collision>
<geometry>
<cylinder length="0.6" radius="0.2"/>
</geometry>
</collision>
</link>
</robot>

View File

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<robot name="physics">
<link name="base_link">
<visual>
<geometry>
<cylinder length="0.6" radius="0.2"/>
</geometry>
<material name="blue">
<color rgba="0 0 .8 1"/>
</material>
</visual>
<collision>
<geometry>
<cylinder length="0.6" radius="0.2"/>
</geometry>
</collision>
<inertial>
<mass value="2"/>
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
</inertial>
</link>
</robot>

View File

@ -0,0 +1,48 @@
<?xml version="1.0"?>
<robot name="physics">
<link name="base_link">
<visual>
<geometry>
<cylinder length="0.6" radius="0.2"/>
</geometry>
<material name="blue">
<color rgba="0 0 .8 1"/>
</material>
</visual>
<collision>
<geometry>
<cylinder length="0.6" radius="0.2"/>
</geometry>
</collision>
<inertial>
<mass value="2"/>
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
</inertial>
</link>
<link name="sub_link">
<visual>
<geometry>
<cylinder length="0.8" radius="0.1"/>
</geometry>
<material name="red">
<color rgba=".8 0 0 1"/>
</material>
</visual>
<collision>
<geometry>
<cylinder length="0.8" radius="0.1"/>
</geometry>
</collision>
<inertial>
<mass value="2"/>
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
</inertial>
</link>
<joint name="base_to_sub" type="fixed">
<parent link="base_link"/>
<child link="sub_link"/>
<axis xyz="1 0 0"/>
<limit effor="10" upper="0" lower="10" velocity="1"/>
<origin rpy="0 0 0" xyz="0 0 0.6"/>
</joint>
</robot>

View File

@ -0,0 +1,48 @@
<?xml version="1.0"?>
<robot name="physics">
<link name="base_link">
<visual>
<geometry>
<cylinder length="0.6" radius="0.2"/>
</geometry>
<material name="blue">
<color rgba="0 0 .8 1"/>
</material>
</visual>
<collision>
<geometry>
<cylinder length="0.6" radius="0.2"/>
</geometry>
</collision>
<inertial>
<mass value="2"/>
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
</inertial>
</link>
<link name="sub_link">
<visual>
<geometry>
<cylinder length="0.8" radius="0.1"/>
</geometry>
<material name="red">
<color rgba=".8 0 0 1"/>
</material>
</visual>
<collision>
<geometry>
<cylinder length="0.8" radius="0.1"/>
</geometry>
</collision>
<inertial>
<mass value="2"/>
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
</inertial>
</link>
<joint name="base_to_sub" type="revolute">
<parent link="base_link"/>
<child link="sub_link"/>
<axis xyz="1 0 0"/>
<limit effor="10" upper="0" lower="10" velocity="1"/>
<origin rpy="0 0 0" xyz="0 0 0.6"/>
</joint>
</robot>

View File

@ -0,0 +1,74 @@
<?xml version="1.0"?>
<robot name="physics">
<link name="base_link">
<visual>
<geometry>
<cylinder length="0.6" radius="0.2"/>
</geometry>
<material name="blue">
<color rgba="0 0 .8 1"/>
</material>
</visual>
<collision>
<geometry>
<cylinder length="0.6" radius="0.2"/>
</geometry>
</collision>
<inertial>
<mass value="2"/>
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
</inertial>
</link>
<link name="sub_link">
<visual>
<geometry>
<cylinder length="0.8" radius="0.1"/>
</geometry>
<material name="red">
<color rgba=".8 0 0 1"/>
</material>
</visual>
<collision>
<geometry>
<cylinder length="0.8" radius="0.1"/>
</geometry>
</collision>
<inertial>
<mass value="2"/>
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
</inertial>
</link>
<link name="sub_link2">
<visual>
<geometry>
<cylinder length="1" radius="0.5"/>
</geometry>
<material name="green">
<color rgba="0 .8 0 1"/>
</material>
</visual>
<collision>
<geometry>
<cylinder length="1" radius="0.5"/>
</geometry>
</collision>
<inertial>
<mass value="2"/>
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
</inertial>
</link>
<joint name="base_to_sub" type="revolute">
<parent link="base_link"/>
<child link="sub_link"/>
<axis xyz="1 0 0"/>
<limit effor="10" upper="0" lower="10" velocity="1"/>
<origin rpy="0 0 0" xyz="0 0 0.6"/>
</joint>
<joint name="base_to_sub2" type="revolute">
<parent link="base_link"/>
<child link="sub_link2"/>
<axis xyz="1 0 0"/>
<limit effor="10" upper="0" lower="10" velocity="1"/>
<origin rpy="0 0 0" xyz="0 0 1.2"/>
</joint>
</robot>

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<robot name="robot_with_four_legs">
<link name="body">
<inertial>
<mass value="0.5" />
<inertia ixx="0.0003" ixy="0.0" ixz="0.0" iyy="0.0003" iyz="0.0" izz="0.0003" />
</inertial>
<visual name="">
<origin xyz="0.0 0.0 1.25" rpy="0.0 0.0 0.0" />
<geometry>
<box size="2 0.5 1" />
</geometry>
</visual>
<collision>
<origin xyz="0.0 0.0 1.25" rpy="0.0 0.0 0.0" />
<geometry>
<box size="2 0.5 1" />
</geometry>
</collision>
</link>
<link name="left_front_leg">
<inertial>
<mass value="0.5" />
<inertia ixx="0.0003" ixy="0.0" ixz="0.0" iyy="0.0003" iyz="0.0" izz="0.0003" />
</inertial>
<visual name="">
<geometry>
<box size="0.25 0.25 1" />
</geometry>
</visual>
<collision>
<geometry>
<box size="0.25 0.25 1" />
</geometry>
</collision>
</link>
<link name="right_front_leg">
<inertial>
<mass value="0.5" />
<inertia ixx="0.0003" ixy="0.0" ixz="0.0" iyy="0.0003" iyz="0.0" izz="0.0003" />
</inertial>
<visual name="">
<geometry>
<box size="0.25 0.25 1" />
</geometry>
</visual>
<collision>
<geometry>
<box size="0.25 0.25 1" />
</geometry>
</collision>
</link>
<joint name="left_front_leg_joint" type="revolute">
<origin xyz="0.0 0.5 1.0" rpy="0.0 0.0 0.0"/>
<parent link="body"/>
<child link="left_front_leg"/>
<axis xyz="0.0 1 0.0"/>
<limit lower="10.0" upper="10" effort="10" velocity="10.0"/>
</joint>
<joint name="rgiht_front_leg_joint" type="revolute">
<origin xyz="0.0 -0.5 1.0" rpy="0.0 0.0 0.0"/>
<parent link="body"/>
<child link="right_front_leg"/>
<axis xyz="0.0 1 0.0"/>
<limit lower="10.0" upper="10" effort="10" velocity="10.0"/>
</joint>
</robot>

View File

@ -0,0 +1,66 @@
# Key components in the creatures system
Genetic Algorithms (GA) has 3 phases
1. Varied population with heredity
2. Some sort of test (selection)
3. Variations of the winners/survivors (breeding)
> The most creative and challenging parts of programming a GA are usually the problem specific aspects - Hervey, Inman (2009)
We will roughly follow Sims, but with simplifications
We'll use the URDF format
We don't have a CM-5 handy, or access to the original Sims code, we'll use an alternative physics engine.
### Genotype
We'll follow Sims somewhat, but with simplifications.
### Fitness function
How far does it move?
But... they are going to cheat!
### Population model
Roulette wheel selection etc.
### Compute in parallel
We can gain a lot of speed by computing in parallel
### Technology stack
* Python
* Pybullet
* URDF format
# Introduction to pybullet
### What is bullet
It's a rigid and soft body physics engine originally developed by Erwin Coumans.
### Demo
It's written in C and C++. It's been translated to JS in ammo.js
http://kripken.github.io/ammo.js/
### Install pybullet
* Create the virtual env and install pybullet
# The URDR file format
Stands for Unified Robot Description Format
It's an XML-based file format for building robot models, including their motors and other dynamics.
To generate a model programmatically is too complex when the problem has a currently viable solution.
Using URDF makes it easier to share the models.
Links are the parts, joints are the points where the parts meet and interact.
# Moving a URDF robot
There are 3 types of joints available in pybullet, though the URDF standard supports more. These are:
* JOINT_REVOLUTE: rotate
* JOINT_PRISMATIC: move along an axis
* JOINT_FIXED: does not move
# Mving a preset robot
Joint info
* getNumJoints
* getJointInfo