|
| 1 | +ROS_STA = []; |
| 2 | +ROS_STA.ros_already_running = 0; |
| 3 | +ROS_STA.ros_started = 0; |
| 4 | +ROS_STA.ros_running = 0; |
| 5 | +ROS_STA.no_local_ros_core = 0; |
| 6 | +ROS_STA.current_port = NaN; |
| 7 | +ROS_STA.current_ros_master_ip = NaN; |
| 8 | + |
| 9 | +try |
| 10 | + rosnode list |
| 11 | + ROS_STA.ros_already_running = 1; |
| 12 | +catch |
| 13 | + if UI.simulation && (~exist('core','var') || isempty(core) || ~isvalid(core)) |
| 14 | + core = ros.Core(UI.port); |
| 15 | + end |
| 16 | + try |
| 17 | + rosinit(UI.masterURI) |
| 18 | + catch |
| 19 | + warning('Oopsie, rosshutdown then rosinit again..') |
| 20 | + rosshutdown |
| 21 | + rosinit(UI.masterURI) |
| 22 | + end |
| 23 | + ROS_STA.ros_started = 1; |
| 24 | +end |
| 25 | + |
| 26 | + |
| 27 | +if ROS_STA.ros_already_running || ROS_STA.ros_started |
| 28 | + ROS_STA.ros_running = 1; |
| 29 | +end |
| 30 | + |
| 31 | +if ~exist('core','var') || isempty(core) |
| 32 | + ROS_STA.no_local_ros_core = 1; |
| 33 | + if UI.simulation |
| 34 | + error('Simulation selected, but no local core found.') |
| 35 | + end |
| 36 | + if ~ros.internal.NetworkIntrospection.isMasterReachable(UI.masterURI) |
| 37 | + error('Will the real ros master please stand up?') |
| 38 | + else |
| 39 | + [ROS_STA.current_ros_master_ip, ROS_STA.current_port] = ... |
| 40 | + ros.internal.NetworkIntrospection.getHostAndPortFromMasterURI(UI.masterURI); |
| 41 | + end |
| 42 | +else |
| 43 | + ROS_STA.no_local_ros_core = 0; |
| 44 | + [ROS_STA.current_ros_master_ip, ROS_STA.current_port] = ... |
| 45 | + ros.internal.NetworkIntrospection.getHostAndPortFromMasterURI(core.MasterURI); |
| 46 | + if UI.simulation |
| 47 | + if strcmp(ROS_STA.current_ros_master_ip, UI.real_ros_master_ip) |
| 48 | + error('Simulation selected, but ROS master ip is same as core.') |
| 49 | + end |
| 50 | + clear tmp |
| 51 | + end |
| 52 | +end |
| 53 | + |
| 54 | +ROS_STA |
0 commit comments