matlab&&ros2-humble联合控制1

主题:使用matlab脚本控制turtlesim小乌龟

clc
clear

setenv('ROS_DOMAIN_ID', '30');
n = ros2node("matlab", 30);
cmd_pub = ros2publisher(n, '/turtle1/cmd_vel', 'geometry_msgs/Twist');
vel_msg = ros2message(cmd_pub);
vel_msg.linear.x = 1;
vel_msg.angular.z = 0.5;
for i = 0 : 999
    send(cmd_pub, vel_msg);
    pause(1)
end

matlab&&ros2-humble联合控制1_第1张图片

你可能感兴趣的:(ros2,人工智能)