88import pyopensot as pysot
99import numpy as np
1010from sensor_msgs .msg import JointState
11- from std_msgs .msg import String , Float64MultiArray
1211import subprocess
1312import time
1413from geometry_msgs .msg import PoseStamped
@@ -30,7 +29,7 @@ def __init__(self):
3029
3130 self .robot_description_subscriber = self .create_subscription (
3231 String ,
33- '/robot_description ' ,
32+ '/robot_description_no_hand ' ,
3433 self .listener_callback ,
3534 10 )
3635
@@ -91,21 +90,24 @@ def publish(self, joint_state_msg:JointState):
9190
9291
9392Ns = 10 # number of nodes
94- tf = 0.3 # final time
93+ tf = 0.5 # final time
9594dt = tf / Ns
9695
9796model = xbi .ModelInterface2 (node .urdf )
9897print (model .getJointNames ())
9998
10099
101- q_val = np .array ([0. , - 0.7 , 0. , - 2.1 , 0. , 1.4 , 0. ])
102- qdot_val = np .array ([0. , 0. , 0. , 0. , 0. , 0. , 0. ])
103- qddot_val = np .array ([0. , 0. , 0. , 0. , 0. , 0. , 0. ])
100+ # q_val = np.array([0., -0.7, 0., -2.1, 0., 1.4, 0.])
101+ # qdot_val = np.array([0., 0., 0., 0., 0., 0., 0.])
102+ # qddot_val = np.array([0., 0., 0., 0., 0., 0., 0.])
104103
105104model .setJointPosition (node .state [:model .nq ].copy ())
106105model .update ()
107- T = model .getPose ("panda_link8" )
106+ # T = model.getPose("panda_link8")
108107
108+ q_val = node .state [:model .nq ].copy ()
109+ qdot_val = node .state [model .nq :].copy ()
110+ qddot_val = np .zeros (model .nv )
109111
110112
111113vars = list ()
@@ -216,12 +218,12 @@ def publish(self, joint_state_msg:JointState):
216218 minu .setWeight (1e-3 * np .eye (model .nv ))
217219 minus .append (minu )
218220
219- postural = Postural (ocp .stage (i ).model )
220- postural .setWeight (1e-3 * np .eye (model .nv ))
221- postural .setReference (q_val .copy ())
222- minus .append (postural )
221+ # postural = Postural(ocp.stage(i).model)
222+ # postural.setWeight(1e0 * np.eye(model.nv))
223+ # postural.setReference(q_val.copy())
224+ # minus.append(postural)
223225
224- ocp .stage (i ).stack = pysot .AutoStack (minu + AffineTask .toAffine (postural , dvariables .getVariable ("dq" )))
226+ ocp .stage (i ).stack = pysot .AutoStack (minu ) # + AffineTask.toAffine(postural, dvariables.getVariable("dq")))
225227
226228 # tau_min
227229 tau_lim = DynamicsConstraint (ocp .stage (i ).model , ocp .stage (i ).dx , ocp .stage (i ).du )
@@ -288,7 +290,7 @@ def publish(self, joint_state_msg:JointState):
288290
289291msg = JointState ()
290292msg .name = model .getJointNames ()
291- print (msg .name )
293+ # print(msg.name)
292294try :
293295 while rclpy .ok ():
294296 cartesian_task .setReference (node .pose_ref .copy ())
0 commit comments