Skip to content

Commit

Permalink
Various minor fixes and improvements. (#189)
Browse files Browse the repository at this point in the history
- [Viewer/play_trajectories] Do not delete robot automatically in Notebooks
- [Viewer] Set default backend
- [Viewer] Fix fix_mesh_path
- [Viewer] Fix index.html
- [Viewer] Bypass chrome/webgl GPU backlisting
- [Viewer] Fix chrome executable path for Google Colab
- [Meshcat/server] Use set to manage comm pool
- [BasicSimulator] Fix callback
- [engine_async] Update default engine_async camera pose.
- [misc] Fix notebook.
- [misc] OpenCV is now an optional dependency
- [misc] Always generate pip wheels artefacts for both Linux and Windows on CI

Co-authored-by: Alexis Duburcq <alexis.duburcq@wandercraft.eu>
  • Loading branch information
duburcqa and Alexis Duburcq authored Sep 1, 2020
1 parent ab16cbb commit 7e56f01
Show file tree
Hide file tree
Showing 11 changed files with 1,062 additions and 36 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/manylinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ jobs:
cmake . -DCOMPONENT=pypi -P ./cmake_install.cmake
auditwheel repair pypi/jiminy_py/dist/*.whl
"${PYTHON_EXECUTABLE}" -m pip install --force-reinstall --no-deps wheelhouse/*.whl
- name: Upload the wheel for Linux of Jiminy_py
if: success() && github.repository == 'Wandercraft/jiminy'
uses: actions/upload-artifact@v1
with:
name: jiminy_py${{ matrix.python-version }}-wheel
path: build/wheelhouse/

#####################################################################################

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ jobs:
#####################################################################################

- name: Generating the Python Pip wheels
if: success() && github.repository == 'Wandercraft/jiminy' && github.event_name == 'push' && github.ref == 'refs/heads/master'
if: success() && github.repository == 'Wandercraft/jiminy'
run: |
Set-Location -Path "./build"
cmake . -DCOMPONENT=pypi -P ./cmake_install.cmake
Remove-Item -Path "./pypi/jiminy_py/dist/*" -Include *.tar.gz
- name: Upload the wheel for Windows of Jiminy_py
if: success() && github.repository == 'Wandercraft/jiminy' && github.event_name == 'push' && github.ref == 'refs/heads/master'
if: success() && github.repository == 'Wandercraft/jiminy'
uses: actions/upload-artifact@v1
with:
name: jiminy_py${{ matrix.python-version }}-wheel
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
cmake_minimum_required(VERSION 3.10)

# Set the build version
set(BUILD_VERSION 1.3.4)
set(BUILD_VERSION 1.3.5)

# Add definition of Jiminy version for C++ headers
add_definitions("-DJIMINY_VERSION=\"${BUILD_VERSION}\"")
Expand Down
1,039 changes: 1,022 additions & 17 deletions examples/tutorial.ipynb

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions python/jiminy_py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ def finalize_options(self):
'matplotlib',
'meshcat>=0.0.18',
'psutil',
'requests_html',
'opencv-python-headless<=4.3.0.36'
]
'requests_html'
],
extras_require = {
'gepetto': [
'opencv-python-headless<=4.3.0.36'
]
}
)
4 changes: 2 additions & 2 deletions python/jiminy_py/src/jiminy_py/engine_asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ def render(self, return_rgb_array=False, width=None, height=None):
window_name="_".join(("window", uniq_id)))
if self._viewer.is_backend_parent:
self._viewer.set_camera_transform(
translation=[0.0, 9.0, 2e-5],
rotation=[np.pi/2, 0.0, np.pi])
translation=[9.0, 0.0, 2e-5],
rotation=[np.pi/2, 0.0, np.pi/2])
self._viewer.wait(False) # Wait for backend to finish loading

# Try refreshing the viewer
Expand Down
2 changes: 1 addition & 1 deletion python/jiminy_py/src/jiminy_py/meshcat/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
viewer.handle_command_bytearray(new Uint8Array(message.buffers[0].buffer));
});
viewer.connection.on_close(function(message) {
console.log("connection to Jupyter kernel closed:", evt);
console.log("connection to Jupyter kernel closed:", message);
});
}
else {
Expand Down
4 changes: 3 additions & 1 deletion python/jiminy_py/src/jiminy_py/meshcat/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import subprocess
import multiprocessing
import multiprocessing.managers
from pathlib import Path
from ctypes import c_char_p, c_bool, c_int
from contextlib import redirect_stderr

Expand All @@ -20,7 +21,7 @@
# Note that the downside is that chrome must be installed manually.
import pyppeteer.chromium_downloader
pyppeteer.chromium_downloader.chromium_executable = \
lambda : "/usr/lib/chromium-browser/chromium-browser"
lambda : Path("/usr/lib/chromium-browser/chromium-browser")
if not pyppeteer.chromium_downloader.check_chromium():
logging.warning("Chrome must be installed manually on Google Colab. "\
"It must be done using '!apt install chromium-chromedriver'.")
Expand Down Expand Up @@ -53,6 +54,7 @@ async def launch(self) -> Browser:
"--disable-frame-rate-limit",
"--disable-gpu-vsync",
# "--disable-gpu", # GPU acceleration is not available in headless mode on Windows for now apparently...
"--ignore-gpu-blacklist",
"--ignore-certificate-errors",
"--disable-infobars",
"--disable-breakpad",
Expand Down
4 changes: 2 additions & 2 deletions python/jiminy_py/src/jiminy_py/meshcat/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def f(port):
self.setup_comm(comm_url)

# Extra buffers for comm ids and messages
self.comm_pool = []
self.comm_pool = set()
self.comm_msg = []
self.websocket_msg = []

Expand Down Expand Up @@ -135,7 +135,7 @@ def handle_comm(self, frames):
if cmd.startswith("open:"):
comm_id = f"{cmd.split(':', 1)[1]}"
self.send_scene(comm_id=comm_id)
self.comm_pool.append(comm_id)
self.comm_pool.add(comm_id)
elif cmd.startswith("close:"):
comm_id = f"{cmd.split(':', 1)[1]}"
self.comm_pool.remove(comm_id)
Expand Down
3 changes: 1 addition & 2 deletions python/jiminy_py/src/jiminy_py/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ def callback(t, q, v, out):
"""
@brief Callback method for the simulation.
"""
pass

out[:] = True

def _compute_command_wrapper(self, t, q, v, sensors_data, u):
"""
Expand Down
20 changes: 15 additions & 5 deletions python/jiminy_py/src/jiminy_py/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
except ImportError:
pass

def default_backend():
if is_notebook() or not 'gepetto-gui' in backends_available:
return 'meshcat'
else:
return 'gepetto-gui'


# Create logger
class DuplicateFilter:
Expand Down Expand Up @@ -142,7 +148,7 @@ def kill(self):


class Viewer:
backend = None
backend = default_backend()
_backend_obj = None
_backend_exceptions = ()
_backend_proc = None
Expand Down Expand Up @@ -192,10 +198,10 @@ def __init__(self,
# Handling of default arguments
if robot_name is None:
uniq_id = next(tempfile._get_candidate_names())
robot_name="_".join(("robot", uniq_id))
robot_name = "_".join(("robot", uniq_id))

# Backup some user arguments
self.urdf_path = robot.urdf_path
self.urdf_path = os.path.realpath(robot.urdf_path)
self.robot_name = robot_name
self.scene_name = scene_name
self.window_name = window_name
Expand Down Expand Up @@ -603,7 +609,7 @@ def _urdf_fix_mesh_path(urdf_path, mesh_root_path, output_root_path=None):
for filename in re.findall('<mesh filename="(.*)"', urdf_contents)
if not filename.startswith('package://')]
if not pathlists:
return
return urdf_path

# If mesh root path already matching, then nothing to do
mesh_root_path_orig = os.path.commonpath(pathlists)
Expand Down Expand Up @@ -1103,7 +1109,7 @@ def play_trajectories(trajectory_data,
window_name='python-pinocchio',
scene_name='world',
close_backend=None,
delete_robot_on_close=True,
delete_robot_on_close=None,
verbose=True):
"""!
@brief Replay one or several robot trajectories in a viewer.
Expand Down Expand Up @@ -1175,6 +1181,10 @@ def play_trajectories(trajectory_data,
close_backend = False

if viewers is None:
# Delete robot by default only if not in notebook
if delete_robot_on_close is None:
delete_robot_on_close = not is_notebook()

# Create new viewer instances
viewers = []
lock = Lock()
Expand Down

0 comments on commit 7e56f01

Please sign in to comment.