Get data in real time, draw graphics changing in real time.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I'm getting real-time data from the manipulator, its current position.
channel = ddeinit('ipc_data', 'ipc_1');
data(1,1)=ddereq(channel,'mw1311'); % X coordinate
data(1,2)=ddereq(channel,'mw1312');% Y coordinate
data(1,3)=ddereq(channel,'mw1313');% Z coordinate
I need to represent the manipulator's position on the chart. and when the manipulator moves, it should be evident in the chart.
0 commentaires
Réponse acceptée
Paulo Silva
le 12 Avr 2011
clf
p=plot3(nan,nan,nan);
while 1
data(1,1)=ddereq(channel,'mw1311'); % X coordinate
data(1,2)=ddereq(channel,'mw1312');% Y coordinate
data(1,3)=ddereq(channel,'mw1313');% Z coordinate
set(p,'XData',[0 data(1,1)],'YData',[0 data(1,2)],'ZData',[0 data(1,3)])
pause(0.5) %read and draw data every 0.5 seconds
end
To stop the loop do CTRL+C
Alternative way, using a timer:
function test
fig=figure;
set(fig,'CloseRequestFcn','delete(gcf);')
h = plot3(NaN, NaN, NaN,'LineWidth',5);
t = timer('TimerFcn',@readdata,...
'Period', 0.5,'executionmode','fixedSpacing');start(t)
function readdata(g1,gg1)
if (~ishandle(fig)),stop(t),return,end
data(1,1)=ddereq(channel,'mw1311'); % X coordinate
data(1,2)=ddereq(channel,'mw1312');% Y coordinate
data(1,3)=ddereq(channel,'mw1313');% Z coordinate
set(p,'XData',[0 data(1,1)],'YData',[0 data(1,2)],'ZData',[0 data(1,3)])
end
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Instrument Control Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!