梳妆谐振器的matlab实现,基于HOPF振荡器的CPG单元模型matlab实现

代码为实现仿生四足机器人技术(罗庆生等)中关于CPG网络控制模型的部分的绘图。

本人新手 代码不保证正确性

方程:

7a4ddb03da1abc1bd042947ef8d06642.png

两种方法通用一个函数:

代码中变量含义:

a=

0e716f2c95281ea081ca17b2ccc25e92.png  B=

4ec990637e996cc5d2025af0407673ee.png  u= 

629dc53d84931af2fca12ae9debbfdd8.png   Wsw=

cff4095e55645c015062ba8e033ce4c4.png  W=

b8c3119e4321ff1c1d632873cf88ea67.png th=

3484c1527177ac74ef92d123ac538fe3.png  Q=

175a24c445ff2789b1a42a7d9224e7da.png A=a

x=[x1;y1;x2;y2......]

代码中的

131414a68f3fd246fccd252a02c657f7.png通过书中的公式 使用

4ec990637e996cc5d2025af0407673ee.png (占空比)来得出;相位关系可参照波士顿动力真的无可企及吗?一步步剖析四足机器人技术(一)中相关内容

function dydt = f( t,x )

%F 此处显示有关此函数的摘要

% 此处显示详细说明

a=10000;

B=0.75;

u=0.4;

Wsw=5*pi;

A=100;

QLF=0;%1

QRH=0.25;%3 0.25

QRF=1;%2

QLH=1;%4

W1=(((1-B)/B)*Wsw)/(exp(-1*A*x(2))+1)+(Wsw/(exp(A*x(2))+1));

W2=(((1-B)/B)*Wsw)/(exp(-1*A*x(4))+1)+(Wsw/(exp(A*x(4))+1));

W3=(((1-B)/B)*Wsw)/(exp(-1*A*x(6))+1)+(Wsw/(exp(A*x(6))+1));

W4=(((1-B)/B)*Wsw)/(exp(-1*A*x(8))+1)+(Wsw/(exp(A*x(8))+1));

r1=x(1)^2+x(2)^2;

r2=x(3)^2+x(4)^2;

r3=x(5)^2+x(6)^2;

r4=x(7)^2+x(8)^2;

if QLH~=0

QRF=B-QRH;

QLH=B;

else

if QLH==0

QRF=QRH;

QLH=QLF;

end

end

%1行

% QLF=0;%1

% QRH=0.25;%3

%

% QRF=0;%2

% QLH=0;%4

% th11=0;

th11=2*pi*(QLF-QLF);

R11 = [cos(th11), -sin(th11);

sin(th11), cos(th11)];

%th21=-pi;

th21=2*pi*(QLF-QRF);

R21 = [cos(th21), -sin(th21);

sin(th21), cos(th21)];

%th31=-pi/2;

th31=2*pi*(QLF-QRH);

R31 = [cos(th31), -sin(th31);

sin(th31), cos(th31)];

% th41=-3*pi/2;

th41=2*pi*(QLF-QLH);

R41 = [cos(th41), -sin(th41);

sin(th41), cos(th41)];

%2行

% th12=pi;

th12=2*pi*(QRF-QLF);

R12 = [cos(th12), -sin(th12);

sin(th12), cos(th12)];

% th22=0;

th22=2*pi*(QRF-QRF);

R22 = [cos(th22), -sin(th22);

sin(th22), cos(th22)];

% th32=pi/2;

th32=2*pi*(QRF-QRH);

R32 = [cos(th32), -sin(th32);

sin(th32), cos(th32)];

% th42=-pi/2;

th42=2*pi*(QRF-QLH);

R42 = [cos(th42), -sin(th42);

sin(th42), cos(th42)];

%3行

% th13=pi/2;

th13=2*pi*(QRH-QLF);

R13 = [cos(th13), -sin(th13);

sin(th13), cos(th13)];

% th23=-pi/2;

th23=2*pi*(QRH-QRF);

R23 = [cos(th23), -sin(th23);

sin(th23), cos(th23)];

% th33=0;

th33=2*pi*(QRH-QRH);

R33 = [cos(th33), -sin(th33);

sin(th33), cos(th33)];

% th43=-pi;

th43=2*pi*(QRH-QLH);

R43 = [cos(th43), -sin(th43);

sin(th43), cos(th43)];

%4行

% th14=3*pi/2;

th14=2*pi*(QLH-QLF);

R14 = [cos(th14), -sin(th14);

sin(th14), cos(th14)];

% th24=pi/2;

th24=2*pi*(QLH-QRF);

R24 = [cos(th24), -sin(th24);

sin(th24), cos(th24)];

% th34=pi;

th34=2*pi*(QLH-QRH);

R34 = [cos(th34), -sin(th34);

sin(th34), cos(th34)];

% th44=0;

th44=2*pi*(QLH-QLH);

R44 = [cos(th44), -sin(th44);

sin(th44), cos(th44)];

RR=[R11,R21,R31,R41;

R12,R22,R32,R42

R13,R23,R33,R43

R14,R24,R34,R44];

FF=[a*(u-r1)*x(1)-W1*x(2);

a*(u-r1)*x(2)+W1*x(1);

a*(u-r2)*x(3)-W2*x(4);

a*(u-r2)*x(4)+W2*x(3);

a*(u-r3)*x(5)-W3*x(6);

a*(u-r3)*x(6)+W3*x(5);

a*(u-r4)*x(7)-W4*x(8);

a*(u-r4)*x(8)+W4*x(7);

];

