Skip to content

Commit

Permalink
[misc] Update install instructions on windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
duburcqa committed May 6, 2024
1 parent d165464 commit a67f987
Show file tree
Hide file tree
Showing 15 changed files with 137 additions and 125 deletions.
35 changes: 17 additions & 18 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,24 +152,23 @@ if (-not (Test-Path -PathType Container $RootDir/build)) {
New-Item -ItemType "directory" -Force -Path "$RootDir/build"
}
Set-Location -Path $RootDir/build
cmake "$RootDir" -G "Visual Studio 16 2019" -T "v142" -DCMAKE_GENERATOR_PLATFORM=x64 `
-DCMAKE_INSTALL_PREFIX="$InstallDir" -DCMAKE_MODULE_PATH="$InstallDir" `
cmake "$RootDir" -G "Visual Studio 17 2022" -DCMAKE_GENERATOR_PLATFORM=x64 `
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" `
-DCMAKE_INSTALL_PREFIX="$InstallDir" -DCMAKE_PREFIX_PATH="$InstallDir" `
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF -DCMAKE_VERBOSE_MAKEFILE=ON `
-DBOOST_ROOT="$InstallDir" -DBoost_INCLUDE_DIR="$InstallDir/include" `
-DBoost_NO_SYSTEM_PATHS=TRUE -DBoost_NO_BOOST_CMAKE=TRUE `
-DBoost_USE_STATIC_LIBS=OFF `
-DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON -DBUILD_PYTHON_INTERFACE=ON `
-DCMAKE_CXX_FLAGS="-DBOOST_ALL_NO_LIB -DBOOST_LIB_DIAGNOSTIC -DBOOST_CORE_USE_GENERIC_CMATH"
cmake --build . --target all --config "${env:BUILD_TYPE}" --parallel 8
if (-not (Test-Path -PathType Container "$RootDir/build/PyPi/jiminy_py/src/jiminy_py/core")) {
New-Item -ItemType "directory" -Force -Path "$RootDir/build/PyPi/jiminy_py/src/jiminy_py/core"
-DBoost_NO_SYSTEM_PATHS=TRUE -DBoost_NO_BOOST_CMAKE=TRUE -DBoost_USE_STATIC_LIBS=ON `
-DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON -DBUILD_PYTHON_INTERFACE=ON ``
-DCMAKE_CXX_FLAGS="${env:CMAKE_CXX_FLAGS} $(
) -DBOOST_ALL_NO_LIB -DBOOST_LIB_DIAGNOSTIC -DBOOST_CORE_USE_GENERIC_CMATH $(
) -DEIGENPY_STATIC -DURDFDOM_STATIC -DHPP_FCL_STATIC -DPINOCCHIO_STATIC"
cmake --build . --target ALL_BUILD --config "${env:BUILD_TYPE}" --parallel 2
if (-not (Test-Path -PathType Container "$RootDir/build/pypi/jiminy_py/src/jiminy_py")) {
New-Item -ItemType "directory" -Force -Path "$RootDir/build/pypi/jiminy_py/src/jiminy_py/core"
}
Copy-Item -Path "$InstallDir/lib/boost_numpy*.dll" `
-Destination "$RootDir/build/PyPi/jiminy_py/src/jiminy_py/core"
Copy-Item -Path "$InstallDir/lib/boost_python*.dll" `
-Destination "$RootDir/build/PyPi/jiminy_py/src/jiminy_py/core"
Copy-Item -Path "$InstallDir/lib/site-packages/*" `
-Destination "$RootDir/build/PyPi/jiminy_py/src/jiminy_py" -Recurse
cmake --build . --target install --config "${env:BUILD_TYPE}"
Copy-Item -Force -Recurse -Path "$InstallDir/lib/site-packages/*" `
-Destination "$RootDir/build/pypi/jiminy_py/src/jiminy_py/core"
cmake --build . --target INSTALL --config "${env:BUILD_TYPE}"
```
6 changes: 6 additions & 0 deletions docs/api/gym_jiminy/common/bases/compositions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Compositions
============

.. automodule:: gym_jiminy.common.bases.compositions
:members:
:show-inheritance:
2 changes: 2 additions & 0 deletions docs/api/gym_jiminy/common/bases/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ Bases

interfaces
blocks
quantities
compositions
pipeline
6 changes: 6 additions & 0 deletions docs/api/gym_jiminy/common/bases/quantities.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Quantities
==========

.. automodule:: gym_jiminy.common.bases.quantities
:members:
:show-inheritance:
6 changes: 0 additions & 6 deletions docs/api/gym_jiminy/common/bases/quantity.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/api/gym_jiminy/common/bases/reward.rst

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Generic
=======

.. automodule:: gym_jiminy.common.rewards.generic
.. automodule:: gym_jiminy.common.compositions.generic
:members:
:undoc-members:
:private-members:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Envs
====
Compositions
============

.. toctree::
:maxdepth: 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Locomotion
==========

.. automodule:: gym_jiminy.common.rewards.locomotion
.. automodule:: gym_jiminy.common.compositions.locomotion
:members:
:undoc-members:
:private-members:
Expand Down
4 changes: 2 additions & 2 deletions docs/api/gym_jiminy/common/quantities/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Envs
====
Quantities
==========

.. toctree::
:maxdepth: 1
Expand Down
5 changes: 3 additions & 2 deletions python/gym_jiminy/common/gym_jiminy/common/bases/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
AbstractQuantity)
from .compositions import (AbstractReward,
BaseQuantityReward,
BaseMixtureReward,
ComposedJiminyEnv)
BaseMixtureReward)
from .blocks import (BlockStateT,
InterfaceBlock,
BaseObserverBlock,
Expand All @@ -26,6 +25,7 @@
BasePipelineWrapper,
BaseTransformObservation,
BaseTransformAction,
ComposedJiminyEnv,
ObservedJiminyEnv,
ControlledJiminyEnv)

