How to exchange MultiDOFJointTrajectoryPoint[] datas using ROS-Matlab?

asked 2015-02-20 13:22:13 -0500

Andromeda gravatar image

updated 2015-05-15 00:12:40 -0500

Hi guys, I'm having a hard time trying to find out how to use the ROS I/O Matlab package to let them communicate each other.

In my simple script I wrote the following lines of Matlab's code:

%% Creating a Publisher and send data from Matlab to ROS

% Create a new node named /NODE and connect it to the master.
rosmat_nh = rosmatlab.node( 'matlab_generator', [], [], 'rosIP', '127.0.0.1' );

publish_point = rosmat_nh.addPublisher( 'trajectory', 'trajectory_msgs/MultiDOFJointTrajectoryPoint' );

message_point = rosmat_nh.newMessage( 'trajectory_msgs/MultiDOFJointTrajectoryPoint');

for i = 1:100
     message_point.setTransforms().setTranslation().setX(rand(1));

    publish_point.publish(message_point);
    pause(1);
end

but it ends with an error saying:

>> publisher_trajectory
Shutting down node /matlab_generator on http://127.0.0.1:54160/.
No method 'setTransforms' with matching signature found for class 'org.ros.internal.message.$Proxy24'.

Error in publisher_trajectory (line 11)
     message_point.setTransforms().setTranslation().setX(rand(1));

I suppose the problem arises because trajectory_msgs/MultiDOFJointTrajectoryPoint[] is an array. But how to deal with it? How should I change my code to make it working?

Do you have any example where array are created and published in rosjava????

Regards

PS: using another not-array standard type (e.g. geometry_msgs/Point) works perfectly

edit retag flag offensive close merge delete