IEEE Robotics & Automation Magazine - June 2015 - 19
to the function
function rxcallback(src,
msg)
disp([char(msg.
Data()), sprintf('\n
Message received: %s',
datestr(now))]);
which is invoked on every message
receipt.
Next, let us look at a more complex message: the velocity twist with
time stamp
msg =
rosmessage('geometry_
msgs/TwistStamped'),
and we can view its definition
>> definition(msg)
% A Twist with reference
coordinate frame and
timestamp std_msgs/Header Header Twist Twist
and the service function is
and then invoking the service
function resp =
SumCallback(˜,req,resp)
resp.Sum = req.A +
req.B;
sumresp = call(sumclient,
s u m r e q , ' T i m e o u t ', 3 )
>> sumresp.Sum ans = 3.
and this can now be invoked from any
ROS node
$ rosservice call /sum2 1
2 sum: 3
or from inside MATLAB by first creating a service client
sumclient = rossvcclient
('/sum'),
creating a message with the numbers to
be added
sumreq = r o s m e s s a g e
( s u m c l i e n t );
sumreq.A = 2;
sumreq.B = 1,
There is also the capability to
read and write ROS bag files. First,
we open the bag file and list the
available topics:
bag = rosbag ('quad-201406-13.bag')bag.
AvailableTopics.
To extract all the images on the topic
/ p r e v i e w , we use the s e l e c t
method to choose the particular
topic, use readMessages to extract a cell array of 100 messages
that happen to be of type s e n sormsgs/Image, and then convert
this to a cell array of images that can
be displayed
or access one of its fields
msg.Twist.Linear.X = 0;
Custom messages are also possible
but beyond the scope of this article.
(See http://www.mathworks.com/
matlabcentral/fileexchange/49810 for
details.) The ROS parameters can be
accessed via a ParameterTree object returned by
ptree = rosparam,
and we can use it to set, get, create, or
delete parameters in the ROS parameter server.
ptree.get('rosversion')
ptree.set('myparameter', 23)
and parameters can have integer, logical, char, double, or cell array types.
We can also access and create services in MATLAB code. Inspired by
the TwoInts example given in the
ROS tutorial, we can easily create a
service to add two integers
sumserver = rossvcserver('/
sum', rostype.
roscpp_tutorials_TwoInts, @
SumCallback),
june 2015
*
IEEE ROBOTICS & AUTOMATION MAGAZINE
*
19
http://www.mathworks.com/
Table of Contents for the Digital Edition of IEEE Robotics & Automation Magazine - June 2015
IEEE Robotics & Automation Magazine - June 2015 - Cover1
IEEE Robotics & Automation Magazine - June 2015 - Cover2
IEEE Robotics & Automation Magazine - June 2015 - 1
IEEE Robotics & Automation Magazine - June 2015 - 2
IEEE Robotics & Automation Magazine - June 2015 - 3
IEEE Robotics & Automation Magazine - June 2015 - 4
IEEE Robotics & Automation Magazine - June 2015 - 5
IEEE Robotics & Automation Magazine - June 2015 - 6
IEEE Robotics & Automation Magazine - June 2015 - 7
IEEE Robotics & Automation Magazine - June 2015 - 8
IEEE Robotics & Automation Magazine - June 2015 - 9
IEEE Robotics & Automation Magazine - June 2015 - 10
IEEE Robotics & Automation Magazine - June 2015 - 11
IEEE Robotics & Automation Magazine - June 2015 - 12
IEEE Robotics & Automation Magazine - June 2015 - 13
IEEE Robotics & Automation Magazine - June 2015 - 14
IEEE Robotics & Automation Magazine - June 2015 - 15
IEEE Robotics & Automation Magazine - June 2015 - 16
IEEE Robotics & Automation Magazine - June 2015 - 17
IEEE Robotics & Automation Magazine - June 2015 - 18
IEEE Robotics & Automation Magazine - June 2015 - 19
IEEE Robotics & Automation Magazine - June 2015 - 20
IEEE Robotics & Automation Magazine - June 2015 - 21
IEEE Robotics & Automation Magazine - June 2015 - 22
IEEE Robotics & Automation Magazine - June 2015 - 23
IEEE Robotics & Automation Magazine - June 2015 - 24
IEEE Robotics & Automation Magazine - June 2015 - 25
IEEE Robotics & Automation Magazine - June 2015 - 26
IEEE Robotics & Automation Magazine - June 2015 - 27
IEEE Robotics & Automation Magazine - June 2015 - 28
IEEE Robotics & Automation Magazine - June 2015 - 29
IEEE Robotics & Automation Magazine - June 2015 - 30
IEEE Robotics & Automation Magazine - June 2015 - 31
IEEE Robotics & Automation Magazine - June 2015 - 32
IEEE Robotics & Automation Magazine - June 2015 - 33
IEEE Robotics & Automation Magazine - June 2015 - 34
IEEE Robotics & Automation Magazine - June 2015 - 35
IEEE Robotics & Automation Magazine - June 2015 - 36
IEEE Robotics & Automation Magazine - June 2015 - 37
IEEE Robotics & Automation Magazine - June 2015 - 38
IEEE Robotics & Automation Magazine - June 2015 - 39
IEEE Robotics & Automation Magazine - June 2015 - 40
IEEE Robotics & Automation Magazine - June 2015 - 41
IEEE Robotics & Automation Magazine - June 2015 - 42
IEEE Robotics & Automation Magazine - June 2015 - 43
IEEE Robotics & Automation Magazine - June 2015 - 44
IEEE Robotics & Automation Magazine - June 2015 - 45
IEEE Robotics & Automation Magazine - June 2015 - 46
IEEE Robotics & Automation Magazine - June 2015 - 47
IEEE Robotics & Automation Magazine - June 2015 - 48
IEEE Robotics & Automation Magazine - June 2015 - 49
IEEE Robotics & Automation Magazine - June 2015 - 50
IEEE Robotics & Automation Magazine - June 2015 - 51
IEEE Robotics & Automation Magazine - June 2015 - 52
IEEE Robotics & Automation Magazine - June 2015 - 53
IEEE Robotics & Automation Magazine - June 2015 - 54
IEEE Robotics & Automation Magazine - June 2015 - 55
IEEE Robotics & Automation Magazine - June 2015 - 56
IEEE Robotics & Automation Magazine - June 2015 - 57
IEEE Robotics & Automation Magazine - June 2015 - 58
IEEE Robotics & Automation Magazine - June 2015 - 59
IEEE Robotics & Automation Magazine - June 2015 - 60
IEEE Robotics & Automation Magazine - June 2015 - 61
IEEE Robotics & Automation Magazine - June 2015 - 62
IEEE Robotics & Automation Magazine - June 2015 - 63
IEEE Robotics & Automation Magazine - June 2015 - 64
IEEE Robotics & Automation Magazine - June 2015 - 65
IEEE Robotics & Automation Magazine - June 2015 - 66
IEEE Robotics & Automation Magazine - June 2015 - 67
IEEE Robotics & Automation Magazine - June 2015 - 68
IEEE Robotics & Automation Magazine - June 2015 - 69
IEEE Robotics & Automation Magazine - June 2015 - 70
IEEE Robotics & Automation Magazine - June 2015 - 71
IEEE Robotics & Automation Magazine - June 2015 - 72
IEEE Robotics & Automation Magazine - June 2015 - 73
IEEE Robotics & Automation Magazine - June 2015 - 74
IEEE Robotics & Automation Magazine - June 2015 - 75
IEEE Robotics & Automation Magazine - June 2015 - 76
IEEE Robotics & Automation Magazine - June 2015 - 77
IEEE Robotics & Automation Magazine - June 2015 - 78
IEEE Robotics & Automation Magazine - June 2015 - 79
IEEE Robotics & Automation Magazine - June 2015 - 80
IEEE Robotics & Automation Magazine - June 2015 - 81
IEEE Robotics & Automation Magazine - June 2015 - 82
IEEE Robotics & Automation Magazine - June 2015 - 83
IEEE Robotics & Automation Magazine - June 2015 - 84
IEEE Robotics & Automation Magazine - June 2015 - 85
IEEE Robotics & Automation Magazine - June 2015 - 86
IEEE Robotics & Automation Magazine - June 2015 - 87
IEEE Robotics & Automation Magazine - June 2015 - 88
IEEE Robotics & Automation Magazine - June 2015 - 89
IEEE Robotics & Automation Magazine - June 2015 - 90
IEEE Robotics & Automation Magazine - June 2015 - 91
IEEE Robotics & Automation Magazine - June 2015 - 92
IEEE Robotics & Automation Magazine - June 2015 - 93
IEEE Robotics & Automation Magazine - June 2015 - 94
IEEE Robotics & Automation Magazine - June 2015 - 95
IEEE Robotics & Automation Magazine - June 2015 - 96
IEEE Robotics & Automation Magazine - June 2015 - 97
IEEE Robotics & Automation Magazine - June 2015 - 98
IEEE Robotics & Automation Magazine - June 2015 - 99
IEEE Robotics & Automation Magazine - June 2015 - 100
IEEE Robotics & Automation Magazine - June 2015 - 101
IEEE Robotics & Automation Magazine - June 2015 - 102
IEEE Robotics & Automation Magazine - June 2015 - 103
IEEE Robotics & Automation Magazine - June 2015 - 104
IEEE Robotics & Automation Magazine - June 2015 - 105
IEEE Robotics & Automation Magazine - June 2015 - 106
IEEE Robotics & Automation Magazine - June 2015 - 107
IEEE Robotics & Automation Magazine - June 2015 - 108
IEEE Robotics & Automation Magazine - June 2015 - 109
IEEE Robotics & Automation Magazine - June 2015 - 110
IEEE Robotics & Automation Magazine - June 2015 - 111
IEEE Robotics & Automation Magazine - June 2015 - 112
IEEE Robotics & Automation Magazine - June 2015 - 113
IEEE Robotics & Automation Magazine - June 2015 - 114
IEEE Robotics & Automation Magazine - June 2015 - 115
IEEE Robotics & Automation Magazine - June 2015 - 116
IEEE Robotics & Automation Magazine - June 2015 - 117
IEEE Robotics & Automation Magazine - June 2015 - 118
IEEE Robotics & Automation Magazine - June 2015 - 119
IEEE Robotics & Automation Magazine - June 2015 - 120
IEEE Robotics & Automation Magazine - June 2015 - Cover3
IEEE Robotics & Automation Magazine - June 2015 - Cover4
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2023
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2023
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2023
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2023
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2022
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2022
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2022
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2022
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2021
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2021
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2021
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2021
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2020
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2020
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2020
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2020
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2019
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2019
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2019
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2019
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2018
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2018
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2018
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2018
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2017
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2017
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2017
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2017
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2016
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2016
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2016
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2016
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2015
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2015
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2015
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2015
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2014
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2014
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2014
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2014
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2013
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2013
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2013
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2013
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2012
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2012
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2012
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2012
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2011
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2011
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_june2011
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_march2011
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_december2010
https://www.nxtbook.com/nxtbooks/ieee/roboticsautomation_september2010
https://www.nxtbookmedia.com