convert simulink to rosserial
Hi, I've been trying to write Rosserial Arduino script on a tight timeline and I am struggling with writing the script. This is this first time working with arduino as part of a group that haven't worked with ROS.
A simulink model of what I'm trying to achieve is posted here:
Is there some way of converting this into script automatically? I've done the blinker and chatter publishing and subscribing tutorials on the wiki but they aren't clear how to extract the specific messages from the topic. eg. within local_plan: x = Poses.Pose.Position.X z = Poses.Pose.Position.Z
And also how to collect the xyz vel/accel IMU data and collect into a Topic.
Sorry if this is a few questions at once but help would be greatly appreciated. I can comment the code that I've tried writing but it is just adapted from the blinker and chatter tutorials and is pretty incoherent.
Asked by jamesislost on 2019-06-04 06:56:25 UTC
Answers
For an example of how to use rosserial with Simulink, look to the following link on the Mathworks Website:ROS Deployed on Arduino running in External Mode in Simulink
Asked by SMEAC on 2019-06-13 16:29:25 UTC
Comments
Nice find.
Does this work with the "ROS" blocks that OP has integrated into his simulink model?
Asked by gvdhoorn on 2019-06-14 02:52:51 UTC
Unfortunately not. For the ROS Publish Subscribe Blocks to work, matlab needs to build the system with a Linux kernel. As good as Arduinos are, that don't quite manage that. This is a valid solution for RASPI or other embedded systems. But with the Arduino, we are stuck with the ROSSerial.
Asked by SMEAC on 2019-06-14 03:00:03 UTC
I don't feel it's a limitation per se.
I just wanted to get that cleared up, as future readers might assume that the approach you link to is something that can be used with the "ROS" blocks shown in the model by the OP.
Asked by gvdhoorn on 2019-06-14 03:03:20 UTC
Comments
rosserial
is not a generic transport for ROS messages, but requires both sides to be usingrosserial
. Are both sides doing that?Asked by gvdhoorn on 2019-06-04 07:15:58 UTC
And you have 13 karma, please attach images directly to the question. Do not link to off-site hosting.
Asked by gvdhoorn on 2019-06-04 07:16:27 UTC
Yeah that was something I couldn't find an explicit statement of. Do you mean I should have a file on the ROS computer stating that the arduino should be treated as a node e.g. > rosrun rosserial_arduino serial_node.py _baud:=500000 _port:=/dev/ttyUSB0 And then another script on the board itself with the pub/sub commands on? Or something else? Thanks
Asked by jamesislost on 2019-06-04 09:15:27 UTC
I've reported the failing image uploads: ros-infrastructure/answers.ros.org#192.
Asked by gvdhoorn on 2019-06-04 09:18:29 UTC
on both sides you need to be using
rosserial
. Otherwise it won't work.So I guess the answer to your question would be: yes.
But afaik, the generated code from simulink doesn't use
rosserial
, so that wouldn't work.Asked by gvdhoorn on 2019-06-04 09:19:11 UTC
Oh okay, yeah I wasn't sure if there was a shortcut I could take. So if I write using Rosserial Arduino is it sufficient to have the roslib and in the header include: -#include
-#include
ros::NodeHandle nh;
Asked by jamesislost on 2019-06-04 09:23:46 UTC
I don't understand your last comment.
Asked by gvdhoorn on 2019-06-04 11:20:08 UTC