You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use Pinocchio to compute inverse dynamic of UR5 robot. My code is as follows.
import toppra as ta
import toppra.constraint as constraint
import toppra.algorithm as algo
import numpy as np
import matplotlib.pyplot as plt
import argparse
import pinocchio
from sys import argv
from os.path import dirname, join, abspath
pinocchio_model_dir = join(dirname(dirname(str(abspath(file)))), "models")
urdf_filename = pinocchio_model_dir + '/example-robot-data/robots/ur_description/urdf/ur5_robot.urdf' if len(argv)<2 else argv[1]
model = pinocchio.buildModelFromUrdf(urdf_filename)
print('model name: ' + model.name)
data = model.createData()
def myInverseDynamic(q,v,a):
tau = pinocchio.rnea(model,data,q,v,a)
return tau
And I wonder why there is a big fluctuation in blue line when I set the "gridpoints=np.linspace(0, 1, 300)". But when I set "gridpoints=np.linspace(0, 1, 1000)",the blue line is more smooth.
littlefiveRobot
changed the title
Using JointVelocityConstraint and JointTorqueConstraint can not get result.
Can you help me check if my dynamic constraints are correct?
Jun 8, 2023
I use Pinocchio to compute inverse dynamic of UR5 robot. My code is as follows.
import toppra as ta
import toppra.constraint as constraint
import toppra.algorithm as algo
import numpy as np
import matplotlib.pyplot as plt
import argparse
import pinocchio
from sys import argv
from os.path import dirname, join, abspath
pinocchio_model_dir = join(dirname(dirname(str(abspath(file)))), "models")
urdf_filename = pinocchio_model_dir + '/example-robot-data/robots/ur_description/urdf/ur5_robot.urdf' if len(argv)<2 else argv[1]
model = pinocchio.buildModelFromUrdf(urdf_filename)
print('model name: ' + model.name)
data = model.createData()
def myInverseDynamic(q,v,a):
tau = pinocchio.rnea(model,data,q,v,a)
return tau
N_samples = 4 # 路径点的数量
dof = 6 # 机械臂自由度
way_pts = np.zeros([4,6])
way_pts[0] = [-1.62219,0.0430026,0.51164 ,0.814931 ,0.88985 ,-1.98603]
way_pts[1] = [0, 0, 0, 0, 0.523599, 0]
vlim_ = np.array([3.15,3.15,3.15,3.2,3.2,3.2])
vlim = np.vstack((-vlim_, vlim_)).T # 对每个自由度设置速度 最小最大限制
alim_ = np.array([6,6,6,6,6,6])
alim = np.vstack((-alim_, alim_)).T
taulim_ = np.array([150,150,150,28,28,28])
taulim = np.vstack((-taulim_, taulim_)).T
fs_coef = list([0] * dof)
path = ta.SplineInterpolator(np.linspace(0, 1, N_samples), way_pts)
pc_vel = constraint.JointVelocityConstraint(vlim)
pc_acc = constraint.JointAccelerationConstraint(alim, discretization_scheme=constraint.DiscretizationType.Collocation)
pc_tau = constraint.JointTorqueConstraint(myInverseDynamic, taulim, fs_coef, discretization_scheme=constraint.DiscretizationType.Collocation
)
instance = algo.TOPPRA([pc_vel,pc_acc,pc_tau],path,gridpoints=np.linspace(0, 1, 1000),solver_wrapper='ecos',)
result
![image](https://private-user-images.githubusercontent.com/87530322/244285982-88f1c9a2-34a5-41d3-9f37-6594cd8496d6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4OTE3MDEsIm5iZiI6MTczODg5MTQwMSwicGF0aCI6Ii84NzUzMDMyMi8yNDQyODU5ODItODhmMWM5YTItMzRhNS00MWQzLTlmMzctNjU5NGNkODQ5NmQ2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDAxMjMyMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBiM2QzOWI5NzgyM2RmNzQwMzc0MmZhZTc1NWYxZjBiMzVmM2I1NzkxNGZiZDMyNDUxMzk1ZGQ1YjU3NTllNDEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Au7QfuKl-dDNREbZnVfobyEimAiU2xXDigR6sJvBMnw)
![image](https://private-user-images.githubusercontent.com/87530322/244286054-3e7cd745-d80b-4f5e-b37e-4fd80f30d007.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4OTE3MDEsIm5iZiI6MTczODg5MTQwMSwicGF0aCI6Ii84NzUzMDMyMi8yNDQyODYwNTQtM2U3Y2Q3NDUtZDgwYi00ZjVlLWIzN2UtNGZkODBmMzBkMDA3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDAxMjMyMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZjNjgzOTU5MGZmNjZiMjA5ZTBlZGI0MDFiY2RjMzk2N2Q3MmNjYzJiYjgwNTgwOGExNGI4NDg4ZjE0NjAwNjkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.aoynxFmuivoVI4mNANb0q5nrRu9SodRTaAYMk_XE8TQ)
Version
I use 'pip install toppra' to install the algorithm.
The text was updated successfully, but these errors were encountered: