Skip to content

Commit 12ba1da

Browse files
committed
added control of orientation through instantaneous task
1 parent 51ba021 commit 12ba1da

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

bindings/python/examples/panda_trajectory.py renamed to bindings/python/examples/panda_mpc.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
from rcl_interfaces.srv import GetParameters
44
from ament_index_python.packages import get_package_share_directory
55
from xbot2_interface import pyxbot2_interface as xbi
6-
from pyopensot import AffineHelper, OptvarHelper, GenericTask, Task
7-
from pyopensot.tasks.velocity import Postural, Cartesian, Manipulability, MinimumEffort
8-
from pyopensot.constraints.velocity import JointLimits, VelocityLimits
6+
from pyopensot import AffineHelper, OptvarHelper, GenericTask, Task, AffineTask, AffineConstraint
7+
from pyopensot.tasks.velocity import Cartesian
8+
from pyopensot.constraints.velocity import JointLimits
99
import pyopensot as pysot
1010
import numpy as np
1111
from sensor_msgs.msg import JointState
@@ -138,7 +138,6 @@ def publish(self, joint_state_msg):
138138

139139
dt = 1./100.
140140

141-
142141
nx = 3 # [px, py, pz]
143142
nu = 3 # [vx, vy, vz]
144143

@@ -250,7 +249,15 @@ def create(cls, vee, v):
250249

251250
min_u = pysot.AggregatedTask(min_u_list, variables.getSize())
252251

253-
stack = pysot.AutoStack(ik_task + min_u + goal_task_list[Ns-1]) << initial_state
252+
c = Cartesian("Cartesian", model, "fp3_link8", "world")
253+
c.setLambda(10.)
254+
255+
qmin, qmax = model.getJointLimits()
256+
qlims = JointLimits(model, qmax, qmin)
257+
qlims.setBoundScaling(1./dt)
258+
259+
260+
stack = pysot.AutoStack(ik_task + min_u + goal_task_list[Ns-1] + AffineTask.toAffine(c[3:], variables.getVariable("qdot0"))) << initial_state << AffineConstraint.toAffine(qlims, variables.getVariable("qdot0"))
254261
stack.update()
255262
solver = pysot.iHQP(stack)
256263

@@ -279,6 +286,8 @@ def create(cls, vee, v):
279286
pose_ref.linear = R.from_quat(quat).as_matrix()
280287
goal_task_list[Ns-1].setb(pose_ref.translation)
281288

289+
c.setReference(pose_ref)
290+
282291

283292
x0 = model.getPose("fp3_link8").translation
284293
initial_state.setb(x0)

0 commit comments

Comments
 (0)