Skip to content

Commit 94c011e

Browse files
authored
Merge pull request #35 from JdeRobot/issue-34
Added ROS2 applications compatibility
2 parents ce089e4 + 958d337 commit 94c011e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

manager/libs/applications/compatibility/robotics_application_wrapper.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def __init__(self, update_callback):
2828
self.start_console()
2929
self.user_process = None
3030
self.entrypoint_path = None
31+
self.python_command = "python"
32+
self.check_python_version()
3133

3234
def _create_process(self, cmd):
3335
#print("creando procesos")
@@ -45,7 +47,7 @@ def load_code(self, path: str):
4547
self.entrypoint_path = path
4648

4749
def run(self):
48-
self.user_process = self._create_process(f"DISPLAY=:2 python {self.entrypoint_path}")
50+
self.user_process = self._create_process(f"DISPLAY=:2 {self.python_command} {self.entrypoint_path}")
4951
self.running = True
5052

5153
def stop(self):
@@ -94,4 +96,12 @@ def suspend_resume(self, signal):
9496
if(signal == "resume"):
9597
p.resume()
9698
except psutil.NoSuchProcess:
97-
pass
99+
pass
100+
101+
def check_python_version(self):
102+
output = subprocess.check_output(['bash', '-c', 'echo $ROS_VERSION'])
103+
output_str = output.decode('utf-8')
104+
if (output_str == 1):
105+
self.python_command = "python"
106+
else:
107+
self.python_command = "python3"

0 commit comments

Comments
 (0)