Skip to content

Commit 988d39e

Browse files
committed
real_mpc changes
1 parent b6a6fef commit 988d39e

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

bindings/python/examples/floating_frame/franka_mpc_real.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import pyopensot as pysot
99
import numpy as np
1010
from sensor_msgs.msg import JointState
11-
from std_msgs.msg import String, Float64MultiArray
1211
import subprocess
1312
import time
1413
from 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

9392
Ns = 10 # number of nodes
94-
tf = 0.3 # final time
93+
tf = 0.5 # final time
9594
dt = tf/Ns
9695

9796
model = xbi.ModelInterface2(node.urdf)
9897
print(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

105104
model.setJointPosition(node.state[:model.nq].copy())
106105
model.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

111113
vars = 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

289291
msg = JointState()
290292
msg.name = model.getJointNames()
291-
print(msg.name)
293+
# print(msg.name)
292294
try:
293295
while rclpy.ok():
294296
cartesian_task.setReference(node.pose_ref.copy())

0 commit comments

Comments
 (0)