How to check if global ROS node is already running in MATLAB?

조회 수: 7 (최근 30일)
Rahul Bhadani
Rahul Bhadani 2016년 2월 24일
댓글: Thomas Stubbs 2023년 1월 27일
Hi, I am using Robotics Toolbox to interface MATLAB and ROS. Before doing rosinit('http://192.68.0.43:11311') i want to check whether a Global Ros Node corresponding to it is running. What are the steps to accomplish that?

채택된 답변

Marcelino Almeida
Marcelino Almeida 2017년 3월 22일
편집: Marcelino Almeida 2017년 3월 22일
I know it has been a long time, but I decided to post an answer here in case other people might be wondering how to do this.
Although there isn't much documentation on this, and this might not exist in future versions of the Robotics Toolbox, I've been able to check for node running through the following call:
robotics.ros.internal.Global.isNodeActive
The command above returns 1 if active, 0 if inactive.
  댓글 수: 2
Alen Alempijevic
Alen Alempijevic 2020년 9월 22일
This is a great hack, but access to the variable robotics.ros.internal.Global seems to be removed in 2019b. You can wrap the command in a try catch
try
rosinit
catch ME
fprintf(2,'%s\n',ME.message);
end
Thomas Stubbs
Thomas Stubbs 2023년 1월 27일
I was able to do the Marcelino's solution in 2022b with a slight change:
ros.internal.Global.isNodeActive

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Network Connection and Exploration에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by