Expand Down Expand Up @@ -55,6 +55,7 @@
'BasePipelineWrapper',
'BaseTransformObservation',
'BaseTransformAction',
'ComposedJiminyEnv',
'ObservedJiminyEnv',
'ControlledJiminyEnv',
'QuantityCreator'
Expand Down
77 changes: 2 additions & 75 deletions python/gym_jiminy/common/gym_jiminy/common/bases/compositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
it greatly reduces code duplication and bugs.
"""
from abc import ABC, abstractmethod
from typing import Sequence, Callable, Optional, Tuple, TypeVar, Generic
from typing import Sequence, Callable, Optional, Tuple, TypeVar

import numpy as np

from .interfaces import ObsT, ActT, InfoType, EngineObsType, InterfaceJiminyEnv
from .interfaces import InfoType, InterfaceJiminyEnv
from .quantities import QuantityCreator
from .pipeline import BasePipelineWrapper


ValueT = TypeVar('ValueT')
Expand Down Expand Up @@ -360,75 +359,3 @@ def compute(self, terminated: bool, info: InfoType) -> Optional[float]:
reward_total = self._reduce_fn(values)

return reward_total


class ComposedJiminyEnv(
BasePipelineWrapper[ObsT, ActT, ObsT, ActT],
Generic[ObsT, ActT]):
"""Plug ad-hoc reward components and termination conditions to the
wrapped environment.
.. note::
This wrapper derives from `BasePipelineWrapper`, and such as, it is
considered as internal unlike `gym.Wrapper`. This means that it will be
taken into account when calling `evaluate` or `play_interactive` on the
wrapped environment.
"""
def __init__(self,
env: InterfaceJiminyEnv[ObsT, ActT],
*,
reward: AbstractReward) -> None:
# Make sure that the reward is linked to this environment
assert env is reward.env

# Backup user argument(s)
self.reward = reward

# Initialize base class
super().__init__(env)

# Bind observation and action of the base environment
assert self.observation_space.contains(self.env.observation)
assert self.action_space.contains(self.env.action)
self.observation = self.env.observation
self.action = self.env.action

def _initialize_action_space(self) -> None:
"""Configure the action space.
It simply copy the action space of the wrapped environment.
"""
self.action_space = self.env.action_space

def _initialize_observation_space(self) -> None:
"""Configure the observation space.
It simply copy the observation space of the wrapped environment.
"""
self.observation_space = self.env.observation_space

def refresh_observation(self, measurement: EngineObsType) -> None:
"""Compute high-level features based on the current wrapped
environment's observation.
It simply forwards the observation computed by the wrapped environment
without any processing.
:param measurement: Low-level measure from the environment to process
to get higher-level observation.
"""
self.env.refresh_observation(measurement)

def compute_command(self, action: ActT, command: np.ndarray) -> None:
"""Compute the motors efforts to apply on the robot.
It simply forwards the command computed by the wrapped environment
without any processing.
:param action: High-level target to achieve by means of the command.
:param command: Lower-level command to updated in-place.
"""
self.env.compute_command(action, command)

def compute_reward(self, terminated: bool, info: InfoType) -> float:
return self.reward(terminated, info)
88 changes: 86 additions & 2 deletions python/gym_jiminy/common/gym_jiminy/common/bases/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
InfoType,
EngineObsType,
InterfaceJiminyEnv)
from .compositions import AbstractReward
from .blocks import BaseControllerBlock, BaseObserverBlock

from ..utils import DataNested, is_breakpoint, zeros, build_copyto, copy
Expand Down Expand Up @@ -298,6 +299,91 @@ def close(self) -> None:
self.env.close()


class ComposedJiminyEnv(
BasePipelineWrapper[ObsT, ActT, ObsT, ActT],
Generic[ObsT, ActT]):
"""Plug ad-hoc reward components and termination conditions to the
wrapped environment.
.. note::
This wrapper derives from `BasePipelineWrapper`, and such as, it is
considered as internal unlike `gym.Wrapper`. This means that it will be
taken into account when calling `evaluate` or `play_interactive` on the
wrapped environment.
"""
def __init__(self,
env: InterfaceJiminyEnv[ObsT, ActT],
*,
reward: AbstractReward) -> None:
# Make sure that the reward is linked to this environment
assert env is reward.env

# Backup user argument(s)
self.reward = reward

# Initialize base class
super().__init__(env)

# Bind observation and action of the base environment
assert self.observation_space.contains(self.env.observation)
assert self.action_space.contains(self.env.action)
self.observation = self.env.observation
self.action = self.env.action

def _initialize_action_space(self) -> None:
"""Configure the action space.
It simply copy the action space of the wrapped environment.
"""
self.action_space = self.env.action_space

def _initialize_observation_space(self) -> None:
"""Configure the observation space.
It simply copy the observation space of the wrapped environment.
"""
self.observation_space = self.env.observation_space

def _setup(self) -> None:
"""Configure the wrapper.
In addition to calling the base implementation, it sets the observe
and control update period.
"""
# Call base implementation
super()._setup()

# Copy observe and control update periods from wrapped environment
self.observe_dt = self.env.observe_dt
self.control_dt = self.env.control_dt

def refresh_observation(self, measurement: EngineObsType) -> None:
"""Compute high-level features based on the current wrapped
environment's observation.
It simply forwards the observation computed by the wrapped environment
without any processing.
:param measurement: Low-level measure from the environment to process
to get higher-level observation.
"""
self.env.refresh_observation(measurement)

def compute_command(self, action: ActT, command: np.ndarray) -> None:
"""Compute the motors efforts to apply on the robot.
It simply forwards the command computed by the wrapped environment
without any processing.
:param action: High-level target to achieve by means of the command.
:param command: Lower-level command to updated in-place.
"""
self.env.compute_command(action, command)

def compute_reward(self, terminated: bool, info: InfoType) -> float:
return self.reward(terminated, info)


class ObservedJiminyEnv(
BasePipelineWrapper[NestedObsT, ActT, BaseObsT, ActT],
Generic[NestedObsT, ActT, BaseObsT]):
Expand Down Expand Up @@ -364,7 +450,6 @@ def __init__(self,

# Make sure that the environment is either some `ObservedJiminyEnv` or
# `ControlledJiminyEnv` block, or the base environment directly.
from gym_jiminy.common.bases.compositions import ComposedJiminyEnv
if isinstance(env, BasePipelineWrapper) and not isinstance(env, (
ObservedJiminyEnv, ControlledJiminyEnv, ComposedJiminyEnv)):
raise TypeError(
Expand Down Expand Up @@ -587,7 +672,6 @@ def __init__(self,

# Make sure that the environment is either some `ObservedJiminyEnv` or
# `ControlledJiminyEnv` block, or the base environment directly.
from gym_jiminy.common.bases.compositions import ComposedJiminyEnv
if isinstance(env, BasePipelineWrapper) and not isinstance(env, (
ObservedJiminyEnv, ControlledJiminyEnv, ComposedJiminyEnv)):
raise TypeError(
Expand Down
13 changes: 6 additions & 7 deletions python/gym_jiminy/common/gym_jiminy/common/utils/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,14 @@ def sanitize_reward_config(reward_config: RewardConfig):
cls = reward_config["cls"]
if isinstance(cls, str):
obj = locate(cls)
assert (isinstance(obj, type) and
issubclass(obj, AbstractReward))
assert isinstance(obj, type) and issubclass(obj, AbstractReward)
reward_config["cls"] = obj

# Get reward constructor keyword-arguments
kwargs = reward_config.get("kwargs", {})

# Special handling for `BaseMixtureReward`
if issubclass(cls, BaseMixtureReward):
if issubclass(reward_config["cls"], BaseMixtureReward):
for reward_config in kwargs["components"]:

Check notice on line 169 in python/gym_jiminy/common/gym_jiminy/common/utils/pipeline.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

python/gym_jiminy/common/gym_jiminy/common/utils/pipeline.py#L169

Redefining argument with the local name 'reward_config'
sanitize_reward_config(reward_config)

Expand All @@ -182,8 +181,7 @@ def build_reward(env: InterfaceJiminyEnv,
"""
# Get reward class type
cls = reward_config["cls"]
assert (isinstance(obj, type) and
issubclass(obj, AbstractReward))
assert isinstance(cls, type) and issubclass(cls, AbstractReward)

# Get reward constructor keyword-arguments
kwargs = reward_config.get("kwargs", {})
Expand Down Expand Up @@ -227,7 +225,7 @@ def build_composition(env_creator: Callable[..., InterfaceJiminyEnv],
reward = build_reward(env, reward_config)

# Instantiate the wrapper
return ComposedJiminyEnv(env, reward)
return ComposedJiminyEnv(env, reward=reward)

# Define helper to wrap a single layer
def build_layer(env_creator: Callable[..., InterfaceJiminyEnv],
Expand Down Expand Up @@ -304,9 +302,10 @@ def build_layer(env_creator: Callable[..., InterfaceJiminyEnv],
# Compose base environment with an extra user-specified reward if any
reward_config = env_config.get("reward")
if reward_config is not None:
sanitize_reward_config(reward_config)
pipeline_creator = partial(build_composition,
pipeline_creator,
sanitize_reward_config(reward_config))
reward_config)

# Generate pipeline recursively
for layer_config in layers_config:
Expand Down
Loading

0 comments on commit a67f987

Please sign in to comment.