Ros Matlab I/O joint_state publisher

4 views (last 30 days)
Ioannis
Ioannis on 22 May 2014
Hi all, I am playing around with the Matlab ROS I/O and came across a problem when trying to publish joint state messages, i.e. of type sensor_msgs/JointState.
I can create the msg ok and add position, velocity, etc, values but I cannot fill in the joint names. For example:
...
>> msg = rosmatlab.message('sensor_msgs/JointState',node);
>> msg.setPosition(1,2,3,4);
>> msg.setVelocity(1,2,3,4);
>> msg.setName(['j1','j2','j3','j4'])
No method 'setName' with matching signature found for class 'org.ros.internal.message.$Proxy12'.
or
>> msg.setName('[j1,j2,j3,j4]')
No method 'setName' with matching signature found for class 'org.ros.internal.message.$Proxy12'.
Does anyone know how to set the joint names?
Thanks, Ioannis

Answers (2)

Viktor Dluhos
Viktor Dluhos on 17 Aug 2017
Hi Ioannis,
I had the same problem and I found the solution. Its a bit crazy but it works. You have to create cell array of strings. So what have I done. First I created a string array. Then to each field I set names and then I created a cell from this string array. joints = java_array('java.lang.String',3); joints(1) = java.lang.String('Joint1'); joints(2) = java.lang.String('Joint2'); joints(3) = java.lang.String('Joint_GripperBase') joints_cell = cell(joints) msg.Name = joints_cell
I know you had older matlab and now its totally different, but If someone will have the same problem, then here is the answer.
Viktor D.

Leonardo Fabio M. Benítez
for me it work, but i have a big problem with parameter Header. :(
mensaje_articulaciones = rosmessage(publicador_robot);
%mensaje_articulaciones.Header = {'auto'};
mensaje_articulaciones.Name = {'joint_1', 'joint_2', 'joint_3', 'joint_4'};
mensaje_articulaciones.Position = [0,0,0,0];
mensaje_articulaciones.Velocity = [];
mensaje_articulaciones.Effort = [];

Categories

Find more on Publishers and Subscribers in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!