필터 지우기
필터 지우기

simulink robot arm trajectory control

조회 수: 2 (최근 30일)
jone
jone 2014년 5월 30일
댓글: jone 2014년 6월 3일
Hi all I am trying to simulate 6dof robot arm with Force/position sensor feedback using matlab/simulink and msc.adams now I need to generate trajectory for robot I am using "matlab function" but I have problem "matlab function" doesn't update output variable until function finished
I tried simple code
function y = fcn(u)
%#codegen
coder.extrinsic('if','pause','min');
y = 1;
pause(1);
y = 2;
paus3(1);
y = 3;
pause(1);
y = 4;
pause(1);
but the y always 4 is there any way to make function update variables value in real time????? or is there other way to generate trajectory and modifying outputs according to force and position values?????
thanks all

답변 (1개)

Ryan Livingston
Ryan Livingston 2014년 5월 30일
On each time step of the simulation, the entirety of the code in your MATLAB Function Block will execute to produce the output y. This is why its value is always 4.
If you need access to the simulation time you can use a Clock Block:
as the input to the MATLAB Function Block. Then, on each time step, the input u will be the value of the current simulation time.
As a suggestion, making if an extrinsic will likely have unexpected consequences so removing that may be best. Similarly, min is supported for code generation so there should be little need to make it an extrinsic function.
  댓글 수: 3
Ryan Livingston
Ryan Livingston 2014년 6월 2일
Hi Jone, you should be able to use the clock block that I referenced in my answer. This will give you access to the simulation time so you can do a computation based upon it. If you need to log the previous state from the prior time step, you could use a persistent variable in the MATLAB Function Block.
jone
jone 2014년 6월 3일
Hi Ryan, thank you again but I am not sure that I got the idea, If that possible could you please give simple example.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Code Generation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by