Skip to content

Commit 66edd9f

Browse files
committed
Added psutil reinstall; reworked open3d kill
1 parent 254631b commit 66edd9f

File tree

7 files changed

+24
-9
lines changed

7 files changed

+24
-9
lines changed

Docker/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ RUN echo "export PATH=/usr/local/bin:$PATH" >> /home/docker/.bashrc
5858
# pybullet, robot_description, numpy, etc.
5959
RUN python$PYTHON_VER -m pip install --user --upgrade pip && python$PYTHON_VER -m pip install pybullet "numpy<2" scipy cython matplotlib roboticstoolbox-python --ignore-installed --verbose --no-cache-dir
6060
RUN cd /home/docker && git clone https://github.com/rustlluk/pyCub.git && cd pyCub && git checkout dev && python$PYTHON_VER setup.py install --user
61+
RUN python$PYTHON_VER -m pip install psutil --force-reinstall
6162

6263
# Delete thingies from aptitude
6364
RUN rm -Rf /var/lib/apt/lists/*

Docker/Dockerfile.gitpod

+2
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ RUN python$PYTHON_VER -m pip install --user --upgrade pip && python$PYTHON_VER -
9393

9494
USER gitpod
9595
RUN cd /home/gitpod && git clone https://github.com/rustlluk/pyCub.git && cd pyCub && git checkout dev && python$PYTHON_VER setup.py install --user
96+
RUN python$PYTHON_VER -m pip install psutil --force-reinstall
9697

9798
RUN sudo ln -sf /usr/bin/python$PYTHON_VER /usr/local/bin/python && sudo ln -sf /usr/bin/python$PYTHON_VER /usr/local/bin/python3
9899
RUN echo "export PATH=/usr/local/bin:$PATH" >> /home/gitpod/.bashrc
100+
RUN echo "export BROWSER=/usr/bin/firefox" >> /home/gitpod/.bashrc
99101

100102
# Clean up unnecessary installation products
101103
RUN sudo rm -Rf /var/lib/apt/lists/*

Docker/Dockerfile.vnc

+2
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ RUN python$PYTHON_VER -m pip install --user --upgrade pip && python$PYTHON_VER -
100100

101101
USER docker
102102
RUN cd /home/docker && git clone https://github.com/rustlluk/pyCub.git && cd pyCub && git checkout dev && python$PYTHON_VER setup.py install --user
103+
RUN python$PYTHON_VER -m pip install psutil --force-reinstall
103104

104105
RUN sudo ln -sf /usr/bin/python$PYTHON_VER /usr/local/bin/python && sudo ln -sf /usr/bin/python$PYTHON_VER /usr/local/bin/python3
105106
RUN echo "export PATH=/usr/local/bin:$PATH" >> /home/docker/.bashrc
107+
RUN echo "export BROWSER=/usr/bin/firefox" >> /home/docker/.bashrc
106108

107109
# Clean up unnecessary installation products
108110
RUN sudo rm -Rf /var/lib/apt/lists/*

icub_pybullet/configs/default.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ robot_urdf_path: "../iCub/full.urdf" # path to Robot URDF file relative to pycub
1212
# default: "../iCub/full.urdf"
1313
# str
1414
gui:
15-
standard: False
15+
standard: True
1616
web: False
1717
tolerance:
1818
joint: 1e-3 # circa 2 degrees

icub_pybullet/configs/skin_test.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ robot_urdf_path: "../iCub/full.urdf" # path to Robot URDF file relative to pycub
1212
# default: "../iCub/full.urdf"
1313
# str
1414
gui:
15-
standard: False
15+
standard: True
1616
web: False
1717
tolerance:
1818
joint: 1e-3 # circa 2 degrees

icub_pybullet/configs/with_ball.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ robot_urdf_path: "../iCub/full.urdf" # path to Robot URDF file relative to pycub
1212
# default: "../iCub/full.urdf"
1313
# str
1414
gui:
15-
standard: False
15+
standard: True
1616
web: False
1717
tolerance:
1818
joint: 1e-3 # circa 2 degrees

icub_pybullet/pycub.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import glob
33
import time
44
import numpy as np
5+
import psutil
56
import pybullet as p
67
from pybullet_utils.bullet_client import BulletClient
78
import os
@@ -11,11 +12,9 @@
1112
import logging
1213
import datetime
1314
import inspect
14-
from subprocess import call
15+
import psutil
1516
import atexit
1617
import roboticstoolbox as rtb
17-
import signal
18-
import psutil
1918

2019

2120
class pyCub(BulletClient):
@@ -262,10 +261,21 @@ def get_camera_images(self):
262261
images.append(np.asarray(ew.last_image))
263262
return images
264263

264+
def find_processes_by_name(self):
265+
matching_pids = []
266+
for process in psutil.process_iter(attrs=['pid', 'name', 'cmdline']):
267+
try:
268+
if self.parent_name in ' '.join(process.info['cmdline']):
269+
matching_pids.append(process.info['pid'])
270+
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
271+
pass
272+
return matching_pids
273+
265274
def kill_open3d(self):
266-
# a bit of a workaround to kill open3d, that seems to hang for some reason
267-
for _ in os.popen("pgrep -f " + self.parent_name).read().strip().splitlines():
268-
call("kill -9 " + _, shell=True)
275+
# a bit of a workaround to kill open3d, that seems to hang for some
276+
for _ in self.find_processes_by_name():
277+
psutil.Process(_).kill()
278+
269279

270280
def init_robot(self):
271281
"""

0 commit comments

Comments
 (0)