Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gymnasium interface changes #228

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

mkhoshnam
Copy link

This pull request introduces the gymnasium_interface module, which includes the following files:

**- example.py: An example file for using the Gymnasium interface.

  • pycram_gym_env.py: The implementation of the environment interface for Gymnasium.
    
  • task_executor.py: A script for executing tasks within the Gymnasium environment.**
    

These files are added as part of integrating the Gymnasium interface into the existing PyCRAM system. The new module will allow interaction with Gym environments, enabling reinforcement learning and other task execution capabilities.

Additionally, I have ensured that only the necessary files related to the Gymnasium interface have been pushed, without including the entire dev branch.

}

# Define objects to initialize in the environment
objects = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs some more engineering. Perhaps objects that do not have worlds yet? Please prepare a short discussion of this kind of problem for the next pycram meeting


# Define default parameters for each action
default_params = {
"navigate": {"target_pose": Pose(position=[1.0, 2.0, 0.0], orientation=[0.0, 0.0, 0.0, 1.0])},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be function points in my opinion and not key-value stores

:type reward_function: callable
"""

def __init__(self, actions, default_params=None, objects=None, reward_function=None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use function points instead, talk with @Leusmann how to do so

calculations.

:param actions: List of valid action classes or functions (e.g., [NavigateAction, PickUpAction]).
:type actions: list
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

annotate types in the constructor, not in the docstring.

"""
Resets the environment.

:return: The initial state of the environment.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this docstring should be inherited from the super class

def _place(self, params):
"""
Places an object at a target location.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

types 👏 in 👏 the 👏 signature 👏

def _open(self, params):
"""
Opens an object (e.g., a drawer or door).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

types 👏 in 👏 the 👏 signature 👏

"""
Closes an object (e.g., a drawer or door).

:param params: Parameters for the close action, including "handle_desig" and "arm".
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

types 👏 in 👏 the 👏 signature 👏

Resets the simulation environment dynamically by clearing the world and adding new objects.

:param objects: List of objects to be added to the environment.
:type objects: list[dict]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

types 👏 in 👏 the 👏 signature 👏

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally the structure here is very repetitive with pycram designators, this should not be

@@ -0,0 +1,2 @@
from gymnasium_interface.pycram_gym_env import PyCRAMGymEnv
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this relative imports

@@ -0,0 +1,54 @@
import logging
from gymnasium_interface.pycram_gym_env import PyCRAMGymEnv
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make these relative imports

from pycram.datastructures.pose import Pose

# Configure logging
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the logging from pycram.ros.logging instead of the Python logging

Handles task execution in a PyCRAM environment. This class integrates with BulletWorld
for managing objects and robot tasks in the simulation.

Attributes:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use rst syntax for the doc string

@@ -0,0 +1,178 @@
from pycram.worlds.bullet_world import BulletWorld
from pycram.world_concepts.world_object import Object
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relative imports

from typing import Dict, List, Union

# Configure logging
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use logging from pycram.ros.logging

self.clear_world()

# Reload the apartment URDF
self.apartment = Object("apartment", "environment", "apartment.urdf")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ObjectType.ENVIRONMENT instead of the string

else:
raise ValueError(f"Unknown action: {action}")

def _navigate(self, params: Dict[str, Pose]) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you execute the action directly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants