ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ROS Simulink connection

asked 2015-12-16 02:02:16 -0500

Terry Su gravatar image

updated 2015-12-16 02:05:18 -0500

Hello,

Here I can use ROS to connect to the lidar (ubuntu14.04LTS, ROS:Jade, Lidar:Sick tim 561). I installed the MATLAB and Simulink in the same computer. Now I want to use the Simulink to connect to the ROS and then get the lidar's signals. does anyone do that before? Or I just can use the MATLAB to connect the ROS and get the lidar's signals only? (Matlab version: R2015b-trial version)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-12-16 10:19:22 -0500

codenotes gravatar image

I'd also wanted ROS in Simulink. My understanding looking at the early ROS for Matlab package was that it really wasn't designed for that. Subscribed messages come in as an aysnchonous callback; and that is not how simulink works. And I think the ROS/Matlab integration is all Java based on the ros-java bridge, and Simulink is really based around a C++ integration paradigm. They are really two different products kind of bound togther in my opinion.

Having worked a little with simulink SFunctions, I think you'd need to do a fair bit of work, but I have done essentially this kind of integration to make ROS messages accessible from a game engine (which works similarly to simulink in that you are processing things based on ticks/frames, both are really simulators at the end of the day.)

1) write a C++ function using the core roscpp library that monitors/subscribes to the topic but polls the message queue and retrieves the message on every call. You are basically looking to pop a message of the queue with every simulated time-tick/call on your function from simulink simulation your are running. ROS will keep a message queue for you of incoming messages that you can access. 2) wrap this function in the appropriate simulink wrapping (I believe the terminology is a SFunction, but it is been awhile) and make the outputs your new Simulink block a straight transfer from the message fields of the ROS message that you are interested in. 3) do this trick with every kind of message you are interested in.

To be fair, I know this is a fair amount of work; you'd need to understand a little simulink integration and the ros core libraries, and you will need to work in C++ which not everyone prefers. But it is not a ton of code and is certainly doable.

As an alternative, it may very well be possible to use the ros matlab bridge to capture the messages and push into in some form of global data structure in matlab, and simulink may be able to access and pop things off that data structure from within a block. I do know you can access matlab language functions from within a block, in fact, I think there is a type of simulink block that is, actually, just a matlab function you write. So if that function can pop off a message from this global queue, that may be all you need.

So that may be a simpler avenue. But I have always tended toward the C++ route. So I am not certain as to how you'd do the above.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2015-12-16 02:02:16 -0500

Seen: 399 times

Last updated: Dec 16 '15