Ask Your Question
0

convert simulink to rosserial

asked 2019-06-04 06:56:25 -0500

jamesislost gravatar image

updated 2019-06-04 09:02:58 -0500

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:

image description

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.

edit retag flag offensive close merge delete

Comments

1

rosserial is not a generic transport for ROS messages, but requires both sides to be using rosserial. Are both sides doing that?

gvdhoorn gravatar imagegvdhoorn ( 2019-06-04 07:15:58 -0500 )edit
1

And you have 13 karma, please attach images directly to the question. Do not link to off-site hosting.

gvdhoorn gravatar imagegvdhoorn ( 2019-06-04 07:16:27 -0500 )edit

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

jamesislost gravatar imagejamesislost ( 2019-06-04 09:15:27 -0500 )edit

I've reported the failing image uploads: ros-infrastructure/answers.ros.org#192.

gvdhoorn gravatar imagegvdhoorn ( 2019-06-04 09:18:29 -0500 )edit

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?

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.

gvdhoorn gravatar imagegvdhoorn ( 2019-06-04 09:19:11 -0500 )edit

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 <ros.h> -#include <std_msgs string.h=""> ros::NodeHandle nh;

jamesislost gravatar imagejamesislost ( 2019-06-04 09:23:46 -0500 )edit

I don't understand your last comment.

gvdhoorn gravatar imagegvdhoorn ( 2019-06-04 11:20:08 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-06-13 16:29:25 -0500

SMEAC gravatar image

updated 2019-06-13 16:30:29 -0500

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

edit flag offensive delete link more

Comments

Nice find.

Does this work with the "ROS" blocks that OP has integrated into his simulink model?

gvdhoorn gravatar imagegvdhoorn ( 2019-06-14 02:52:51 -0500 )edit

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.

SMEAC gravatar imageSMEAC ( 2019-06-14 03:00:03 -0500 )edit

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.

gvdhoorn gravatar imagegvdhoorn ( 2019-06-14 03:03:20 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-06-04 06:56:25 -0500

Seen: 294 times

Last updated: Jun 13