Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
2a3b8d7
allow order objects by position in view, reposition camera, narrower …
Feb 14, 2020
f37876a
field of view back to 120 degrees
Feb 14, 2020
781e6c2
add agent's absolute position and pose into observation
May 14, 2020
ab15b68
non-egocentric full state observation for GoalTask
Jul 28, 2020
4b1dfd1
goal conditioned GoalTask and PlayGround env, with -1/0 reward
Jul 30, 2020
fd43286
simplify
Jul 30, 2020
e2c6130
fix after rebase
Jul 30, 2020
5aa122e
plot goal range in tensorboard
Aug 1, 2020
341460c
add comments for goal conditioned task
Aug 3, 2020
36c3690
properly return random_range always, to report goal_range metric (epi…
Aug 13, 2020
596e0d6
fix goal_range reporting to only report it once at episode end
Aug 14, 2020
5ef28e9
terminate gzclient at env close(), fix bug where direction not ignore…
Aug 25, 2020
b25a51c
address comments
Aug 27, 2020
9f3051d
make "human" rendering consistent with "rgb_array" - video recording
Aug 28, 2020
8281a65
use aux achieved field in goal conditioned GoalTask.
Sep 4, 2020
9bd0d52
add the option to only plan x-y related dimensions in aux_achieved
Sep 4, 2020
a94601f
multi dimensional reward for goal conditioned goal task
Sep 9, 2020
dca0807
adding a smaller ball to indicate target for pioneer, so it doesn't c…
Sep 9, 2020
411a096
fix missing distraction penalty
Sep 10, 2020
849b5ea
address comments from JT
Sep 10, 2020
9d0dd00
missed one fix
Sep 10, 2020
92db4a0
address comments, move goal_conditioned obs generation to GoalTask
Sep 15, 2020
dba0931
use more readable states to generate goal conditioned output
Sep 15, 2020
b7d0ab4
address comments from JT.
Sep 16, 2020
da45b96
remove unused var use_full_states
Sep 17, 2020
19ce0c7
random agent start position in GoalTask. Fix initial_dist and prev_d…
Oct 5, 2020
47b2ee9
more debug printing of agent states at episode end
Oct 31, 2020
200368d
add short walls to enclose playground
Nov 6, 2020
593135a
allow chaining goaltask together with probability, also avoids resett…
Nov 11, 2020
9734ffb
allow setting min_distance of goal to agent's location, so now goal r…
Jan 13, 2021
5c98ed0
allow using speed_goal (besides position goal) in GoalTask.
Jan 21, 2021
e454aee
allow setting speed limit in speed goal task, refactor
Jan 26, 2021
0bdca8c
more debug info for goal task to output states when reward achieved.
Apr 7, 2021
1b71a77
add PushReachTask
May 17, 2021
25b0f89
fix goal dist output bug
May 26, 2021
37da328
Merge branch 'focused_explore' into pushreachtask
May 26, 2021
30864bb
allow obj to be initialized closer to the agent
Jun 8, 2021
4fee570
update some doc
Jun 8, 2021
ed5f7b6
allow using obj pose, move obj at least 0.3 away from agent.
Jun 15, 2021
d68a3ff
allow moving target relative to object position, vs agent
Jun 19, 2021
5908648
allow turn off multi dim reward in push task; more debug printing.
Aug 12, 2021
8bd8753
proper seeding of envs for deterministic randomization
Aug 16, 2021
8a15ea9
mode with Push and Reach goals in a single PushReachTask.
Sep 21, 2021
b90e6e5
update Pioneer tasks (target navigation, push reach) to alf config
Apr 28, 2022
9185962
depend on alf for alf.config
Apr 28, 2022
cc5c764
update alf image
Apr 28, 2022
7460efd
Revert "update alf image"
Apr 29, 2022
25cc082
Revert "depend on alf for alf.config"
Apr 29, 2022
484b0f9
Revert "update Pioneer tasks (target navigation, push reach) to alf c…
Apr 29, 2022
611dbd3
pose only goal for goal task
Oct 5, 2022
96ea226
adding ghost pioneer car to indicate goal position and orientation in…
Oct 6, 2022
3a17001
allow additionally including x-y speed and yaw (together with x-y pos…
Oct 7, 2022
9f13d98
goal conditioned dense reward for goal task
Oct 11, 2022
8729406
allow position and speed goal multiplier in GoalTask to be roughly at…
Oct 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ You also need to install the following packages:
apt install python3-tk
```

## Download
```bash
git clone --recursive https://github.com/HorizonRobotics/SocialRobot
```

## To compile
```bash
cd REPO_ROOT
Expand All @@ -27,7 +32,7 @@ mkdir build
cd build
cmake ..
make -j
cd REPO_ROOT
cd .. # REPO_ROOT
pip3 install -e .
```
if cmake .. complains about cannot find configuration file provided by "gazebo", run
Expand Down Expand Up @@ -165,6 +170,22 @@ It's not so easy, for some task you may need some trials to complete it. An exam
### python
You need to make sure the python you use matches the python found by cmake. You can check this by looking at REPO_ROOT/build/CMakeCache.txt

### Python config cmake errors
```
CMake Error at pybind11/tools/FindPythonLibsNew.cmake:95 (message):
Python config failure:

Call Stack (most recent call first):
pybind11/tools/pybind11Tools.cmake:16 (find_package)
pybind11/CMakeLists.txt:33 (include)
```

Remove the makefiles and build again:
```bash
cd REPO_ROOT
rm -rf build
```

### display

You need to make sure your `DISPLAY` environment variable points to a valid display, otherwise camera sensor cannot be created and there will be the following error:
Expand Down
6 changes: 6 additions & 0 deletions pygazebo/pygazebo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <gazebo/sensors/SensorManager.hh>
#include <gazebo/sensors/SensorsIface.hh>
#include <gazebo/util/LogRecord.hh>
#include <ignition/math/Rand.hh>
#include <mutex> // NOLINT
#include <sstream>

Expand Down Expand Up @@ -469,6 +470,7 @@ class World {

void Initialize(const std::vector<std::string>& args,
int port = 0,
int seed = -1,
bool quiet = false) {
if (port != 0) {
std::string uri = "localhost:" + std::to_string(port);
Expand All @@ -477,6 +479,9 @@ void Initialize(const std::vector<std::string>& args,
if (!gazebo_initialized) {
gazebo::common::Console::SetQuiet(quiet);
gazebo::setupServer(args);
if (seed >= 0) {
ignition::math::Rand::Seed((unsigned int)seed);
}
// gazebo::runWorld uses World::RunLoop(). RunLoop() starts LogWorker()
// every time. LogWorker will always store something in the buffer when
// it is started. But we don't have a running LogRecord to collect all
Expand Down Expand Up @@ -568,6 +573,7 @@ PYBIND11_MODULE(pygazebo, m) {
"Initialize",
py::arg("args") = std::vector<std::string>(),
py::arg("port") = 0,
py::arg("seed") = -1,
py::arg("quiet") = false);

m.def("close", &Close, "Shutdown everything of gazebo");
Expand Down
15 changes: 13 additions & 2 deletions python/social_bot/envs/gazebo_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def __init__(self,
world_config=None,
sim_time_precision=0.001,
port=None,
seed=-1,
use_port_in_gz_seed=True,
quiet=False):
"""
Args:
Expand All @@ -52,6 +54,10 @@ def __init__(self,
see `_modify_world_xml` for details
sim_time_precision (float): the time precision of the simulator
port (int): Gazebo port
seed (int): random seed for gazebo, -1 for using the default: PID
use_port_in_gz_seed (bool): if True, use port and seed in gazebo seed.
Set to False when doing repeatability debugging. Set to True when
running several envs in parallel during regular training.
quiet (bool) Set quiet output
"""
os.environ["GAZEBO_MODEL_DATABASE_URI"] = ""
Expand All @@ -61,12 +67,17 @@ def __init__(self,
# This avoids different parallel simulations having the same randomness.
# When calling from alf, alf.environments.utils.create_environment calls
# env.seed() afterwards, which is the real seed being used. Not this one.
random.seed(port)
_seed = port
if seed >= 0:
_seed = seed
if use_port_in_gz_seed:
_seed += port
random.seed(_seed)
self._rendering_process = None
self._rendering_camera = None
# the default camera pose for rendering rgb_array, could be override
self._rendering_cam_pose = "10 -10 6 0 0.4 2.4"
gazebo.initialize(port=port, quiet=quiet)
gazebo.initialize(port=port, seed=_seed, quiet=quiet)

if world_file:
world_file_abs_path = os.path.join(social_bot.get_world_dir(),
Expand Down
4 changes: 2 additions & 2 deletions python/social_bot/envs/play_ground.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from social_bot.envs.gazebo_base import GazeboEnvBase
from social_bot.teacher import TaskGroup
from social_bot.teacher import TeacherAction
from social_bot.tasks import GoalTask, ICubAuxiliaryTask, KickingBallTask, Reaching3D
from social_bot.tasks import GoalTask, PushReachTask, ICubAuxiliaryTask, KickingBallTask, Reaching3D


@gin.configurable
Expand Down Expand Up @@ -173,7 +173,7 @@ def __init__(self,
self._teacher = teacher.Teacher(task_groups_exclusive=False)
self._has_goal_task = False
for task in tasks:
if task == GoalTask:
if task in (GoalTask, PushReachTask):
self._has_goal_task = True
task_group = TaskGroup()
task_group.add_task(task(env=self, max_steps=max_steps))
Expand Down
102 changes: 102 additions & 0 deletions python/social_bot/models/pioneer2dx_noplugin_ghost/model-ghost.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" ?>
<sdf version="1.5">
<model name="pioneer2dx_noplugin_ghost">
<static>true</static>
<link name="chassis">
<pose>0 0 0.16 0 0 0</pose>
<inertial>
<mass>5.67</mass>
<inertia>
<ixx>0.07</ixx>
<iyy>0.08</iyy>
<izz>0.10</izz>
<ixy>0</ixy>
<ixz>0</ixz>
<iyz>0</iyz>
</inertia>
</inertial>
<visual name="visual">
<pose>0 0 0.04 0 0 0</pose>
<geometry>
<mesh>
<uri>model://pioneer2dx/meshes/chassis.dae</uri>
</mesh>
</geometry>
<transparency>0.7</transparency>
</visual>
<visual name="castor_visual">
<transparency>0.7</transparency>
<pose>-0.200 0 -0.12 0 0 0</pose>
<geometry>
<sphere>
<radius>0.04</radius>
</sphere>
</geometry>
<material>
<script>
<uri>file://media/materials/scripts/gazebo.material</uri>
<name>Gazebo/FlatBlack</name>
</script>
</material>
</visual>
</link>
<link name="right_wheel">
<pose>0.1 -.17 0.11 0 1.5707 1.5707</pose>
<inertial>
<mass>1.5</mass>
<inertia>
<ixx>0.0051</ixx>
<iyy>0.0051</iyy>
<izz>0.0090</izz>
<ixy>0</ixy>
<ixz>0</ixz>
<iyz>0</iyz>
</inertia>
</inertial>
<visual name="visual">
<transparency>0.7</transparency>
<geometry>
<cylinder>
<radius>0.11</radius>
<length>0.05</length>
</cylinder>
</geometry>
<material>
<script>
<uri>file://media/materials/scripts/gazebo.material</uri>
<name>Gazebo/FlatBlack</name>
</script>
</material>
</visual>
</link>
<link name="left_wheel">
<pose>0.1 .17 0.11 0 1.5707 1.5707</pose>
<inertial>
<mass>1.5</mass>
<inertia>
<ixx>0.0051</ixx>
<iyy>0.0051</iyy>
<izz>0.0090</izz>
<ixy>0</ixy>
<ixz>0</ixz>
<iyz>0</iyz>
</inertia>
</inertial>
<visual name="visual">
<transparency>0.7</transparency>
<geometry>
<cylinder>
<radius>0.11</radius>
<length>0.05</length>
</cylinder>
</geometry>
<material>
<script>
<uri>file://media/materials/scripts/gazebo.material</uri>
<name>Gazebo/FlatBlack</name>
</script>
</material>
</visual>
</link>
</model>
</sdf>
21 changes: 21 additions & 0 deletions python/social_bot/models/pioneer2dx_noplugin_ghost/model.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>

<model>
<!-- This is essentially same as the original Pioneer 2DX model without the model plugin -->
<name>Pioneer 2DX Ghost</name>
<version>1.0</version>
<sdf version="1.5">model-ghost.sdf</sdf>

<author>
<name>Nate Koenig</name>
<email>nate@osrfoundation.org</email>
</author>

<description>
A model of the pioneer 2 dx robot. This is same as https://bitbucket.org/osrf/gazebo_models/src/default/pioneer2dx/
with the plugin removed.
</description>

<depend>
</depend>
</model>
2 changes: 1 addition & 1 deletion python/social_bot/models/target_ball/model.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<visual name="visual">
<geometry>
<sphere>
<radius>0.03</radius>
<radius>0.1</radius>
</sphere>
</geometry>
<material>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>

<model>
<name>Wood cube 30cm</name>
<version>1.0</version>
<sdf version='1.5'>model.sdf</sdf>

<author>
<name>Nate Koenig</name>
<email>nate@osrfoundation.org</email>
</author>

<description>
A 30cm^3 wooden cube modified from the 10x10x10 cm wooden cube.
The 5cm height offset of the internal link has been removed from the original version.
Also reduced mass by 0.3, and friction to 1/2.
</description>
</model>
63 changes: 63 additions & 0 deletions python/social_bot/models/wood_cube_30cm_without_offset/model.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" ?>
<sdf version="1.5">
<model name="wood_cube_30cm_without_offset">
<link name="link">
<inertial>
<mass>0.2167</mass>
<inertia>
<ixx>0.0008611666666666669</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.0008611666666666669</iyy>
<iyz>0</iyz>
<izz>0.0008611666666666669</izz>
</inertia>
</inertial>

<collision name="collision">
<geometry>
<box>
<size>0.3 0.3 0.3</size>
</box>
</geometry>
<surface>
<contact>
<!-- Red Pine coefficients for longitudinal axis of the wood
according to:
http://www.fpl.fs.fed.us/documnts/fplgtr/fplgtr113/ch04.pdf -->
<poissons_ratio>0.347</poissons_ratio>
<elastic_modulus>8.8e+09</elastic_modulus>
<ode>
<kp>100000</kp>
<kd>100</kd>
<max_vel>100.0</max_vel>
<min_depth>0.001</min_depth>
</ode>
</contact>
<friction>
<torsional>
<coefficient>0.5</coefficient>
<use_patch_radius>0</use_patch_radius>
<surface_radius>0.01</surface_radius>
</torsional>
</friction>
</surface>
</collision>

<visual name="visual">
<geometry>
<box>
<size>0.3 0.3 0.3</size>
</box>
</geometry>
<material>
<script>
<uri>file://media/materials/scripts/gazebo.material</uri>
<name>Gazebo/Wood</name>
</script>
</material>
</visual>

</link>
</model>
</sdf>
Loading