11{
2- "metadata" : {
3- "language_info" : {
4- "codemirror_mode" : {
5- "name" : " ipython" ,
6- "version" : 3
7- },
8- "file_extension" : " .py" ,
9- "mimetype" : " text/x-python" ,
10- "name" : " python" ,
11- "nbconvert_exporter" : " python" ,
12- "pygments_lexer" : " ipython3" ,
13- "version" : " 3.9.6"
14- },
15- "orig_nbformat" : 2 ,
16- "kernelspec" : {
17- "name" : " python3" ,
18- "display_name" : " Python 3.9.6 64-bit ('base': conda)"
19- },
20- "interpreter" : {
21- "hash" : " 95ec9ec1504d83f612128e0fb229072f90bbb4cb09d9d5d93b5dd26e0ca2cfd1"
22- }
23- },
24- "nbformat" : 4 ,
25- "nbformat_minor" : 2 ,
262 "cells" : [
273 {
284 "cell_type" : " code" ,
295 "execution_count" : null ,
6+ "metadata" : {},
7+ "outputs" : [],
308 "source" : [
319 " import gtdynamics as gtd\n " ,
3210 " from gtdynamics import ContactGoal, PointOnLink, Slice, Interval\n " ,
3311 " from gtsam import Pose3, Point3"
34- ],
35- "outputs" : [],
36- "metadata" : {}
12+ ]
3713 },
3814 {
3915 "cell_type" : " code" ,
4016 "execution_count" : null ,
17+ "metadata" : {},
18+ "outputs" : [],
4119 "source" : [
4220 " # Load the vision 60 quadruped by Ghost robotics: https://youtu.be/wrBNJKZKg10\n " ,
4321 " robot = gtd.CreateRobotFromFile(gtd.URDF_PATH + \" /vision60.urdf\" );"
44- ],
45- "outputs" : [],
46- "metadata" : {}
22+ ]
4723 },
4824 {
4925 "cell_type" : " code" ,
5026 "execution_count" : null ,
27+ "metadata" : {},
28+ "outputs" : [],
5129 "source" : [
5230 " # feet\n " ,
5331 " contact_in_com =(0.14, 0, 0)\n " ,
6442 " ContactGoal(RH, [-0.4, -0.16, 0])\n " ,
6543 " ]\n " ,
6644 " print(contact_goals)"
67- ],
68- "outputs" : [],
69- "metadata" : {}
45+ ]
7046 },
7147 {
7248 "cell_type" : " code" ,
7349 "execution_count" : null ,
74- "source" : [
75- " kinematics = gtd.Kinematics()\n " ,
76- " result = kinematics.inverse(Slice(4), robot, contact_goals)\n " ,
77- " print(result)"
78- ],
50+ "metadata" : {},
7951 "outputs" : [],
80- "metadata" : {}
52+ "source" : [
53+ " parameters = gtd.KinematicsParameters()\n " ,
54+ " # parameters.method = gtd.KinematicsParameters.Method.SOFT_CONSTRAINTS # not yet wrapped\n " ,
55+ " kinematics = gtd.Kinematics(parameters)\n " ,
56+ " result = kinematics.inverse(Slice(4), robot, contact_goals)"
57+ ]
8158 },
8259 {
8360 "cell_type" : " code" ,
8461 "execution_count" : null ,
62+ "metadata" : {},
63+ "outputs" : [],
8564 "source" : [
8665 " for goal in contact_goals:\n " ,
8766 " print(goal.link().name(), goal.satisfied(result,k=4,tol=1e-3))"
88- ],
89- "outputs" : [],
90- "metadata" : {}
67+ ]
9168 },
9269 {
9370 "cell_type" : " code" ,
9471 "execution_count" : null ,
72+ "metadata" : {},
73+ "outputs" : [],
9574 "source" : [
9675 " # interpolate\n " ,
76+ " \n " ,
9777 " contact_goals2 = [\n " ,
9878 " ContactGoal(LH, [-0.4, 0.16, 0]),\n " ,
9979 " ContactGoal(LF, [0.3, 0.16, 0]),\n " ,
100- " ContactGoal(RF, [0.4, -0.16, 0]), # 10 cm on!\n " ,
101- " ContactGoal(RH, [-0.4, -0.16, 0])\n " ,
102- " ]\n " ,
103- " interpolated_values = kinematics.interpolate(Interval(4,8), robot, contact_goals, contact_goals2)"
104- ],
105- "outputs" : [],
106- "metadata" : {}
80+ " ContactGoal(RF, [0.3 + 0.10, -0.16, 0]), # 10 cm on!\n " ,
81+ " ContactGoal(RH, [-0.4, -0.16, 0]),\n " ,
82+ " ]\n " ,
83+ " \n " ,
84+ " k_start, k_end = 4, 8\n " ,
85+ " interpolated_values = kinematics.interpolate(\n " ,
86+ " Interval(k_start, k_end), robot, contact_goals, contact_goals2\n " ,
87+ " )\n " ,
88+ " # interpolated_values.print(\" interpolated_values\" , gtd.GTDKeyFormatter)"
89+ ]
10790 },
10891 {
10992 "cell_type" : " code" ,
11093 "execution_count" : null ,
94+ "metadata" : {},
95+ "outputs" : [],
11196 "source" : [
112- " print(interpolated_values)"
113- ],
97+ " import plotly.graph_objects as go\n " ,
98+ " \n " ,
99+ " fig = go.Figure()\n " ,
100+ " \n " ,
101+ " for joint in robot.joints():\n " ,
102+ " joint_id = joint.id()\n " ,
103+ " ks = []\n " ,
104+ " angles = []\n " ,
105+ " for k in range(k_start, k_end + 1):\n " ,
106+ " key = gtd.JointAngleKey(joint_id, k)\n " ,
107+ " if interpolated_values.exists(key):\n " ,
108+ " ks.append(k)\n " ,
109+ " angles.append(interpolated_values.atDouble(key))\n " ,
110+ " \n " ,
111+ " if angles:\n " ,
112+ " fig.add_trace(go.Scatter(x=ks, y=angles, mode=\" lines+markers\" , name=joint.name()))\n " ,
113+ " \n " ,
114+ " fig.update_layout(\n " ,
115+ " title=\" Interpolated Joint Angles\" ,\n " ,
116+ " xaxis_title=\" k\" ,\n " ,
117+ " yaxis_title=\" angle (rad)\" ,\n " ,
118+ " template=\" plotly_white\" ,\n " ,
119+ " )\n " ,
120+ " fig.show()"
121+ ]
122+ },
123+ {
124+ "cell_type" : " code" ,
125+ "execution_count" : null ,
126+ "metadata" : {},
114127 "outputs" : [],
115- "metadata" : {}
128+ "source" : [
129+ " for k in range(k_start, k_end + 1):\n " ,
130+ " print(f\" --- k={k} ---\" )\n " ,
131+ " for goal in contact_goals:\n " ,
132+ " print(goal.link().name(), goal.satisfied(interpolated_values,k=k,tol=1e-3))"
133+ ]
116134 }
117- ]
118- }
135+ ],
136+ "metadata" : {
137+ "kernelspec" : {
138+ "display_name" : " py312" ,
139+ "language" : " python" ,
140+ "name" : " python3"
141+ },
142+ "language_info" : {
143+ "codemirror_mode" : {
144+ "name" : " ipython" ,
145+ "version" : 3
146+ },
147+ "file_extension" : " .py" ,
148+ "mimetype" : " text/x-python" ,
149+ "name" : " python" ,
150+ "nbconvert_exporter" : " python" ,
151+ "pygments_lexer" : " ipython3" ,
152+ "version" : " 3.12.6"
153+ },
154+ "orig_nbformat" : 2
155+ },
156+ "nbformat" : 4 ,
157+ "nbformat_minor" : 2
158+ }
0 commit comments