www.gusucode.com > robotics 案例源码程序 matlab代码 > robotics/RunAROSNodeOnAROSDeviceExample.m
%% Run ROS Node on ROS Device % Connect to a remote ROS device and start a ROS % node. First, run a ROS core so that ROS nodes can communicate via a ROS % network. You can run and stop a ROS core or node and check their status using % a |rosdevice| object. %% % Create a connection to a ROS device. Specify the address, user name and % password of your specific ROS device. The device contains information % about the ROS device, including the available ROS nodes that can be run using % |runNode|. ipaddress = '192.168.154.131'; d = rosdevice(ipaddress,'user','password') %% % Run a ROS core. Connect MATLAB(R) to the ROS master using |rosinit|. This % core enables you to run ROS nodes on your ROS device. runCore(d) rosinit(d.DeviceAddress) %% % Check the available ROS nodes on the connected ROS device. These nodes % were generated from Simlink(R) models following the process in the % <matlab:helpview(fullfile(docroot,'robotics/examples/robotics_examples.map'),'robotROSCodeGenerationExample') Generate a standalone ROS node from Simulink(R)> % example. d.AvailableNodes %% % Run a ROS node. specifying the node name. Check if the node is running. runNode(d,'robotcontroller') running = isNodeRunning(d,'robotcontroller') %% % Stop the ROS node. Disconnect from the ROS network. Stop the ROS core. stopNode(d,'robotcontroller') rosshutdown stopCore(d)