Skip to content
Snippets Groups Projects
Commit 3cef4856 authored by Pep Martí Saumell's avatar Pep Martí Saumell
Browse files

WIP: changing the control function

parent ffaf30f3
No related branches found
No related tags found
No related merge requests found
Pipeline #4456 failed
...@@ -51,7 +51,7 @@ class ActuationModelUAM: ...@@ -51,7 +51,7 @@ class ActuationModelUAM:
We implement here the simplest model: tau = S.T*u, where S is constant. We implement here the simplest model: tau = S.T*u, where S is constant.
''' '''
def __init__(self, pinocchioModel, quadrotorType, rotorDistance, coefM, coefF): def __init__(self, pinocchioModel, quadrotorType, rotorDistance, coefM, coefF, uLim, lLim):
self.pinocchio = pinocchioModel self.pinocchio = pinocchioModel
if (pinocchioModel.joints[1].shortname() != 'JointModelFreeFlyer'): if (pinocchioModel.joints[1].shortname() != 'JointModelFreeFlyer'):
warnings.warn('Strange that the first joint is not a freeflyer') warnings.warn('Strange that the first joint is not a freeflyer')
...@@ -73,17 +73,30 @@ class ActuationModelUAM: ...@@ -73,17 +73,30 @@ class ActuationModelUAM:
self.d = rotorDistance self.d = rotorDistance
self.cm = coefM self.cm = coefM
self.cf = coefF self.cf = coefF
self.uLim = uLim
self.lLim = lLim
def calc(self, data, x, u): def calc(self, data, x, u):
d, cf, cm = self.d, self.cf, self.cf d, cf, cm = self.d, self.cf, self.cf
S = np.array(np.zeros([self.nv, self.nu])) uLim, lLim = self.uLim, self.lLim
# Jacobian of torques with respect motor vertical forces
J_tau_f = np.array(np.zeros([self.nv, self.nu]))
if self.type == 'x': if self.type == 'x':
S[2:6, :4] = np.array([[1, 1, 1, 1], [-d, d, d, -d], [-d, d, -d, d], [-cm / cf, -cm / cf, cm / cf, cm / cf]]) J_tau_f[2:6, :4] = np.array([[1, 1, 1, 1], [-d, d, d, -d], [-d, d, -d, d], [-cm / cf, -cm / cf, cm / cf, cm / cf]])
elif self.type == '+': elif self.type == '+':
S[2:6, :4] = np.array([[1, 1, 1, 1], [0, d, 0, -d], [-d, 0, d, 0], [-cm / cf, cm / cf, -cm / cf, cm / cf]]) J_tau_f[2:6, :4] = np.array([[1, 1, 1, 1], [0, d, 0, -d], [-d, 0, d, 0], [-cm / cf, cm / cf, -cm / cf, cm / cf]])
np.fill_diagonal(S[6:, 4:], 1) np.fill_diagonal(J_tau_f[6:, 4:], 1)
data.a = np.dot(S, u) # Actuation function - tanh
range = uLim - lLim
range = uLim - lLim
f = lLim + range / 2 + range / 2 * np.tanh(u)
d_f = range / 2 * np.tanh(u)**2
J_f_u = np.zeros([4, 4])
np.fill_diagonal(J_f_u, d_f)
data.a = np.dot(J_tau_f, f)
return data.a return data.a
def calcDiff(self, data, x, u, recalc=True): def calcDiff(self, data, x, u, recalc=True):
......
source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment