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

[Question] Seeking Assistance for Resolving Configuration Error in SKRL Training with Franka Lift Environment #155

Closed
XInyuSong000 opened this issue Dec 3, 2023 · 2 comments
Labels
question Further information is requested

Comments

@XInyuSong000
Copy link

Question

Hi, I attempted to integrate a camera sensor into the Franka Lift environment as outlined here: Integration Guide. The observation space seems to be functioning correctly, as I can successfully execute the command ./orbit.sh -p source/standalone/environments/random_agent.py --task Isaac-Lift-Franka-v0 --num_envs 2 without encountering any errors.

However, issues arose when I tried using SKRL to test the environment. In the torch_lift_franka_ppo.py file, I modified the model to use CNN for image input and adjusted several hyperparameters accordingly:

memory = RandomMemory(memory_size=4, num_envs=env.num_envs, device=device)

cfg["rollouts"] = 4  # memory_size
cfg["learning_epochs"] = 5
cfg["mini_batches"] = 2

When attempting to run SKRL training with two environments using the command ./orbit.sh -p torch_lift_franka_ppo.py --num_envs 2 --headless, I encountered the following error:

./orbit.sh -p torch_lift_franka_ppo.py --num_envs 2 --headless
...
...
Traceback (most recent call last):
  File " torch_lift_franka_ppo.py", line 244, in <module>
    trainer.train()
  File "/home/wuyou/.local/share/ov/pkg/isaac_sim-2022.2.1/kit/python/lib/python3.7/site-packages/skrl/trainers/torch/sequential.py", line 77, in train
    self.single_agent_train()
  File "/home/wuyou/.local/share/ov/pkg/isaac_sim-2022.2.1/kit/python/lib/python3.7/site-packages/skrl/trainers/torch/base.py", line 193, in single_agent_train
    self.agents.post_interaction(timestep=timestep, timesteps=self.timesteps)
  File "/home/wuyou/.local/share/ov/pkg/isaac_sim-2022.2.1/kit/python/lib/python3.7/site-packages/skrl/agents/torch/ppo/ppo.py", line 294, in post_interaction
    self._update(timestep, timesteps)
  File "/home/wuyou/.local/share/ov/pkg/isaac_sim-2022.2.1/kit/python/lib/python3.7/site-packages/skrl/agents/torch/ppo/ppo.py", line 384, in _update
    _, next_log_prob, _ = self.policy.act({"states": sampled_states, "taken_actions": sampled_actions}, role="policy")
  File "torch_lift_franka_ppo.py", line 87, in act
    return GaussianMixin.act(self, inputs, role)
  File "/home/wuyou/.local/share/ov/pkg/isaac_sim-2022.2.1/kit/python/lib/python3.7/site-packages/skrl/models/torch/gaussian.py", line 160, in act
    log_prob = self._g_distribution[role].log_prob(inputs.get("taken_actions", actions))
  File "/home/wuyou/.local/share/ov/pkg/isaac_sim-2022.2.1/extscache/omni.pip.torch-1_13_1-0.1.4+104.2.lx64/torch-1-13-1/torch/distributions/normal.py", line 79, in log_prob
    self._validate_sample(value)
  File "/home/wuyou/.local/share/ov/pkg/isaac_sim-2022.2.1/extscache/omni.pip.torch-1_13_1-0.1.4+104.2.lx64/torch-1-13-1/torch/distributions/distribution.py", line 283, in _validate_sample
    format(actual_shape, expected_shape))
ValueError: Value is not broadcastable with batch_shape+event_shape: torch.Size([4, 8]) vs torch.Size([2, 8]).

It appears that training only initiates successfully when both mini_batches and rollouts are set to the same number. Could there be an oversight in my environment configuration that is causing this error?

@Mayankm96
Copy link
Contributor

@Toni-SM Do you have an idea on this?

@Mayankm96 Mayankm96 added the question Further information is requested label Dec 6, 2023
Mayankm96 pushed a commit that referenced this issue Dec 10, 2023
# Description

This MR updates the tutorials to the latest version of Orbit. It
introduced a new structure for them. They cover basic sim elements,
assets, sensors, scenes, and envs.

Fixes #190 , #149 , #148 , #147 , #151, #152, #155, #156, #157

## Type of change

- New feature (non-breaking change which adds functionality)
- This change requires a documentation update

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

---------

Signed-off-by: Pascal Roth <57946385+pascal-roth@users.noreply.github.com>
Co-authored-by: James Smith <jsmith@theaiinstitute.com>
Mayankm96 pushed a commit that referenced this issue Dec 22, 2023
# Description

This MR updates the tutorials to the latest version of Orbit. It
introduced a new structure for them. They cover basic sim elements,
assets, sensors, scenes, and envs.

Fixes #190 , #149 , #148 , #147 , #151, #152, #155, #156, #157

## Type of change

- New feature (non-breaking change which adds functionality)
- This change requires a documentation update

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

---------

Signed-off-by: Pascal Roth <57946385+pascal-roth@users.noreply.github.com>
Co-authored-by: James Smith <jsmith@theaiinstitute.com>
@Mayankm96
Copy link
Contributor

Closing this issue since it is not related to Orbit library itself. Please open an issue on skrl to receive a faster response from the team there.

fatimaanes pushed a commit to fatimaanes/omniperf that referenced this issue Aug 8, 2024
# Description

This MR updates the tutorials to the latest version of Orbit. It
introduced a new structure for them. They cover basic sim elements,
assets, sensors, scenes, and envs.

Fixes isaac-sim#190 , isaac-sim#149 , isaac-sim#148 , isaac-sim#147 , isaac-sim#151, isaac-sim#152, isaac-sim#155, isaac-sim#156, isaac-sim#157

## Type of change

- New feature (non-breaking change which adds functionality)
- This change requires a documentation update

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

---------

Signed-off-by: Pascal Roth <57946385+pascal-roth@users.noreply.github.com>
Co-authored-by: James Smith <jsmith@theaiinstitute.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants