robotology / gym-ignition

Framework for developing OpenAI Gym robotics environments simulated with Ignition Gazebo
https://robotology.github.io/gym-ignition
GNU Lesser General Public License v3.0
220 stars 26 forks source link

Make command Failed #403

Open kashifzr opened 2 years ago

kashifzr commented 2 years ago
/gym-ignition/scenario/build$ make
[  8%] Built target tiny-process-library
[ 20%] Built target CoreUtils
[ 25%] Building CXX object src/gazebo/CMakeFiles/ScenarioGazebo.dir/src/World.cpp.o
/home/cde/gym-ignition/scenario/src/gazebo/src/World.cpp: In member function ‘bool scenario::gazebo::World::Impl::insertModel(const std::shared_ptr<sdf::v10::Root>&, const scenario::core::Pose&, const string&, scenario::gazebo::World&)’:
/home/cde/gym-ignition/scenario/src/gazebo/src/World.cpp:88:50: error: using element_type = class sdf::v10::Root {aka class sdf::v10::Root}’ has no member named ‘Model’
             finalModelEntityName = modelSdfRoot->Model()->Name();
                                                  ^~~~~
/home/cde/gym-ignition/scenario/src/gazebo/src/World.cpp:108:47: error: using element_type = class sdf::v10::Root {aka class sdf::v10::Root}’ has no member named ‘Model’
         const_cast<sdf::Model*>(modelSdfRoot->Model())
                                               ^~~~~
/home/cde/gym-ignition/scenario/src/gazebo/src/World.cpp:127:66: error: using element_type = class sdf::v10::Root {aka class sdf::v10::Root}’ has no member named ‘Model’
             this->sdfEntityCreator->CreateEntities(modelSdfRoot->Model());
                                                                  ^~~~~
/home/cde/gym-ignition/scenario/src/gazebo/src/World.cpp:134:54: error: using element_type = class sdf::v10::Root {aka class sdf::v10::Root}’ has no member named ‘Model’
             std::string modelNameSDF = modelSdfRoot->Model()->Name();
                                                      ^~~~~
