Skip to content

Commit

Permalink
update the color of robots and the background
Browse files Browse the repository at this point in the history
  • Loading branch information
YIFANSUN98 committed May 31, 2024
1 parent 5d47a91 commit a5b1f53
Show file tree
Hide file tree
Showing 44 changed files with 15,935 additions and 36 deletions.
Binary file added images/constraints/ghost3Ds_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/constraints/ghost3Ds_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/constraints/ghosts_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/constraints/ghosts_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/constraints/hazard3Ds_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/constraints/hazard3Ds_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/robots/ant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/robots/arm3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/robots/arm6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/robots/car.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/robots/doggo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/robots/drone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/robots/hopper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/robots/humanoid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/robots/point.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/robots/swimmer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/robots/walker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/tasks/chase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/tasks/defense.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/tasks/goal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/tasks/push.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 12 additions & 4 deletions safe_rl_envs/safe_rl_envs/envs/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,23 @@ def build(self):
equality['weld'] = []

# Add asset section if missing

# <texture type="skybox" builtin="gradient" rgb1="0.527 0.582 0.906" rgb2="0.1 0.1 0.35"
# width="800" height="800" markrgb="1 1 1" mark="random" random="0.001"/>

asset = xmltodict.parse(f'''
<asset>
<texture name="texplane" builtin="checker" height="100" width="100"
rgb1="0.7 0.7 0.7" rgb2="0.8 0.8 0.8" type="2d"/>
<texture type="skybox" builtin="gradient" rgb1="0.527 0.582 0.906" rgb2="0.1 0.1 0.35"
width="800" height="800" markrgb="1 1 1" mark="random" random="0.001"/>
<material name="MatPlane" reflectance="0.1" shininess="0.1" specular="0.1"
texrepeat="10 10" texture="texplane"/>
<texture name="texplane2" builtin="checker" height="100" width="100"
rgb1="0.8 0.8 0.8" rgb2="0.6 0.6 0.6" type="2d"/>
<texture name="my_texture" type="2d" file="xmls/image.png"/>
<texture type="skybox" builtin="gradient" rgb1="0.1 0.1 0.6" rgb2="0. 0. 0.2"
width="800" height="800" markrgb="1 1 1" mark="random" random="0.0"/>
<material name="MatPlane2" reflectance="0.3" shininess=".1" specular=".1"
texrepeat="2 2" texture="my_texture"/>
</asset>
''')
xml_path = os.path.dirname(os.path.join(BASE_DIR, self.robot_base))
Expand Down Expand Up @@ -166,7 +174,7 @@ def build(self):
# Make sure floor renders the same for every world
for g in worldbody['geom']:
if g['@name'] == 'floor':
g.update({'@size': convert(self.floor_size), '@rgba': '1 1 1 1', '@material': 'MatPlane'})
g.update({'@size': convert(self.floor_size), '@rgba': '1 1 1 1', '@material': 'MatPlane2'})

