4

I am trying to build a posture regulation control which works with acceleration inputs.

Doing it with velocity inputs,I have well understood how it works. Moreover,for now, the controller only controls the position $x,y$ and sends to zero these two coordinates, so it brings $(x,y)=(0,0)$ and does not control the orientation.

I have built the acceleration level control for this case, and what I get is:

enter image description here

where we can see that the $x$ and $y$ coordinates go to zero, and $\theta$ is not controlled, as I expected. Even if the acceleration profile is a bit weird (and this makes me think that the error may be in the implementation, but I am not sure):

enter image description here

I think the acceleration is weird because I was expecting a profile of the type:

enter image description here

where on top there is the linear acceleration and the bottom one is the angular acceleration.

So I am not sure I am doing well. In this case, I have defined the polar coordinates:

$R = \sqrt{x^2+y^2}$

$\gamma=atan2(y.x)-\theta$

and the controller is:

 x = state(1);
 y = state(2);
 theta = state(3);
 v_state = state(4);
 omega_state = state(5);
 theta_w = state(6);

k_1 = gain(1); k_2 = gain(2); k_3 = gain(3); k_4 = gain(4); k_5 = gain(5);

temp = x^2+y^2;

R = sqrt(temp); gamma = atan2(y,x)-theta; delta = gamma + theta;

sinc = sin(gamma)*sign(cos(gamma));

v=k_1Rsign(cos(gamma)); omega = k_2(k_1sinc(gamma+k_3delta)/(2gamma + k_3delta));

a = k_4(v-v_state); alpha = k_4(omega-omega_state);

inputs = [a;alpha];

where $v$ and $\omega$ can be obtained with the same procedure that I have written below, or also from the feedback linearization as it is done in the paper.

Moreover, v_state and omega_state are respectively linear and angular velocities of the system, that now have become states, since I want acceleration inputs.

And the model, written in Matlab , is:

a = inputs(1);
alpha = inputs(2);

x = state(1); y = state(2); theta = state(3); v_state = state(4); omega_state = state(5);

x_dot = -v_statecos(theta)+yomega_state; y_dot = -v_statesin(theta)-xomega_state; theta_dot = omega_state; theta_w_dot = -omega_state; v_dot = a; omega_dot = alpha;

Note: the above codes are from Simulink blocks.

Now, I would like to control also the final orientation,and bring it to zero, so I define the polar coordinate(in the code above I have already written the control law that should control also the final orientation that I am going to derive below):

$\delta = \theta + \gamma$

and if I take the derivatives of all these polar coordinates, I get the following kinematic model:

$\dot{R}=-vcos\gamma$

$\dot{\gamma}=v\frac{sin\gamma}{R}-2\omega$

$\dot{\delta}=v\frac{sin\gamma}{R}-\omega$

and the objective is to have $R=0, \gamma=0,\delta=0$.

Now, to derive the control law that controls also the orientation I use a Lyapunov function:

$V = \frac{1}{2}(R^2+\gamma^2+\delta^2)>0$

$\dot{V}=R\dot{R}+\gamma\dot{\gamma}+\delta\dot{\delta}= R(-vcos\gamma)+\gamma(v\frac{vsin\gamma}{R}-2\omega)+\delta(\frac{vsin\gamma}{R}-\omega)= v(-Rcos\gamma + \gamma\frac{sin\gamma}{R}-\delta \frac{sin\gamma}{R})-\omega(2\gamma+\delta)$

and this has to be less than or equal to zero for the Lyapunov criterion.

From here, I derive that

$v = k_1\cdot Rcos\gamma$

$\omega = \frac{k_1\cdot sin\gamma\cdot cos\gamma(\gamma+k_2\delta)}{2\gamma+k_2\delta}$

but if i try these and use them as desired linear and angular velocities, I get :

enter image description here

so the orientation still does not go to zero.

I don't understand what I am doing wrong, and I have been on this for a while now and I am really stuck. The reasoning seems correct, at least to me, but apparently I am doing something wrong that I don't get.

Can somebody please help me understand what I am doing wrong? Do you think my approach is correct, or should I try another way for solving the problem?

For the implementation I have used Matlab and Simulink.

Could the problem be connected to the initial configuration? I really don't get what I am doing wrong, i am trying from a while now, but I am really stuck.

I have also tried to not make the values of $\gamma$ and $\delta$ don't go to large, so I have added this lines of code:

