I need this because I have a 2xN array of pathpoints which I want to send via UDP Send/Receive from my raspberry to my robot, both running simulink. I know I can send a hugh Nx1 array and make it back to 2xN on the robot side.. but the next problem is, that I need to go through every column on robot.. which leads to the same problem as above :/
Column-by-Column (SIMULINK)
3 次查看(过去 30 天)
显示 更早的评论
Hey guys,
I would like to do a "slow" iteration..
As far as I know Simulink first executes a block and passes its value over. Which means, If I have a loop it finishes the loop and gives out the last value. But I need to give specific elements from my array as a command and send it. Which means I need to execute element 1 followed by element 2 in a ordered manner.
I would like to have sth like this pseudocode
A = 2x6 (like a constant block [1 2 3 4 5 6; 0 0 0 0 0 0])
for i = 1:6 do / or while loop
output col 1 of A
wait like 5 seconds or if-condition (like if trigger == 1 -> only(!) next col and wait for next trigger to output next col)
output col 2 of A
wait like 5 seconds or if-condition
output col 3 of A
..etc..
end loop
I already tried an assignment block.. but it outputs the full matrix
..and I tried direct look-up table... but I do not know how to get a right counter/incrementer for it.. sth like a triggered or slow incrementation..
In MATLAB you can write a pause and some commands in each loop step but a pause in simulink pauses the whole simulation and that is not what I want at all..
any tips?
采纳的回答
Jonas
2020-4-7
编辑:Jonas
2020-4-7
You need the Selector block to capture the column you need, and then a Trigger Subsystem which executes on your command. You can also use a subsystem triggered by a function call. You can control the time delay between executions by using a Stateflow with the state transition 'after(5,sec)' for example, or implement an integrator block with gain 1, which will build up in real-time and you then trigger based on when it reaches a threshold.
You can also in Stateflow maintain a counter and increment with each sample time. Since you know your sample time, you can let the UDP Send trigger after the counter has reached a value.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!