Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:leggedrobotics/raisimGym into fea…
Browse files Browse the repository at this point in the history
…ture/build_script
  • Loading branch information
mktk1117 committed Nov 20, 2019
2 parents 57c6088 + 9e46011 commit c765e96
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 15 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ pybind11_add_module(_raisim_gym raisim_gym/env/raisim_gym.cpp)
target_link_libraries(_raisim_gym PRIVATE raisim::raisim raisim::raisimOgre yaml-cpp)
target_include_directories(_raisim_gym PUBLIC raisim_gym/env ${RSG_ENVIRONMENT_INCLUDE_PATH} ${EIGEN3_INCLUDE_DIRS})
target_compile_options(_raisim_gym PRIVATE -mtune=native -fPIC -O3)

if (CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "Debug")
message("[RAISIM_GYM]BUILDING THE DEBUG APP")
add_executable(debug_app raisim_gym/env/debug_app.cpp)
target_link_libraries(debug_app PRIVATE raisim::raisim raisim::raisimOgre yaml-cpp)
target_include_directories(debug_app PUBLIC raisim_gym/env ${RSG_ENVIRONMENT_INCLUDE_PATH} ${EIGEN3_INCLUDE_DIRS})
target_compile_options(debug_app PRIVATE -mtune=native -fPIC -g -O0)
endif()
1 change: 0 additions & 1 deletion raisim_gym/env/RaisimGymEnv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <vector>
#include <memory>
#include <unordered_map>
#include <pybind11/pybind11.h>
#include <Eigen/Core>
#include "raisim/World.hpp"
#include "raisim/RaisimServer.hpp"
Expand Down
3 changes: 1 addition & 2 deletions raisim_gym/env/VectorizedEnvironment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class VectorizedEnvironment {
: resourceDir_(resourceDir) {
cfg_ = YAML::Load(cfg);
if(cfg_["render"])
render_ = cfg_["render"].as<bool>();

render_ = cfg_["render"].template as<bool>();
}

~VectorizedEnvironment() {
Expand Down
64 changes: 64 additions & 0 deletions raisim_gym/env/debug_app.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// Created by jemin on 11/12/19.
// MIT License
//
// Copyright (c) 2019-2019 Robotic Systems Lab, ETH Zurich
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include "Environment.hpp"
#include "VectorizedEnvironment.hpp"

using namespace raisim;

int main(int argc, char *argv[]) {
RSFATAL_IF(argc != 4, "got "<<argc<<" arguments. "<<"This executable takes three arguments: 1. resource directory, 2. configuration file, 3. render or no_render to control rendering")

std::string resourceDir(argv[1]), cfgFile(argv[2]);
YAML::Node config = YAML::LoadFile(cfgFile);
std::stringstream config_str;

if(std::string(argv[3]) == "no_render") {
config["environment"]["render"] = false;
std::cout<<argv[3]<<std::endl;
} else {
std::cout<<argv[3]<<std::endl;
config["environment"]["render"] = true;
}

config_str << config["environment"];

VectorizedEnvironment<ENVIRONMENT> vecEnv(resourceDir, config_str.str());
vecEnv.init();

EigenRowMajorMat observation(config["environment"]["num_envs"].as<int>(), vecEnv.getObDim());
EigenRowMajorMat action(config["environment"]["num_envs"].as<int>(), vecEnv.getActionDim());
EigenVec reward(config["environment"]["num_envs"].as<int>(), 1);
EigenBoolVec dones(config["environment"]["num_envs"].as<int>(), 1);
EigenRowMajorMat extra_info(config["environment"]["num_envs"].as<int>(), vecEnv.getExtraInfoDim());

Eigen::Ref<EigenRowMajorMat> ob_ref(observation), action_ref(action), extra_info_ref(extra_info);
Eigen::Ref<EigenVec> reward_ref(reward);
Eigen::Ref<EigenBoolVec> dones_ref(dones);

vecEnv.reset(ob_ref);
vecEnv.step(action_ref, ob_ref, reward_ref, dones_ref, extra_info_ref);

return 0;
}
5 changes: 2 additions & 3 deletions raisim_gym/env/env/ANYmal/ANYmal_bear2/default_cfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ seed: 1
record_video: yes

environment:
render: yes
render: True
num_envs: 100
num_threads: 40
simulation_dt: 0.0025
control_dt: 0.01
max_time: 4.0

forwardVelRewardCoeff: 0.3
torqueRewardCoeff: -2e-5
torqueRewardCoeff: -2e-5
19 changes: 10 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@

__CMAKE_PREFIX_PATH__ = None
__ENVIRONMENT_PATH__ = None
__DEBUG__ = False

if "--CMAKE_PREFIX_PATH" in sys.argv:
index = sys.argv.index('--CMAKE_PREFIX_PATH')
__CMAKE_PREFIX_PATH__ = sys.argv[index+1]
sys.argv.remove("--CMAKE_PREFIX_PATH")
sys.argv.remove(__CMAKE_PREFIX_PATH__)

if "--Debug" in sys.argv:
index = sys.argv.index('--Debug')
sys.argv.remove("--Debug")
__DEBUG__ = True

if "--env" in sys.argv:
index = sys.argv.index('--env')
environment = sys.argv[index+1]
Expand Down Expand Up @@ -66,16 +72,11 @@ def build_extension(self, ext):

cmake_args.append('-DRSG_ENVIRONMENT_INCLUDE_PATH=' + __ENVIRONMENT_PATH__)

cfg = 'Debug' if self.debug else 'Release'
cfg = 'Debug' if __DEBUG__ else 'Release'
build_args = ['--config', cfg]
if platform.system() == "Windows":
cmake_args += ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), extdir)]
if sys.maxsize > 2**32:
cmake_args += ['-A', 'x64']
build_args += ['--', '/m']
else:
cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
build_args += ['--', '-j2']

cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
build_args += ['--', '-j2']

env = os.environ.copy()
env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''),
Expand Down

0 comments on commit c765e96

Please sign in to comment.