Skip to content
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

New API #3

Merged
merged 7 commits into from
Feb 28, 2018
Merged
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ addons:
## uncomment the following lines to override the default test script
script:
- julia -e 'Pkg.clone("https://github.com/rdeits/MeshCat.jl"); Pkg.build("MeshCat")'
- julia -e 'Pkg.clone(pwd()); Pkg.build("MeshCatMechanisms"); Pkg.test("MeshCatMechanisms"; coverage=true)'
- julia -e 'Pkg.clone(pwd()); Pkg.checkout("RigidBodyDynamics"); Pkg.build("MeshCatMechanisms"); Pkg.test("MeshCatMechanisms"; coverage=true)';
after_success:
# push coverage results to Codecov
- julia -e 'cd(Pkg.dir("MeshCatMechanisms")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
16 changes: 9 additions & 7 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
julia 0.6
MeshCat

LightXML
CoordinateTransformations
GeometryTypes
RigidBodyDynamics
MeshIO
FileIO
ColorTypes
ColorTypes 0.2.0
CoordinateTransformations 0.4.1
FileIO 0.1.0
GeometryTypes 0.4.0
Interpolations 0.3.6
LightXML 0.4.0
LoopThrottle 0.0.1
MeshIO 0.1.0
RigidBodyDynamics 0.4
87 changes: 18 additions & 69 deletions mechanism-demo.ipynb
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"using Revise"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -27,7 +18,7 @@
"outputs": [],
"source": [
"vis = Visualizer()\n",
"open(vis) # open the visualizer in a separate tab/window\n",
"# open(vis) # open the visualizer in a separate tab/window\n",
"IJuliaCell(vis)"
]
},
Expand All @@ -37,12 +28,11 @@
"metadata": {},
"outputs": [],
"source": [
"robot = parse_urdf(Float64, \"test/urdf/Acrobot.urdf\")\n",
"urdf = joinpath(Pkg.dir(\"MeshCatMechanisms\"), \"test\", \"urdf\", \"Acrobot.urdf\")\n",
"robot = parse_urdf(Float64, urdf)\n",
"delete!(vis)\n",
"mvis = MechanismVisualizer(robot, \"test/urdf/Acrobot.urdf\", vis)\n",
"state = MechanismState(robot)\n",
"set_configuration!(state, [1.0, -0.5])\n",
"setstate!(mvis, state)"
"mvis = MechanismVisualizer(robot, urdf, vis)\n",
"set_configuration!(mvis, [1.0, -0.5])"
]
},
{
Expand All @@ -51,22 +41,10 @@
"metadata": {},
"outputs": [],
"source": [
"t, q, v = simulate(state, 5.0);"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for i in 1:10:length(t)\n",
" set_configuration!(state, q[i])\n",
" setstate!(mvis, state)\n",
" if i < length(t)\n",
" sleep(t[i + 1] - t[i])\n",
" end\n",
"end"
"state = MechanismState(robot, randn(2), randn(2))\n",
"t, q, v = simulate(state, 5.0);\n",
"\n",
"animate(mvis, t, q)"
]
},
{
Expand All @@ -78,12 +56,12 @@
"using ValkyrieRobot\n",
"\n",
"val = Valkyrie();\n",
"\n",
"delete!(vis)\n",
"mvis = MechanismVisualizer(val.mechanism, ValkyrieRobot.urdfpath(), vis, package_path=[dirname(dirname(ValkyrieRobot.urdfpath()))])\n",
"\n",
"state = MechanismState(val.mechanism)\n",
"setstate!(mvis, state)"
"mvis = MechanismVisualizer(\n",
" val.mechanism, \n",
" ValkyrieRobot.urdfpath(),\n",
" vis, \n",
" package_path=[dirname(dirname(ValkyrieRobot.urdfpath()))]);"
]
},
{
Expand All @@ -94,7 +72,7 @@
"source": [
"using ValkyrieRobot.BipedControlUtil: Side, flipsign_if_right\n",
"\n",
"function initialize(state::MechanismState, val::Valkyrie, vis::MechanismVisualizer)\n",
"function initialize!(state::MechanismState, val::Valkyrie)\n",
" zero!(state)\n",
" mechanism = val.mechanism\n",
" for side in instances(Side)\n",
Expand All @@ -107,40 +85,11 @@
" set_configuration!(state, findjoint(mechanism, \"$(side)ForearmYaw\"), [1.571])\n",
" end\n",
" set_configuration!(state, val.basejoint, [1; 0; 0; 0; 0; 0; 1.025])\n",
" setstate!(vis, state)\n",
" nothing\n",
"end\n",
"\n",
"initialize(state, val, mvis)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"robot = parse_urdf(Float64, \"test/urdf/Acrobot_fixed.urdf\")\n",
"RigidBodyDynamics.remove_fixed_tree_joints!(robot)\n",
"delete!(vis)\n",
"mvis = MechanismVisualizer(robot, \"test/urdf/Acrobot_fixed.urdf\", vis)\n",
"\n",
"state = MechanismState(robot)\n",
"set_configuration!(state, [0.5])\n",
"setstate!(mvis, state)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for theta in linspace(-pi, pi, 1000)\n",
" set_configuration!(state, [theta])\n",
" setstate!(mvis, state)\n",
" sleep(0.001)\n",
"end"
"state = MechanismState(val.mechanism)\n",
"initialize!(state, val)\n",
"set_configuration!(mvis, configuration(state))"
]
},
{
Expand Down
Loading