RR(abs(RR)-0<0.00001)=0;

temp=RR*x;

dydt=FF+RR*x;

matlab自带函数实现

使用ode45函数绘图

[t,y] = ode45(@f,[0 5],[0.1;0;0;0;0;0;0;0]);

%这里是膝关节处理

for i=1:length(y)

if y(i,2)<=0

y(i,2)=-1*sign(-1)*0.7067*y(i,2);

else

y(i,2)=0;

end

if y(i,4)<=0

y(i,4)=-1*sign(-1)*0.7067*y(i,4);

else

y(i,4)=0;

end

if y(i,6)<=0

y(i,6)=-1*sign(-1)*0.7067*y(i,6);

else

y(i,6)=0;

end

if y(i,8)<=0

y(i,8)=-1*sign(-1)*0.7067*y(i,8);

else

y(i,8)=0;

end

end

subplot(4,1,1)

plot(t,y(:,1),t,y(:,2));

subplot(4,1,2)

plot(t,y(:,3),t,y(:,4));

subplot(4,1,3)

plot(t,y(:,5),t,y(:,6));

subplot(4,1,4)

plot(t,y(:,7),t,y(:,8));

grid;

matlab手动欧拉法

out=[]%输出变量

count=1;

temp=f([],[0.1;0;0;0;0;0;0;0]);%后面参数为初值

y=zeros(8,1);

y=y+temp*0.0001;%0.0001为步长

for i=0:0.0001:5

temp=f([],y);

y=y+temp*0.0001;

%处理膝关节

if y(2)<=0

out(count,2)=-1*sign(-1)*0.7067*y(2);

else

out(count,2)=0;

end

if y(4)<=0

out(count,4)=-1*sign(-1)*0.7067*y(4);

else

out(count,4)=0;

end

if y(6)<=0

out(count,6)=-1*sign(-1)*0.7067*y(6);

else

out(count,6)=0;

end

if y(8)<=0

out(count,8)=-1*sign(-1)*0.7067*y(8);

else

out(count,8)=0;

end

out(count,1)=y(1);

%out(count,2)=y(2);

out(count,3)=y(3);

% out(count,4)=y(4);

out(count,5)=y(5);

% out(count,6)=y(6);

out(count,7)=y(7);

% out(count,8)=y(8);

count=count+1;

end

t=0:0.0001:5;

%绘图

subplot(4,1,1)

plot(t,out(:,1),t,out(:,2));

title('LF')

subplot(4,1,2)

plot(t,out(:,3),t,out(:,4));

title('RF')

subplot(4,1,3)

plot(t,out(:,5),t,out(:,6));

title('RH')

subplot(4,1,4)

plot(t,out(:,7),t,out(:,8));

title('LH')

grid;

效果:

ode45:

ba7063706ee8b641728e249a5257d1db.png

手动欧拉法

0bafcf575be4487461b5e6a468f1025c.png

simulink:

1676ae44aea1db9302abb4ec616add4d.png

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Hopf振荡器是一种常见的动力学模型,常用于描述生物、物理和工程学科中的周期性运动。而MATLAB是一种强大的数学工具箱,适用于数据分析、科学计算、模型仿真等多个领域。因此,结合MATLAB进行Hopf振荡器的仿真与研究具有广泛的应用价值。 在MATLAB中,Hopf振荡器模型通常采用一系列微分方程来描述。这些微分方程由Hopf本人在20世纪初提出,描述了一种由非线性时间演化方程组成的动力学系统,其运动可近似为谐波运动。 具体而言,Hopf振荡器模型中会涉及到一系列参数,包括自身演化的时间、非线性系数、耗散项等。这些参数会为Hopf振荡器的振荡频率和幅度等特性产生影响,通过MATLAB的程序仿真可以帮助我们更好地理解Hopf振荡器模型的行为特性。 除此之外,MATLAB还提供了各种计算工具和图形化界面,可以方便地进行解析分析和可视化展示。包括拟合、趋势分析、频谱分析等,都可以较为简便地完成。因此,MATLAB Hopf振荡器的研究可帮助我们探究复杂动力学系统的本质规律和性质,具有重要的理论和实际应用意义。 ### 回答2: MATLAB Hopf 振荡器是一种基于 Hopf 器件设计和实现振荡器,用于生成具有特定频率和对称性的信号。 该振荡器在动态系统研究和信号处理领域中广泛应用,可用于探究自然界中的物理行为,如天体物理、流体动力学和生态学等。 除此之外,MATLAB Hopf 振荡器也用于数字信号处理、通信系统、压缩和编解码等技术领域。 MATLAB Hopf 振荡器由跨越各个领域的科学家共同研究和开发,并通过物理学、数学学科的理论基础和 MATLAB 编程语言的工具实现。 它主要由状态方程、耦合函数和信号调制器组成,可通过调整参数来生成不同类型、不同频率、不同对称性的振荡信号。 概括而言,MATLAB Hopf 振荡器广泛应用于许多领域,是一项基于理论、数学和计算机科学相结合的前沿技术,为实现信号处理、动态系统研究和数字通信等提供了有力支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值