rosoct(); % apparently supposed to be included in order to connect ROS and Octave
rosoct_add_msgs('geometry_msgs')

%% test publishing a chatter topic
success = rosoct_advertise('cmd_vel',@geometry_msgs_Twist, 1);
if( ~success )
    error('failed to advertise cmd_vel');
end

for i = 1:1000000
    msg = geometry_msgs_Twist();
    msg.linear.x = 2;
    msg.angular.z = 3;
    success = rosoct_publish('cmd_vel',msg);
    if( ~success )
        error('failed to publish cmd_vel');
    end
end

success = rosoct_unadvertise('cmd_vel');
if( ~success )
    error('failed to unadvertise');
end