# Add cameras to the XML dictionary
cameras = xmltodict.parse('''<b>
Expand Down
35 changes: 19 additions & 16 deletions safe_rl_envs/safe_rl_envs/myTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,34 +62,34 @@ def run_random(env_name):
# }
config = {
# robot setting
'robot_base': 'xmls/drone.xml',
'robot_base': 'xmls/ant.xml',

# task setting
'task': 'goal',
'goal_3D': True,
'goal_z_range': [0.5,1.5],
'task': 'chase',
'goal_size': 0.5,

# observation setting
'observe_goal_comp': True, # Observe the goal with a lidar sensor
'observe_hazard3Ds': True, # Observe the vector from agent to hazards
'compass_shape': 3,
'observe_robbers': False, # Observe the goal with a lidar sensor
'observe_ghosts': True, # Observe the vector from agent to hazards
'sensors_obs': ['accelerometer', 'velocimeter', 'gyro', 'magnetometer',
'touch_p1a', 'touch_p1b', 'touch_p2a', 'touch_p2b',
'touch_p3a', 'touch_p3b', 'touch_p4a', 'touch_p4b'],
'touch_ankle_1a', 'touch_ankle_2a', 'touch_ankle_3a', 'touch_ankle_4a',
'touch_ankle_1b', 'touch_ankle_2b', 'touch_ankle_3b', 'touch_ankle_4b'],


# constraint setting
'constrain_hazard3Ds': True, # Constrain robot from being in hazardous areas
'constrain_ghosts': True, # Constrain robot from being in hazardous areas
'constrain_indicator': False, # If true, all costs are either 1 or 0 for a given step. If false, then we get dense cost.

# lidar setting
'lidar_num_bins': 10,
'lidar_num_bins3D': 6,
'lidar_num_bins': 16,

# object setting
'hazard3Ds_num': 8,
'hazard3Ds_size': 0.3,
'hazard3Ds_z_range': [0.5, 1.5],
'ghosts_num': 8,
'ghosts_size': 0.3,
'ghosts_travel':2.5,
'ghosts_safe_dist': 1.5,
'robbers_num': 0,
'robbers_size': 0.3,
}
env = Engine(config)
obs = env.reset()
Expand Down Expand Up @@ -204,9 +204,12 @@ def run_random(env_name):
# import ipdb;ipdb.set_trace()
o = env.reset()
# import ipdb;ipdb.set_trace()
if cnt > 10000:
if cnt > 800:
import ipdb;ipdb.set_trace()
break

env.render()

print("##", time.time() - t)

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion safe_rl_envs/safe_rl_envs/xmls/ant.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<size njmax="3000" nconmax="1000"/>
<default>
<joint armature="1" damping="1" limited="true"/>
<geom condim="6" density="5.0" friction="0.75 0.01 0.01" margin="0.01" rgba="1 0 0 1"/>
<geom condim="6" density="5.0" friction="0.75 0.01 0.01" margin="0.01" rgba="1 0.6 0 1"/>
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="30"/>
<site size="0.2" type="sphere" rgba="0 0 1 0"/>
</default>
Expand Down
2 changes: 1 addition & 1 deletion safe_rl_envs/safe_rl_envs/xmls/arm_3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<option gravity="0 0 0" timestep="0.002"/>
<default>
<joint limited="false" damping="5000" range="-180 180" />
<geom condim="6" size="0.032" rgba="1 0 0 0.5" type="capsule" density="0.01"/>
<geom condim="6" size="0.032" rgba="1 0.6 0 1" type="capsule" density="0.01"/>
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="3000"/>
<site size="0.05" type="sphere" rgba="0 0 1 0"/>
</default>
Expand Down
2 changes: 1 addition & 1 deletion safe_rl_envs/safe_rl_envs/xmls/arm_6.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<option gravity="0 0 0" timestep="0.002"/>
<default>
<joint limited="false" damping="5000" range="-180 180" />
<geom condim="6" size="0.032" rgba="1 0 0 0.5" type="capsule" density="0.01"/>
<geom condim="6" size="0.032" rgba="1 0.6 0 1" type="capsule" density="0.01"/>
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="2000"/>
<site size="0.05" type="sphere" rgba="0 0 1 1"/>
</default>
Expand Down
2 changes: 1 addition & 1 deletion safe_rl_envs/safe_rl_envs/xmls/car.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<size njmax="3000" nconmax="1000"/>
<option timestep="0.004"/>
<default>
<geom condim="6" density="5" rgba="1 0 0 1" size=".05" type="sphere"/>
<geom condim="6" density="5" rgba="1 0.6 0 1" size=".05" type="sphere"/>
<joint damping=".001"/>
<motor ctrlrange="-1 1" ctrllimited="true" forcerange="-.02 .02" forcelimited="true"/>
<site size="0.032" type="sphere"/>
Expand Down
2 changes: 1 addition & 1 deletion safe_rl_envs/safe_rl_envs/xmls/doggo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<size njmax="3000" nconmax="1000"/>
<default>
<joint limited="true" stiffness="0.01"/>
<geom condim="6" size="0.032" rgba="1 0 0 1" type="capsule" density="5"/>
<geom condim="6" size="0.032" rgba="1 0.6 0 1" type="capsule" density="5"/>
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear=".0125"/>
<site size="0.036" type="sphere" rgba="1 0 0 0"/>
</default>
Expand Down
2 changes: 1 addition & 1 deletion safe_rl_envs/safe_rl_envs/xmls/drone.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<size njmax="3000" nconmax="1000"/>
<option timestep="0.008"/>
<default>
<geom condim="6" density="1" rgba="1 0 0 1" />
<geom condim="6" density="1" rgba="1 0.6 0 1" />
<joint damping=".001"/>
<motor ctrlrange="-1 1" ctrllimited="true" forcerange="-.05 .05" forcelimited="true"/>
<velocity ctrlrange="-1 1" ctrllimited="true" forcerange="-.05 .05" forcelimited="true"/>
Expand Down
2 changes: 1 addition & 1 deletion safe_rl_envs/safe_rl_envs/xmls/hopper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<compiler angle="degree" coordinate="local" inertiafromgeom="true"/>
<default>
<joint armature="1" damping="1" limited="true"/>
<geom conaffinity="1" condim="6" contype="1" margin="0.001" rgba="1 0 0 1" solimp=".8 .8 .01" solref=".02 1"/>
<geom conaffinity="1" condim="6" contype="1" margin="0.001" rgba="1 0.6 0 1" solimp=".8 .8 .01" solref=".02 1"/>
<motor ctrllimited="true" ctrlrange="-.4 .4"/>
<site size="0.2" type="sphere" rgba="0 0 1 0"/>
</default>
Expand Down
4 changes: 2 additions & 2 deletions safe_rl_envs/safe_rl_envs/xmls/humanoid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<compiler angle="degree" inertiafromgeom="true"/>
<default>
<joint armature="10" damping="1" limited="true"/>
<geom condim="6" rgba="1 0 0 1"/>
<geom condim="6" rgba="1 0.6 0 1"/>
<motor ctrllimited="true" ctrlrange="-1.0 1.0"/>
<site size="0.1" type="sphere" rgba="0 0 1 0"/>
</default>
Expand All @@ -15,7 +15,7 @@
<geom name="floor" size="5 5 0.1" type="plane" condim="6"/>
<!-- <geom condim="3" material="MatPlane" name="floor" pos="0 0 0" size="10 10 0.125" type="plane"/>-->
<body name="robot" pos="0 0 1.28">
<site name="robot" rgba="1 0 0 .1"/>
<site name="robot" rgba="1 0 0 .0"/>
<camera name="vision" pos=".125 0 .2" xyaxes="0 -1 0 .4 0 1" fovy="100"/>
<!-- <joint armature="0" damping="0" limited="false" name="root" pos="0 0 0" stiffness="0" type="free"/> -->
<joint armature="0" axis="1 0 0" damping="0" limited="false" name="rootx" pos="0 0 0" stiffness="0" type="slide"/>
Expand Down
Binary file added safe_rl_envs/safe_rl_envs/xmls/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion safe_rl_envs/safe_rl_envs/xmls/point.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<size njmax="3000" nconmax="1000"/>
<option timestep="0.002"/>
<default>
<geom condim="6" density="1" rgba="1 0 0 1" />
<geom condim="6" density="1" rgba="1 0.6 0 1" />
<joint damping=".001"/>
<motor ctrlrange="-1 1" ctrllimited="true" forcerange="-.05 .05" forcelimited="true"/>
<velocity ctrlrange="-1 1" ctrllimited="true" forcerange="-.05 .05" forcelimited="true"/>
Expand Down
Loading

0 comments on commit a5b1f53

Please sign in to comment.