-
Notifications
You must be signed in to change notification settings - Fork 568
Adding a spline joint to the joint collection #2784
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
MegMll
wants to merge
185
commits into
stack-of-tasks:devel
Choose a base branch
from
MegMll:topic/spline_joint
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
185 commits
Select commit
Hold shift + click to select a range
81fb500
Joints - Add a first implementation of joint spline
MegMll 6d10338
Unittest - Add TU for spline joint
MegMll 03cff56
Bindings - add bindings for spline joint
MegMll acf9c52
Spatial - Weird fix to make spline joint work for now (to remove)
MegMll 601c202
Unittest - update joint unittests to include spline joints
MegMll 9227017
SplineJoint - apply pre-commit
MegMll 7fa9883
Spline - use the true cumulative form of the spline
MegMll 2a376bc
Spline - Add isEqual Method
MegMll ba8dafb
Spline - Add TU with finite difference
MegMll 349758d
Unittest - fix tests for spline joint
MegMll 697a984
Spline joint - change if/else to be casadi compatible
MegMll 4f1b461
Joint Spline - Remove useless comments
MegMll 7df1feb
Joint Spline - Fix indexing
MegMll d557795
Joint Spline - Eigen No Malloc checked and passed
MegMll 76f9ef3
Spline joints - fix casadi joints tests
MegMll 8b0a4db
Joint Spline - Add a build method
MegMll 1e0bbed
Unittest - Fix joint spline's unittests
MegMll 7b3210c
Model-graph - Add spline joint to model graph
MegMll 1f3c5ca
JointSpline - make some correction to the joint
MegMll 5a3bbd8
TU - apply new jointSpline constructor
MegMll 62866a4
ModelGraph - use new JointSpline method
MegMll 17da33e
Serialization - Add attributes from spline model and data
MegMll c7766c7
Unittest - use std vector instead of se3
MegMll 2474c2a
JointSpline - Diverse Changes
MegMll fe623c0
Casadi - Add a separated file for findSpan to be able to do specializ…
MegMll 0d44830
Bindings - modify joint spline binding
MegMll c5bef24
JointSpline - Remove findSpan
MegMll 5570819
Unittest - remove buildJoint function
MegMll 8f71dc3
ModelGraph - finish adding jointSpline to model graph + unittest
MegMll 5477879
cppadcg: Fix cppadcg cast test with spline joint
jorisv a2706dc
multiprecision: Fix multiprecision cast test with Spline joint
jorisv 06f8cfa
multiprecision: Add missing header
jorisv aa227a3
lint: Run linter
jorisv e5160f9
JointSpline - Removed comments
MegMll 8f48978
JointSpline - move bspline functions in public to be able to test it
MegMll 25053c8
Unittest - add more test for joint spline
MegMll 93e0b9e
Bindings - Add another constructor for joint spline
MegMll 7ba95a6
Unittest - put full knee trajectory
MegMll f6500f3
Unittest - fix getTrajectory function
MegMll 01758ec
Bindings - add modelgraph bindings constant
MegMll b571c7b
JointSpline - Fix indexing
MegMll 6b17353
JointSpline - Add a doc
MegMll 49164a9
JointSpline - Fix bias computation
MegMll 5855b08
Unittest - add a finite difference test for S and bias c for JointSpline
MegMll 3779f4e
JointSpline - Add comments and complete isEqual function
MegMll d1afd72
Unittest - Try to add tolerance to see if it fixes macos-intel problem
MegMll 647676b
Unittest - fix compilation error
MegMll 21f7094
JointSpline - add assert for configuration to be between 0 and 1
MegMll 49f7d44
Bindings - Add graph spline joints bindings
MegMll 119145e
Algo/Splines - remove comments
MegMll d9cd11a
Unittest - add find span test for q = 0
MegMll ea020af
Changelog - update
MegMll 3f688ea
JointSpline - remove SE3 and use Transformation_t
MegMll ba770e4
Unittest - remove comments
MegMll 2cbb266
JointSpline - Use transformation_t and motion_t
MegMll 6dbfa5b
Examples - Add a small examples on what the spline joint can do
MegMll 5110376
Unittest - Specialize for joint spline
MegMll 4c94147
Examples - add spline joint examples
MegMll bba1873
Unittest - Fix joint generic test for joint spline
MegMll 574a334
Examples - Fix some linting errors
MegMll 78caac0
JointSpline - Disable assert
MegMll 7fa6da1
core: Apply small changes
jorisv 93d513d
Algo/splines - add doc
MegMll 6e56942
Unittest - Avoid code duplication for randomConfig vector generation
MegMll 83fa3f5
Unittest - more complex and complete tests
MegMll 6d64dda
Unittest/cppad - use degree 3 spline joint
MegMll 89ccc56
unittest - change name of struct to be more generic
MegMll b08c065
unittest - avoid code duplication
MegMll 3521f46
unittest - avoid code duplication
MegMll 807bd1a
Unittest - fix casadi/joints test
MegMll d5a6c3d
Unittest - add forgotten helical unaligned joint
MegMll aef9a2b
Unittest - Fix casadi test for universal joints
MegMll e9073a7
Mode-graph - use new function for joint spline
MegMll e25fe62
Linting
MegMll 59f468d
unittest - fix new joint
MegMll 2c0c8c1
JointSpline - Fix bias computation
MegMll 4daa8cf
Unittest - Fix finite-difference test
MegMll 3b52146
unittest - use config vector of joints
MegMll ec96115
unittest - remove useless lines
MegMll 8d3f757
Unittest - Add a utils file to centralize init of joints with parameters
MegMll 0865814
Run pre-commit
MegMll 94ab562
unittest/utils - Fix mimic init
MegMll e069d70
Core - update spline to allow spans to be between min and max, instea…
MegMll 33dcdd5
core - move joint spline definition
MegMll fd0b9ba
core - update splines algorithms
MegMll 3a6e54e
core - add spline joint
MegMll 7fc4873
parser - add spline joint
MegMll ff6cced
core - fix some errors and warnings (some errors due to rebase still …
MegMll caaa9b7
unittest - use jointModelWithParameters
MegMll 6d59876
unittest - use std::vector
MegMll b9336be
remove useless file
MegMll 66fb5ec
unittest - fix compilation warnings
MegMll e1ba833
unittest - add spline joint to serialization test
MegMll 72209ea
unittest - update serialization test to use jointModelWithParameters
MegMll a4edad8
unittest - clean, remove comments
MegMll ccf1933
fix cmake: @lucasJoseph
Ipuch 2c0cf6b
fix: splines.hpp to sources.cmake
Ipuch 4e1dea2
core : factorize code calc functions
MegMll 662fd62
core : finish adding min/max for the knot vector + fix knot vector co…
MegMll 1ba06c9
unittest : modify knot unittest to test min/max
MegMll 900749f
core : add min/max for spline joint
MegMll f3f0773
refactor: decoupling the knotvector scaling
Ipuch 6568415
tests: joint-generic bounding q with joint limits
Ipuch 5b1aadf
spline: Apply new header convention
jorisv 94666c1
spline: Fix build
jorisv d6fd9b6
core - add a new struct JointSplineBuilder
MegMll 4fb8cf5
unittest - update tests to use new builder struct
MegMll 055ff4e
model-graph - update jointSpline
MegMll d2cedc4
bindings - update jointSpline bindings
MegMll 9eeb5b4
graph: Explain why we can't reverse the joint
jorisv a53580b
core - move splines algos into internal and/or private
MegMll 96a0e70
core - make test casadi compatible
MegMll 03021bc
unittest - Fix degree
MegMll 5eee4c9
unittest - Make tset compatible with new internal api
MegMll 50da261
unittest: Fix joint-init.hpp build
jorisv 95a7da8
unittest: Use joint-init.hpp in visitor.cpp
jorisv 033f98f
unittest: Use joint-init.hpp in joint-motion-subspace.cpp
jorisv 2b9ffdb
unittest: Use joint-init.hpp in all-joints.cpp
jorisv 91862d7
unittest: Remove dead code
jorisv 9f47ca3
mpfr: Remove useless include
jorisv 46383e2
changelog: Set in Unreleased and add example link
jorisv f13ce81
casadi: Fix scalar casting
jorisv e99121a
casadi: Fix expression evaluation
jorisv 7e6ecc5
graph: Add JointSplineBuilder
jorisv 48119c9
joint: Remove moved methods
jorisv dccd5eb
joint: Remove one warning
jorisv fc461a0
casadi: Fix build
jorisv 1df18ab
python: Fix binding build and add graph::JointSplineBuilder
jorisv dfe87cc
examples: Use coal and run when running ctest
jorisv 2623fca
python: Add JointModelSplineBuilder binding
jorisv e83419f
lint: Apply clang-format
jorisv 90585c2
joint: Remove warning
jorisv c5a9e7c
unittest: Use builder to build joint
jorisv ee6aff9
unittest: Fix cppad-joints build
jorisv 74045b9
unittest - rewrite most tests to use internal functions directly
MegMll dab1e19
core - write correct test for range inside basis function computation
MegMll 1d04d23
example: knee with spline joint.
Ipuch d18ce5a
example: spline knee joint with better curves.
Ipuch 8f52386
example: spline knee joint make it minimal
Ipuch 0ac2e30
example: parabola in spline-joint.py
Ipuch 031e09e
spline: Fix FindSpan and improve tests
jorisv 6f5f1f5
test: Relax precision on finite-differences test
jorisv 7e23049
test: fix some assert and remove warnings
jorisv 67d1337
spline: Remove more warnings
jorisv eadca27
unittest: Use an open uniform spline by default to help numerical pre…
jorisv 2a44e69
unittest: Add a bound test to bsplineBasis
jorisv c2fdc01
python: Expose JointDataSpline specialized members
jorisv ad9fa91
warning: Remove a bunch of clang warning
jorisv de73179
core - add Continuity check over knot vector
MegMll a975b4d
unittest - add test for basis function continuity
MegMll 64a2969
unittest - fix unittest for basis function derivatives (finite differ…
MegMll e727de6
examples - apply linting
MegMll f152bbe
spline: Add deBoor algorithm to evaluate the BSpline
jorisv eed08d3
spline: Remove warnings
jorisv a450e92
spline: Implement deBoorCumBasisSparse
jorisv 8abff51
spline: Rename deBoorBasis into deBoor
jorisv 1fd24cc
spline: Add bsplineBasis to compute all basis function with minimal c…
jorisv 45c028e
spline: Remove other deBoor like algorithm
jorisv 4f42559
spline: Add comments
jorisv ea7c347
spline: First working version with deBoorBasis
jorisv 132b721
spline: Add standalone function to compute cumulative bspline derivat…
jorisv a3cb088
spline: Move bsplineBasis in unit tests and test cumulativeBasisDeriv…
jorisv be553d0
spline: Fix build
jorisv 3c16950
spline: Add deBoorFullBasis function
jorisv b1748b4
spline: Improve doc and comments
jorisv 8a94293
spline: Add Full variant to support casadi
jorisv 1a2b1e6
spline: Refactor code to implement spline transformation on minimal a…
jorisv 5a078cf
spline: Add computeSplineKinematicsFull
jorisv 763bbe9
spline: Fix changelog
jorisv bab7deb
spline: Test computeSplineKinematicsFull.
jorisv 531ab79
Spline: Setup SplineKinematics structure
jorisv f479196
spline: Try to fix Windows build issue
jorisv acbc13e
examples: Add guards to stop example if meshcat is not installed
jorisv aa9848f
spline: Remove warnings
jorisv 3bbe7e1
spline: Improve assert
jorisv 8d6a79c
spline: Rename deBoorFulBasis into deBoorBasisFull
jorisv 39da48f
spline: Store deBoorBasis in a dense vector
jorisv a90a403
spline: Enforce to evalute spline in valid range
jorisv f582c73
python: Add attributes
jorisv 5a35c9d
spline: Remove useless macro
jorisv 56dd6a3
spline: Fix check_expression_if_real use
jorisv a7c761e
unittest: Use degree 3 spline
jorisv cdc0b86
changelog: List second example
jorisv c8973cf
unittest: Use joint-init.hpp in cppad/joints.cpp
jorisv 504fbc0
spline: Add spline constructor guards test
jorisv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,153 @@ | ||
| """Knee spline joint driven by its physical flexion angle. | ||
|
|
||
| This example uses the SE(3) spline joint (``pin.JointModelSpline`` / | ||
| ``pin.JointModelSplineBuilder``) to reproduce experimental knee kinematics: the | ||
| joint constrains its child (tibia) frame to a cumulative B-spline on SE(3) | ||
| defined by a list of control frames, a knot vector and a degree | ||
|
|
||
| source: Lee, S. H., & Terzopoulos, D. (2008). | ||
| Spline joints for multibody dynamics. In ACM SIGGRAPH 2008 papers (pp. 1-8). | ||
|
|
||
| The 8 control frames below were fit offline (Gauss-Newton, degree=3, n_ctrl=8) | ||
| to a planar OpenSim knee, where the tx/ty translations the rotation | ||
| about Z (knee flexion) are driven by knee flexion itself. | ||
| """ | ||
|
|
||
| import time | ||
| from pathlib import Path | ||
|
|
||
| import coal | ||
|
|
||
| try: | ||
| import meshcat.geometry as mg | ||
| except ImportError as err: | ||
| import sys | ||
|
|
||
| print("Error while importing meshcat. It seems you should install Python meshcat") | ||
| print(err) | ||
| sys.exit(0) | ||
| import numpy as np | ||
| import pinocchio as pin | ||
| from pinocchio.visualize import MeshcatVisualizer | ||
|
|
||
| # Bones: mesh folder, OpenSim (subject-specific) scale factors and display color. | ||
| MESH_DIR = Path(__file__).resolve().parent.parent / "models" / "biomechanics" | ||
| FEMUR_SCALE, TIBIA_SCALE = 1.17378, 1.12373 | ||
| BONE_COLOR = np.array([0.96, 0.94, 0.86, 0.7]) # bone ivory, semi-transparent. | ||
|
|
||
| # Recenter so the femoral condyle (knee) sits at the world origin instead of the | ||
| # hip: the fixed femur and the spline joint are both lifted by the knee offset. | ||
| KNEE_FROM_HIP = np.array([-0.0046, -0.4644, 0.0]) | ||
| RECENTER = pin.SE3(np.eye(3), -KNEE_FROM_HIP) | ||
|
|
||
| # Control frames from the offline 2D-knee regression, as (yaw [rad], tx, ty [m]). | ||
| CONTROL_FRAMES = [ | ||
| (-2.094400, -0.003842, -0.496205), | ||
| (-1.815147, 0.001278, -0.489246), | ||
| (-1.256640, 0.006243, -0.480186), | ||
| (-0.418880, -0.002220, -0.466444), | ||
| (0.418880, -0.008427, -0.463391), | ||
| (1.256640, -0.005740, -0.461613), | ||
| (1.815147, -0.006127, -0.464906), | ||
| (2.094400, -0.006285, -0.464416), | ||
| ] | ||
|
|
||
|
|
||
| def mesh_object(name, parent_joint, stl, scale, placement): | ||
| """Build a mesh GeometryObject fixed to ``parent_joint`` at ``placement``.""" | ||
| mesh_scale = scale * np.ones(3) | ||
| geom = coal.MeshLoader().load(str(stl), mesh_scale) | ||
| obj = pin.GeometryObject(name, parent_joint, placement, geom, str(stl), mesh_scale) | ||
| obj.meshColor = BONE_COLOR | ||
| return obj | ||
|
|
||
|
|
||
| class PointTracer: | ||
| """Trace a fixed point in Meshcat, keeping the dotted trail.""" | ||
|
|
||
| def __init__(self, viz, name, point=None, color=0xFF3030, size=0.004): | ||
| self._world_to_femur = RECENTER.inverse() | ||
| self._point = np.zeros(3) if point is None else np.asarray(point, float) | ||
| self._material = mg.PointsMaterial(size=size, color=color) | ||
| self._trail = [] | ||
| self._node = viz.viewer[f"tibia_traces/{name}"] | ||
| self._node.set_transform(RECENTER.homogeneous) | ||
|
|
||
| def add(self, tibia_pose): | ||
| self._trail.append(self._world_to_femur.act(tibia_pose.act(self._point))) | ||
| pts = np.asarray(self._trail, dtype=np.float32).T | ||
| self._node.set_object(mg.Points(mg.PointsGeometry(pts), self._material)) | ||
|
|
||
|
|
||
| def main(): | ||
| control_frames = [ | ||
| pin.SE3(pin.rpy.rpyToMatrix(0.0, 0.0, yaw), np.array([tx, ty, 0.0])) | ||
| for (yaw, tx, ty) in CONTROL_FRAMES | ||
| ] | ||
|
|
||
| # Knee-angle domain of the fitted spline (in degree). | ||
| THETA_MIN_DEG, THETA_MAX_DEG = -120.0, 120.0 | ||
|
|
||
| knee = ( | ||
| pin.JointModelSplineBuilder() | ||
| .withDegree( | ||
| 3 | ||
| ) # degree of the splines, degree 3 means acceleration is continuous. | ||
| .withControlFrameVector(control_frames) # list of SE3 transforms | ||
| .withOpenUniformKnots( | ||
| THETA_MIN_DEG, THETA_MAX_DEG | ||
| ) # Map knee flexion angle (degrees) to spline parameter q in [0, 1]. | ||
| .build() | ||
| ) | ||
| model = pin.Model() | ||
| joint_id = model.addJoint(0, knee, RECENTER, "knee") | ||
|
|
||
| # visual only code | ||
| try: | ||
| visual_model = pin.GeometryModel() | ||
| visual_model.addGeometryObject( | ||
| mesh_object("femur", 0, MESH_DIR / "femur_r.stl", FEMUR_SCALE, RECENTER) | ||
| ) | ||
| visual_model.addGeometryObject( | ||
| mesh_object( | ||
| "tibia", | ||
| joint_id, | ||
| MESH_DIR / "tibia_r.stl", | ||
| TIBIA_SCALE, | ||
| pin.SE3.Identity(), | ||
| ) | ||
| ) | ||
|
|
||
| viz = MeshcatVisualizer(model, None, visual_model) | ||
| viz.initViewer(open=True) | ||
| viz.loadViewerModel() | ||
|
|
||
| except ImportError as e: | ||
| print("Error while initializing the viewer.") | ||
| print(e) | ||
| return | ||
|
|
||
| # Trace tibia-frame points and show the tibia frame as a triad, updated every step. | ||
| plateau = np.array([0.03100708, -0.03819558, -0.00347008]) | ||
| tracers = [ | ||
| PointTracer(viz, "origin", color=0xFF3030), | ||
| PointTracer(viz, "plateau", plateau, color=0x3060FF), | ||
| ] | ||
| tibia_frame = viz.viewer["tibia_frame"] | ||
| tibia_frame.set_object(mg.triad(0.08)) | ||
|
|
||
| # Sweep the physical knee angle (+10 deg hyperextension to -120 deg flexion), | ||
| angles = np.linspace(10.0, -120.0, 120) | ||
| angles = np.concatenate([angles, angles[::-1]]) | ||
| for _ in range(5): | ||
| for theta_deg in angles: | ||
| viz.display(np.array([theta_deg])) | ||
| tibia_pose = viz.data.oMi[joint_id] | ||
| for tracer in tracers: | ||
| tracer.add(tibia_pose) | ||
| tibia_frame.set_transform(tibia_pose.homogeneous) | ||
| time.sleep(0.015) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or 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,116 @@ | ||
| import time | ||
|
|
||
| try: | ||
| import meshcat.geometry as mg | ||
| except ImportError as err: | ||
| import sys | ||
|
|
||
| print("Error while importing meshcat. It seems you should install Python meshcat") | ||
| print(err) | ||
| sys.exit(0) | ||
| import numpy as np | ||
| import pinocchio as pin | ||
| from pinocchio.visualize import MeshcatVisualizer | ||
|
|
||
|
|
||
| class PointTracer: | ||
| """Trace a fixed point in Meshcat, keeping the dotted trail.""" | ||
|
|
||
| def __init__(self, viz): | ||
| self._material = mg.PointsMaterial(size=0.004, color=0xFF3030) | ||
| self._trail = [] | ||
| self._node = viz.viewer["solid_pose"] | ||
|
|
||
| def add(self, solid_pose): | ||
| self._trail.append(solid_pose.translation.copy()) | ||
| pts = np.asarray(self._trail, dtype=np.float32).T | ||
|
|
||
| line = mg.Line( | ||
| geometry=mg.PointsGeometry(pts), | ||
| material=mg.LineBasicMaterial(color=0xFF3030), | ||
| ) | ||
| self._node.set_object(geometry=line) | ||
|
|
||
|
|
||
| def main(): | ||
| PARABOLA_CONTROL_FRAMES = [ | ||
| (-1.000000, 1.000000), | ||
| (-0.888889, 0.777778), | ||
| (-0.666667, 0.407407), | ||
| (-0.333333, 0.074074), | ||
| (0.000000, -0.037037), | ||
| (0.333333, 0.074074), | ||
| (0.666667, 0.407407), | ||
| (0.888889, 0.777778), | ||
| (1.000000, 1.000000), | ||
| ] | ||
|
|
||
| control_frames = [ | ||
| pin.SE3(np.eye(3), np.array([0, ty, tz])) | ||
| for (ty, tz) in PARABOLA_CONTROL_FRAMES | ||
| ] | ||
|
|
||
| # Create a Pinocchio model with a single free-flyer joint | ||
| model = pin.Model() | ||
| spline_joint = ( | ||
| pin.JointModelSplineBuilder() | ||
| .withDegree(3) | ||
| .withControlFrameVector(control_frames) | ||
| .withOpenUniformKnots(-1, 1) | ||
| .build() | ||
| ) | ||
| joint_id = model.addJoint(0, spline_joint, pin.SE3.Identity(), "spline-joint") | ||
|
|
||
| # adding some inertia to drop the solid in the parabola | ||
| box_size = 1.0 # edge length of each cube [m] | ||
| box_mass = 1.0 # mass of each cube [kg] | ||
| box_inertia = pin.Inertia.FromBox(box_mass, box_size, box_size, box_size) | ||
| model.appendBodyToJoint(joint_id, box_inertia, pin.SE3.Identity()) | ||
|
|
||
| # visual only code | ||
| try: | ||
| visual_model = pin.GeometryModel() | ||
|
|
||
| viz = MeshcatVisualizer(model, None, visual_model) | ||
| viz.initViewer(open=True) | ||
| viz.loadViewerModel() | ||
|
|
||
| except ImportError as e: | ||
| print("Error while initializing the viewer.") | ||
| print(e) | ||
| return | ||
|
|
||
| tracers = [PointTracer(viz)] | ||
| solid_frame = viz.viewer["solid_frame"] | ||
| solid_frame.set_object(mg.triad(0.2)) | ||
|
|
||
| dt = 0.01 | ||
| qs, _ = sim_loop(model, dt) | ||
|
|
||
| for theta in qs: | ||
| viz.display(np.array([theta])) | ||
| solid_pose = viz.data.oMi[joint_id] | ||
| for tracer in tracers: | ||
| tracer.add(solid_pose) | ||
| solid_frame.set_transform(solid_pose.homogeneous) | ||
| time.sleep(dt) | ||
|
|
||
|
|
||
| def sim_loop(model, dt=0.01, nsteps=800): | ||
| qs = [np.array([1.0])] | ||
| vs = [np.array([0])] | ||
| data = model.createData() | ||
| for i in range(nsteps): | ||
| q = qs[i] | ||
| v = vs[i] | ||
| tau = -1 * v # a little bit of damping | ||
| a1 = pin.aba(model, data, q, v, tau) | ||
| vnext = v + dt * a1 | ||
| qnext = pin.integrate(model, q, dt * vnext) | ||
| qs.append(qnext) | ||
| vs.append(vnext) | ||
| return qs, vs | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.