src/gazebo/CMakeFiles/ScenarioGazebo.dir/build.make:62: recipe for target 'src/gazebo/CMakeFiles/ScenarioGazebo.dir/src/World.cpp.o' failed
make[2]: *** [src/gazebo/CMakeFiles/ScenarioGazebo.dir/src/World.cpp.o] Error 1
CMakeFiles/Makefile2:1913: recipe for target 'src/gazebo/CMakeFiles/ScenarioGazebo.dir/all' failed
make[1]: *** [src/gazebo/CMakeFiles/ScenarioGazebo.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

I am trying build gym-ignition from source make command does NOT works, I am using Ros2-Dashing and Ros-Melodic on ubuntu 18 bionic

diegoferigo commented 2 years ago

Can you please take the time to fill the information of the Bug report issue template first? I cannot guess what version you are trying to install against which Ignition distribution.

kashifzr commented 2 years ago

@diegoferigo my apologies for incomplete references Actually i am trying to build gym-ignition package, for building ign_moveit2. When I am installing on Ubuntu 20.04 Focal Fossa using pip install gym-ignition then I am facing libignition-gazebo6.so.6 missing as Import Error. I am using Gazebo11

diegoferigo commented 2 years ago

ScenarIO is compatible only with Ignition Gazebo (Fortress) and not Gazebo Classic (11). They are two different piece of software, you can read more here.

Once you have Ignition (Fortress) installed in your system, you can build the project from sources. If you want to use the binary wheel distributed on PyPI, only Ubuntu Focal is supported. However, also in this case, you must install first manually Ignition Gazebo Fortress, otherwise you get the error about the missing shared library. Apparently the logic of #399 is not fully working.

kashifzr commented 2 years ago

@diegoferigo Please have a look at this issue

System: Ubuntu 20.04 Focal Fossa

pip install scenario
Requirement already satisfied: scenario in ./.local/lib/python3.8/site-packages (1.3.0.post0)
Requirement already satisfied: packaging in /usr/lib/python3/dist-packages (from scenario) (20.3)
isr@isr-MS-7A64:~$ pip install gym-ignition
Requirement already satisfied: gym-ignition in ./.local/lib/python3.8/site-packages (1.3.0.post0)
Requirement already satisfied: gym>=0.13.1 in ./.local/lib/python3.8/site-packages (from gym-ignition) (0.21.0)
Requirement already satisfied: scipy in /usr/lib/python3/dist-packages (from gym-ignition) (1.3.3)
Requirement already satisfied: gym-ignition-models in ./.local/lib/python3.8/site-packages (from gym-ignition) (1.1.0)
Requirement already satisfied: numpy in ./.local/lib/python3.8/site-packages (from gym-ignition) (1.19.5)
Requirement already satisfied: lxml in /usr/lib/python3/dist-packages (from gym-ignition) (4.5.0)
Requirement already satisfied: scenario~=1.3.0 in ./.local/lib/python3.8/site-packages (from gym-ignition) (1.3.0.post0)
Requirement already satisfied: idyntree in ./.local/lib/python3.8/site-packages (from gym-ignition) (4.2.0)
Requirement already satisfied: cloudpickle>=1.2.0 in ./.local/lib/python3.8/site-packages (from gym>=0.13.1->gym-ignition) (2.0.0)
Requirement already satisfied: packaging in /usr/lib/python3/dist-packages (from scenario~=1.3.0->gym-ignition) (20.3)
isr@isr-MS-7A64:~$ python3
Python 3.8.10 (default, Sep 28 2021, 16:10:42) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import scenario
2021-10-18 19:09:57.105458: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/isr/ros2_foxy/install/rosbag2_transport/lib:/home/isr/ros2_foxy/install/rosbag2_compression/lib:/home/isr/ros2_foxy/install/zstd_vendor/lib:/home/isr/ros2_foxy/install/rviz_default_plugins/lib:/home/isr/ros2_foxy/install/rviz_common/lib:/home/isr/ros2_foxy/install/rosbag2_storage_default_plugins/lib:/home/isr/ros2_foxy/install/rosbag2_converter_default_plugins/lib:/home/isr/ros2_foxy/install/rosbag2_cpp/lib:/home/isr/ros2_foxy/install/rosbag2_storage/lib:/home/isr/ros2_foxy/install/yaml_cpp_vendor/opt/yaml_cpp_vendor/lib:/home/isr/ros2_foxy/install/ros1_bridge/lib:/home/isr/ros2_foxy/install/interactive_markers/lib:/home/isr/ros2_foxy/install/visualization_msgs/lib:/home/isr/ros2_foxy/install/robot_state_publisher/lib:/home/isr/ros2_foxy/install/kdl_parser/lib:/home/isr/ros2_foxy/install/urdf/lib:/home/isr/ros2_foxy/install/urdfdom/lib:/home/isr/ros2_foxy/install/turtlesim/lib:/home/isr/ros2_foxy/install/tf2_bullet/lib:/home/isr/ros2_foxy/install/tf2_ros/lib:/home/isr/ros2_foxy/install/tf2_msgs/lib:/home/isr/ros2_foxy/install/test_msgs/lib:/home/isr/ros2_foxy/install/demo_nodes_cpp/lib:/home/isr/ros2_foxy/install/composition/lib:/home/isr/ros2_foxy/install/rclpy/lib:/home/isr/ros2_foxy/install/action_tutorials_cpp/lib:/home/isr/ros2_foxy/install/rclcpp_action/lib:/home/isr/ros2_foxy/install/rcl_action/lib:/home/isr/ros2_foxy/install/move_base_msgs/lib:/home/isr/ros2_foxy/install/example_interfaces/lib:/home/isr/ros2_foxy/install/action_tutorials_interfaces/lib:/home/isr/ros2_foxy/install/action_msgs/lib:/home/isr/ros2_foxy/install/unique_identifier_msgs/lib:/home/isr/ros2_foxy/install/trajectory_msgs/lib:/home/isr/ros2_foxy/install/rqt_gui_cpp/lib:/home/isr/ros2_foxy/install/rclcpp_lifecycle/lib:/home/isr/ros2_foxy/install/logging_demo/lib:/home/isr/ros2_foxy/install/image_tools/lib:/home/isr/ros2_foxy/install/examples_rclcpp_minimal_composition/lib:/home/isr/ros2_foxy/install/demo_nodes_cpp_native/lib:/home/isr/ros2_foxy/install/rclcpp_components/lib:/home/isr/ros2_foxy/install/laser_geometry/lib:/home/isr/ros2_foxy/install/rclcpp/lib:/home/isr/ros2_foxy/install/rcl_lifecycle/lib:/home/isr/ros2_foxy/install/libstatistics_collector/lib:/home/isr/ros2_foxy/install/rcl/lib:/home/isr/ros2_foxy/install/tracetools/lib:/home/isr/ros2_foxy/install/tlsf/lib:/home/isr/ros2_foxy/install/qt_gui_cpp/lib:/home/isr/ros2_foxy/install/tf2_eigen_kdl/lib:/home/isr/ros2_foxy/install/tf2/lib:/home/isr/ros2_foxy/install/stereo_msgs/lib:/home/isr/ros2_foxy/install/std_srvs/lib:/home/isr/ros2_foxy/install/shape_msgs/lib:/home/isr/ros2_foxy/install/map_msgs/lib:/home/isr/ros2_foxy/install/sensor_msgs/lib:/home/isr/ros2_foxy/install/nav_msgs/lib:/home/isr/ros2_foxy/install/diagnostic_msgs/lib:/home/isr/ros2_foxy/install/geometry_msgs/lib:/home/isr/ros2_foxy/install/actionlib_msgs/lib:/home/isr/ros2_foxy/install/std_msgs/lib:/home/isr/ros2_foxy/install/statistics_msgs/lib:/home/isr/ros2_foxy/install/rcl_logging_spdlog/lib:/home/isr/ros2_foxy/install/rviz_rendering/lib:/home/isr/ros2_foxy/install/rviz_ogre_vendor/opt/rviz_ogre_vendor/lib:/home/isr/ros2_foxy/install/rttest/lib:/home/isr/ros2_foxy/install/rosgraph_msgs/lib:/home/isr/ros2_foxy/install/rmw_implementation/lib:/home/isr/ros2_foxy/install/rmw_fastrtps_dynamic_cpp/lib:/home/isr/ros2_foxy/install/rmw_fastrtps_cpp/lib:/home/isr/ros2_foxy/install/rmw_fastrtps_shared_cpp/lib:/home/isr/ros2_foxy/install/rmw_cyclonedds_cpp/lib:/home/isr/ros2_foxy/install/rmw_dds_common/lib:/home/isr/ros2_foxy/install/composition_interfaces/lib:/home/isr/ros2_foxy/install/rcl_interfaces/lib:/home/isr/ros2_foxy/install/pendulum_msgs/lib:/home/isr/ros2_foxy/install/lifecycle_msgs/lib:/home/isr/ros2_foxy/install/builtin_interfaces/lib:/home/isr/ros2_foxy/install/rosidl_typesupport_cpp/lib:/home/isr/ros2_foxy/install/rosidl_typesupport_introspection_cpp/lib:/home/isr/ros2_foxy/install/rosidl_typesupport_c/lib:/home/isr/ros2_foxy/install/rosidl_typesupport_introspection_c/lib:/home/isr/ros2_foxy/install/rosidl_typesupport_fastrtps_c/lib:/home/isr/ros2_foxy/install/rosidl_typesupport_fastrtps_cpp/lib:/home/isr/ros2_foxy/install/rmw/lib:/home/isr/ros2_foxy/install/rosidl_runtime_c/lib:/home/isr/ros2_foxy/install/resource_retriever/lib:/home/isr/ros2_foxy/install/class_loader/lib:/home/isr/ros2_foxy/install/rcpputils/lib:/home/isr/ros2_foxy/install/rcl_logging_noop/lib:/home/isr/ros2_foxy/install/rcl_logging_log4cxx/lib:/home/isr/ros2_foxy/install/rcutils/lib:/home/isr/ros2_foxy/install/rcl_yaml_param_parser/lib:/home/isr/ros2_foxy/install/performance_test_fixture/lib:/home/isr/ros2_foxy/install/osrf_testing_tools_cpp/lib:/home/isr/ros2_foxy/install/orocos_kdl/lib:/home/isr/ros2_foxy/install/mimick_vendor/lib:/home/isr/ros2_foxy/install/message_filters/lib:/home/isr/ros2_foxy/install/libyaml_vendor/lib:/home/isr/ros2_foxy/install/google_benchmark_vendor/lib:/home/isr/ros2_foxy/install/fastrtps/lib:/home/isr/ros2_foxy/install/fastcdr/lib:/home/isr/ros2_foxy/install/cyclonedds/lib:/home/isr/ros2_foxy/install/console_bridge_vendor/lib:/home/isr/ros2_foxy/install/ament_index_cpp/lib:/opt/ros/noetic/lib:/opt/ros/noetic/lib/x86_64-linux-gnu
2021-10-18 19:09:57.105526: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
  File "/home/isr/.local/lib/python3.8/site-packages/scenario/__init__.py", line 137, in check_gazebo_installation
    gazebo_version_parsed = packaging.version.Version(
  File "/usr/lib/python3/dist-packages/packaging/version.py", line 277, in __init__
    raise InvalidVersion("Invalid version: '{0}'".format(version))
packaging.version.InvalidVersion: Invalid version: '6.0.0
5.1.0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/isr/.local/lib/python3.8/site-packages/scenario/__init__.py", line 197, in <module>
    check_gazebo_installation()
  File "/home/isr/.local/lib/python3.8/site-packages/scenario/__init__.py", line 141, in check_gazebo_installation
    raise RuntimeError(f"Failed to parse the output of: {' '.join(command)}")
RuntimeError: Failed to parse the output of: ign gazebo --versions
>>> import scenario
>>> import gym_ignition
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/isr/.local/lib/python3.8/site-packages/gym_ignition/__init__.py", line 14, in <module>
    from gym_ignition.utils import resource_finder
  File "/home/isr/.local/lib/python3.8/site-packages/gym_ignition/utils/__init__.py", line 5, in <module>
    from . import logger, math, misc, resource_finder, scenario
  File "/home/isr/.local/lib/python3.8/site-packages/gym_ignition/utils/math.py", line 10, in <module>
    from scenario import gazebo as scenario
ImportError: cannot import name 'gazebo' from 'scenario' (/home/isr/.local/lib/python3.8/site-packages/scenario/__init__.py)
>>> 

I am unable to understand the reason

diegoferigo commented 2 years ago

What is the output of: ign gazebo --versions?

kashifzr commented 2 years ago

My apology for being late, Actually I was installing it and it took so much time

I did installed ign gazebo which in the include path it is show as ign-gazebo-7 but when I try to see this command it does not work

isr@isr-MS-7A64:/usr/local/lib/ign-gazebo-7$ ls
plugins
isr@isr-MS-7A64:/usr/local/lib/ign-gazebo-7$ 
diegoferigo commented 2 years ago

It's yet not clear to me how you configured your system (exact sequence of commands you used to install the packages). You can use the osrf's ubuntu ppa to install Ignition Fortress (6), that is the only supported version for the Stable channel of ScenarIO / gym-ignition.

kashifzr commented 2 years ago

@diegoferigo For the issue I did install ignition Fortress where the output of ign gazebo --version is given like this, Even the GUI for ign gazebo appear just like normal Gazebo.

isr@isr-MS-7A64:~$ ign gazebo --version
Ignition Gazebo, version 6.0.0
Copyright (C) 2018 Open Source Robotics Foundation.
Released under the Apache 2.0 License.

However the problem to import gym_ignition and scenario is still. I personally remove both packages and install them the problem is still there

python3
Python 3.8.10 (default, Sep 28 2021, 16:10:42) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gym_ignition
2021-10-19 17:24:33.575076: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /opt/ros/noetic/lib:/opt/ros/noetic/lib/x86_64-linux-gnu
2021-10-19 17:24:33.575114: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
  File "/home/isr/.local/lib/python3.8/site-packages/scenario/__init__.py", line 137, in check_gazebo_installation
    gazebo_version_parsed = packaging.version.Version(
  File "/usr/lib/python3/dist-packages/packaging/version.py", line 277, in __init__
    raise InvalidVersion("Invalid version: '{0}'".format(version))
packaging.version.InvalidVersion: Invalid version: '6.0.0
5.1.0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/isr/.local/lib/python3.8/site-packages/gym_ignition/__init__.py", line 14, in <module>
    from gym_ignition.utils import resource_finder
  File "/home/isr/.local/lib/python3.8/site-packages/gym_ignition/utils/__init__.py", line 5, in <module>
    from . import logger, math, misc, resource_finder, scenario
  File "/home/isr/.local/lib/python3.8/site-packages/gym_ignition/utils/math.py", line 10, in <module>
    from scenario import gazebo as scenario
  File "/home/isr/.local/lib/python3.8/site-packages/scenario/__init__.py", line 197, in <module>
    check_gazebo_installation()
  File "/home/isr/.local/lib/python3.8/site-packages/scenario/__init__.py", line 141, in check_gazebo_installation
    raise RuntimeError(f"Failed to parse the output of: {' '.join(command)}")
RuntimeError: Failed to parse the output of: ign gazebo --versions
>>> 

diegoferigo commented 2 years ago

What is the output of: ign gazebo --versions?

Can you provide this output?

kashifzr commented 2 years ago

isr@isr-MS-7A64:~$ ign gazebo --version Ignition Gazebo, version 6.0.0 Copyright (C) 2018 Open Source Robotics Foundation. Released under the Apache 2.0 License.

kashifzr commented 2 years ago

I am using https://ignitionrobotics.org/docs/fortress/install_ubuntu_src where all the commands being used are given, If i am trying to give details whats the output while executions, i need to run all them of once again.

sr@isr-MS-7A64:~$ pip --version
pip 21.3 from /home/isr/.local/lib/python3.8/site-packages/pip (python 3.8)
isr@isr-MS-7A64:~$ pip3 --version
pip 21.3 from /home/isr/.local/lib/python3.8/site-packages/pip (python 3.8)
isr@isr-MS-7A64:~$ 

To give an idea no matter I am using pip or pip3 same output

I will try to give rough idea what are the commands

sudo apt install python3-pip wget lsb-release gnupg curl

pip install -U colcon-common-extensions

pip show vcstool
Name: vcstool
Version: 0.2.15
Summary: vcstool provides a command line tool to invoke vcs commands on multiple repositories.
Home-page: https://github.com/dirk-thomas/vcstool
Author: Dirk Thomas
Author-email: web@dirk-thomas.net
License: Apache License, Version 2.0
Location: /usr/lib/python3/dist-packages
Requires: 
Required-by: 
pip show colcon-common-extensions
Name: colcon-common-extensions
Version: 0.2.1
Summary: Meta package aggregating colcon-core and common extensions.
Home-page: https://colcon.readthedocs.io
Author: Dirk Thomas
Author-email: web@dirk-thomas.net
License: Apache License, Version 2.0
Location: /usr/lib/python3/dist-packages
Requires: colcon-argcomplete, colcon-bash, colcon-cd, colcon-cmake, colcon-core, colcon-defaults, colcon-devtools, colcon-library-path, colcon-metadata, colcon-notification, colcon-output, colcon-package-information, colcon-package-selection, colcon-parallel-executor, colcon-powershell, colcon-python-setup-py, colcon-recursive-crawl, colcon-ros, colcon-test-result, colcon-zsh
Required-by: 

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - sudo apt-get update sudo apt-get install python3-vcstool python3-colcon-common-extensions

mkdir -p ~/workspace/src cd ~/workspace/src

wget https://raw.githubusercontent.com/ignition-tooling/gazebodistro/master/collection-fortress.yaml

vcs import < collection-fortress.yaml

sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null sudo apt-get update

sudo apt -y install \ $(sort -u $(find . -iname 'packages-'lsb_release -cs'.apt' -o -iname 'packages.apt' | grep -v '/.git/') | sed '/ignition|sdf/d' | tr '\n' ' ')

gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

colcon build --merge-install

Just because you help me alot so I try to reduce the problem Why I am getting this isssue, So I try to give every details

kashifzr commented 2 years ago

@diegoferigo thanks for your help and time, The problem is sourcing workspace while importing packages

isr@isr-MS-7A64:~$ python3
Python 3.8.10 (default, Sep 28 2021, 16:10:42) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gym
>>> import scenario
2021-10-19 18:07:19.529127: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/isr/workspace/install/lib:/opt/ros/noetic/lib:/opt/ros/noetic/lib/x86_64-linux-gnu
2021-10-19 18:07:19.529161: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
>>> import gym_ignition
>>> 
diegoferigo commented 2 years ago

isr@isr-MS-7A64:~$ ign gazebo --version Ignition Gazebo, version 6.0.0 Copyright (C) 2018 Open Source Robotics Foundation. Released under the Apache 2.0 License.

I need the output of --versions, not --version.

kashifzr commented 2 years ago
isr@isr-MS-7A64:~$ ign gazebo --versions
6.0.0
isr@isr-MS-7A64:~$ 

diegoferigo commented 2 years ago

From the error you posted in https://github.com/robotology/gym-ignition/issues/403#issuecomment-946480183, it seems that the ign gazebo --versions output cannot be parsed by Python. I was suspecting to a strange output, but it looks good to me. Can you provide the output of the following? It is an extract of the logic that is failing on your setup.


import packaging.specifiers
import packaging.version

def supported_versions_specifier_set() -> packaging.specifiers.SpecifierSet:

    # If 6 is the Ignition distribution major version, the following specifier enables
    # the compatibility with all the following versions:
    #
    # 6.Y.Z.devK
    # 6.Y.Z.alphaK
    # 6.Y.Z.betaK
    # 6.Y.Z.rcK
    # 6.Y.Z.preK
    # 6.Y.Z.postK
    #
    return packaging.specifiers.SpecifierSet("~=6.0.0.dev")

def check_gazebo_installation() -> None:

    import subprocess

    try:
        command = ["ign", "gazebo", "--versions"]
        result = subprocess.run(command, capture_output=True, text=True, check=True)
    except FileNotFoundError:
        msg = "Failed to find the 'ign' command in your PATH. "
        msg += "Make sure that Ignition is installed "
        msg += "and your environment is properly configured."
        raise RuntimeError(msg)
    except subprocess.CalledProcessError:
        raise RuntimeError(f"Failed to execute command: {' '.join(command)}")  # noqa

    gazebo_version_string = result.stdout.strip()

    # Get the gazebo version from the command line.
    # Since the releases could be in the "6.0.0~preK" form, we replace '~' with '.' to
    # be compatible with the 'packaging' package.
    gazebo_version_string_normalized = gazebo_version_string.replace("~", ".")

    try:
        # Parse the gazebo version
        gazebo_version_parsed = packaging.version.Version(
            gazebo_version_string_normalized
        )
    except:
        raise RuntimeError(f"Failed to parse the output of: {' '.join(command)}")

    if not gazebo_version_parsed in supported_versions_specifier_set():
        msg = f"Failed to find Ignition Gazebo {supported_versions_specifier_set()} "
        msg += f"(found incompatible {gazebo_version_parsed})"
        raise RuntimeError(msg)

check_gazebo_installation()
diegoferigo commented 2 years ago

Btw, from this log extracted from your previous comment it seems to me that you had two different Ignition distributions installed in your system:

Traceback (most recent call last):
  File "/home/isr/.local/lib/python3.8/site-packages/scenario/__init__.py", line 137, in check_gazebo_installation
    gazebo_version_parsed = packaging.version.Version(
  File "/usr/lib/python3/dist-packages/packaging/version.py", line 277, in __init__
    raise InvalidVersion("Invalid version: '{0}'".format(version))
packaging.version.InvalidVersion: Invalid version: '6.0.0
5.1.0'

Something that changed in https://github.com/robotology/gym-ignition/issues/403#issuecomment-946527593.

From your list of steps, I would really recommend to use virtual environments and not the ~/.local folder. Furthermore, you can also install Ignition from debs if you prefer, no need to compile from colcon unless you need it for other reasons.

kashifzr commented 2 years ago

@diegoferigo I did try to run the code given. the code run smoothly without any output

diegoferigo commented 2 years ago

This is the code the was failing in https://github.com/robotology/gym-ignition/issues/403#issuecomment-946480183, are you still experiencing import errors?