gamma_t = atan2(y,x)-theta;
delta_t = gamma_t + theta;

gamma = mod(gamma_t+pi,2pi)-pi; delta = mod(delta_t+pi,2pi)-pi;

but this didn't solve the problem.

About the plots, if it can add something, I have done in the following way:

x=configuration.signals.values(:,1);
y=configuration.signals.values(:,2);
theta=configuration.signals.values(:,3);
t=configuration.time;
a=inputs.signals.values(:,1);
alpha=inputs.signals.values(:,2);

figure(1); plot(t,x,t,y,t,theta);grid legend('x','y','theta');

figure(2); plot(t,a,t,alpha);grid legend('a','alpha');

if I have to add something to the question to make it clearer please tell me. I really don't know how to move on.

I am trying to read several papers and references, such as:

Stabilized Feedback Control of Unicycle Mobile Robots

Posture regulation for unicycle-like robots with prescribed performance guarantees

and they seem to use the same approch I have used, so there has to be some mistake in some step I have done, which I do not understand.

Can someone please help me?

J.D.
  • 425
  • So, you have the Lyapunov function analysis, but your simulations do not work? It is always a good idea to compute (and plot) the Lyapunov function and its time derivative. It will give you an idea at which moment the derivative becomes positive. Thus, you can validate your simulations vs. theoretical results. – Arastas Nov 04 '20 at 09:34
  • The Lyapunov function you have does not satisfy $\dot{V}\leq 0$ unless $k_{2} = 1$. – dgadjov Nov 05 '20 at 05:38
  • thank you for the comments. @AsAnExerciseProve could you please tell me how did you verify this? I ask because I am starting to think that the problem is due to a bad gain tuning. Thank you in advance. – J.D. Nov 05 '20 at 19:19

1 Answers1

2

Something is wrong with your Lyapunov analysis.

\begin{align} \dot{V}&=R\dot{R}+\gamma\dot{\gamma}+\delta\dot{\delta} \\ &= R(-vcos\gamma)+\gamma(v\frac{sin\gamma}{R}-2\omega)+\delta(v\frac{sin\gamma}{R}-\omega) \\ &= v(-Rcos\gamma + \gamma\frac{sin\gamma}{R}+\delta \frac{sin\gamma}{R})-\omega(2\gamma+\delta) \end{align} You suggested using, \begin{align} v &= k_1\cdot Rcos\gamma \\ \omega &= \frac{k_1\cdot sin\gamma\cdot cos\gamma(\gamma+k_2\delta)}{2\gamma+k_2\delta} \end{align} Substituiting this in we get that, \begin{align} \dot{V} &= k_1\cdot Rcos\gamma(-Rcos\gamma + \gamma\frac{sin\gamma}{R}+\delta \frac{sin\gamma}{R})-\frac{k_1\cdot sin\gamma\cdot cos\gamma(\gamma+k_2\delta)}{2\gamma+k_2\delta}(2\gamma+\delta) \\ &= -k_{1}R^{2}cos^{2}\gamma + k_{1}(\gamma + \delta)cos\gamma sin\gamma -\frac{k_1\cdot sin\gamma\cdot cos\gamma(\gamma+k_2\delta)}{2\gamma+k_2\delta}(2\gamma+\delta) \end{align} If we assume that $k_{2} =1$ then, \begin{align} \dot{V} &= -k_{1}R^{2}cos^{2}\gamma + k_{1}(\gamma + \delta)cos\gamma sin\gamma -\frac{k_1\cdot sin\gamma\cdot cos\gamma(\gamma+\delta)}{2\gamma+\delta}(2\gamma+\delta) \\ &= -k_{1}R^{2}cos^{2}\gamma + k_{1}(\gamma + \delta)cos\gamma sin\gamma - k_1\cdot sin\gamma\cdot cos\gamma(\gamma+\delta) \\ &= -k_{1}R^{2}cos^{2}\gamma \end{align} and $\dot{V}\leq 0$ if $k_{1}>0$. Therefore, $\dot{V}=0$ when $\gamma = \frac{\pi}{2} + \pi k$ or $R = 0$. Though your dynamics when $R=0$ are not well defined.

