Skip to content

Commit

Permalink
Merge pull request #235 from LuziaKn/ft-add-general-visualization
Browse files Browse the repository at this point in the history
add general visualization
  • Loading branch information
maxspahn authored Oct 10, 2023
2 parents 6cd2dce + 3fbc205 commit fdfe3d9
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions urdfenvs/urdf_common/urdf_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def __init__(
self._obsts: dict = {}
self._collision_links: dict = {}
self._collision_links_poses: dict = {}
self._visualizations: dict = {}
self._goals: dict = {}
self._space_set = False
self._observation_checking = observation_checking
Expand Down Expand Up @@ -227,6 +228,7 @@ def step(self, action: np.ndarray):
self.update_obstacles()
self.update_goals()
self.update_collision_links()

p.stepSimulation(self._cid)
for robot_id, robot in enumerate(self._robots):
contacts = p.getContactPoints(robot._robot)
Expand Down Expand Up @@ -337,6 +339,14 @@ def update_collision_links(self) -> None:
visual_shape_id, translation, rotation
)

def update_visualizations(self, positions) -> None:
for visual_shape_id, info in self._visualizations.items():
position = positions[visual_shape_id-1]
rotation = [1, 0, 0, 0]
p.resetBasePositionAndOrientation(
visual_shape_id, position, rotation
)

def collision_links_poses(self, position_only: bool=False) -> dict:
if position_only:
result_dict = {}
Expand Down Expand Up @@ -405,6 +415,27 @@ def reset_goals(self) -> None:
def get_obstacles(self) -> dict:
return self._obsts

def add_visualization(
self,shape_type: str = "cylinder",
size: Optional[List[float]] = None,
rgba_color: Optional[np.ndarray] = [1.0, 1.0, 0.0, 0.3],
) -> int:

length = [1.0]
if size is None:
size = [1.0, 0.2]

bullet_id = add_shape(
shape_type,
size,
rgba_color,
with_collision_shape=False,
)

self._visualizations[bullet_id] = (bullet_id)

return bullet_id

def add_collision_link(
self,
robot_index: int = 0,
Expand Down

0 comments on commit fdfe3d9

Please sign in to comment.