Ask Your Question
2

Simple publisher in rosmatlab

asked 2013-08-12 03:38:26 -0500

uyaseen gravatar image

updated 2014-04-20 14:09:47 -0500

ngrennan gravatar image

Hi,

I am trying to write a simple publisher using rosmatlab, rosmatlab is installed perfectly and I can access ros-api (limited functionality) in the matlab command window, however I am having hard time advertising a topic, here's the matlab script:

argc=1;
argv='';
ros.init(argc,argv,'mat_ros');
P = ros.Publisher;
topic_name = 'chatter';
msg_type = 'std_msgs.String';
queue_size = 1000;
P.advertise(topic_name,'std_msgs.String',1000);

Error:

Error using internal
[ROS] Publisher.advertise: unknown datatype 'std_msgs.String'

Error in ros.Publisher/advertise (line 38)
        result = internal(obj, 'advertise', topic, datatype,
        varargin{:});

I have tried to change the datatype to 'String', 'string','ros_string' etc etc but still I am getting the same error. If I pass second arguments without the quotes, then I get this:

P.advertise(topic_name, std_msgs.String,1000);

Error using internal
[ROS] Publisher.advertise: need a datatype as 2nd argument

Error in ros.Publisher/advertise (line 38)
        result = internal(obj, 'advertise', topic, datatype,
        varargin{:});

Any idea how can I get rid of this data-type error ? If someone can please share a simple publisher/subscriber script for rosmatlab ? as the wiki page of rosmatlab only has the installation instructions and no sample code.

Thanks

Regards,

Usama

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2013-08-28 04:13:23 -0500

uyaseen gravatar image

I finally figured out that Message types have to be specified using the 'package/Message' syntax i.e 'std_msgs/String'. All message packages beside std_msgs have to be imported before the first usage by just entering the package name without arguments (e.g. geometry_msgs, sensor_msgs, ...).

edit flag offensive delete link more

Comments

1

Hi, How did you figure out the Matlab commands in rosmatlab. I am using rosmatlab package aswell. I want to publish some String message. But I couldnot find any proper Documentation for it.Can you help me.

Ram99 gravatar imageRam99 ( 2013-12-08 10:31:13 -0500 )edit

@Ram99 - this is a Q&A site, not a forum. Please create a new question rather than asking in the comments of an old one.

lindzey gravatar imagelindzey ( 2013-12-08 17:31:45 -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: 2013-08-12 03:38:26 -0500

Seen: 261 times

Last updated: Dec 08 '13