If $k_{1}\neq 1$ then \begin{align} \dot{V} &= -k_{1}R^{2}cos^{2}\gamma + \left(k_{1}(\gamma + \delta) -\frac{k_1(\gamma+k_2\delta)}{2\gamma+k_2\delta}(2\gamma+\delta)\right)cos\gamma sin\gamma \\ &= -k_{1}R^{2}cos^{2}\gamma + k_{1}\left((\gamma + \delta) -\frac{(\gamma+k_2\delta)}{2\gamma+k_2\delta}(2\gamma+\delta)\right)\frac{1}{2}sin(2\gamma) \end{align} As you increase $\gamma$ the second term will oscilate from being positive and negative and therefore $\dot{V}\not\leq 0$.

dgadjov
  • 1,359
  • 8
  • 11
  • Thanks for the answer. I have tried changing $\omega$, and I have found: $\omega=k_2(2\gamma+\delta)+k_1\frac{cos\gamma sin\gamma(\gamma+\delta))}{2\gamma+\delta}$ and applying the reasoning that you suggested I have $\dot{V}<0$, but still does not work. – J.D. Nov 06 '20 at 07:07
  • And also I think that it should be $\dot{V}<0$ for any $k_i>0$. since the Lyapunov function is; $\dot{V}=-k_1R^2cos^2\gamma-k_2(2\gamma+\delta)^2<0$.So, I am really lost and don't get what I am doing wrong. – J.D. Nov 06 '20 at 07:21
  • I think the problem is numerical issues. The Lyapunov function shows that you converge to the largest invariant set, i.e., where $2\gamma + \delta = 0$ and either $R = 0$ or $\gamma = 0.5\pi + \pi k$. When you approach $2\gamma + \delta = 0$ the value of $\omega$ approaches infinity. The ode solver is probably "jumping" over the equilibrium point because of this extremely large input. Your dynamics are not well defined at the equilibrium point and neither is $\omega$. – dgadjov Nov 06 '20 at 18:22
  • thank you again and sorry if i bother again. So, the fact that the system converges to the largest invariant set means that the $\dot{V}$ that I have found is correct, and so the inputs should be the correct ones to drive the system to the equilibrium , is that right? – J.D. Nov 06 '20 at 18:46
  • I think in theory, yes but in practice, I don't know. You will have issues with $\omega$ exploding because when $2\gamma + \delta = 0$, $\omega$ is not well defined. Also when $R=0$ your dynamics are not well defined. These ill-defined points are your equilibriums so as you get closer to the eq. the dynamics have $|\dot{\gamma}|$, $|\dot{\delta}|$ and $\omega$ going off to infinity. – dgadjov Nov 06 '20 at 20:45
  • I am still on this, and I have seen that if I initialize my system at $x=1$,$y=0$, in the simulation (using Matlab\simulink) I get the folllowing error message: Evaluation of expression resulted in an invalid output. Only finite double vector or matrix outputs are supported. Do you think this is related to what you said? Thanks in advance. – J.D. Nov 17 '20 at 06:58
  • I think the problem is given by the $(2\gamma+\delta)$ at the denominator, which is equal to $0$ when $y=0$, but I don't know how to solve it. Do you have any idea? Thank you in advance. – J.D. Nov 17 '20 at 07:29
  • Sorry for writing three comments in a row. I have tried substitute $(2\gamma+\delta)$ at the denominator with $sign(2\gamma+\delta)$, but this time multiplied, not divided, and it seems to work. But I don't understand why I am allowed to do so, I have just seen it doing it many times. If you can, could you explain to me why it works? Thanks again. – J.D. Nov 17 '20 at 07:32
  • Have you tried this with large initial conditions? I have a feeling that this will fail for some initial conditions. – dgadjov Nov 18 '20 at 04:25
  • sorry if I keep commenting, but what if I would like to use $\theta_w$ instead of $\theta$? So, I would like to converge at zero with $(x,y,\theta_w)=(0,0,0)$, how could i do? I have substitute $\theta_w$ with $\theta$ everywhere, also in the computation of the polar coordinates, and using the same approch, I don't get the desired result. Thanks in advance, and really sorry if i keep bothering. – J.D. Nov 24 '20 at 13:53
  • I don't understand why, since the derivative of the Lyapunov function is negative, which is in the case I use $\theta_w$: $\dot{V}=k_1R^{2}cos^2\gamma-k_2\delta^{2}$, and proving it with LaSalle it gives me that the system is asyntotically stable. But yet it does not work. – J.D. Nov 24 '20 at 14:36