Giter Club home page Giter Club logo

Comments (7)

DavidMansolino avatar DavidMansolino commented on May 29, 2024

Hi @LuisYordano, thank you for this precise bug report. I can indeed reproduce this.
In general, when using ROS2 you should not revert or reload the simulation as this will stop the ROS2 node communicating with Webots.
But there is indeed a bug, when the simulation is reverted the ROS2 node does not end correctly (which is why you did get the Goal Accepted), I am attempting to fix this in #39 (without success for now).

from webots_ros2.

LuisYordano avatar LuisYordano commented on May 29, 2024

Hi @DavidMansolino,

I don't know if this helps, but in Gazebo there is the commands:

- rosservice call /gazebo/reset_simulation "{}"

- rosservice call /gazebo/reset_world "{}"
 
- rosservice call /gazebo/pause_physics "{}"
 
- rosservice call /gazebo/unpause_physics "{}"

Webots is different from Gazebo, but the concepts of Reset Simulation, World, Pause, UnPause, would be implemented with the same philosophy in Webots as services in ROS2.

from webots_ros2.

DavidMansolino avatar DavidMansolino commented on May 29, 2024

Thank you for the information.
We have indeed not yet implemented these functionalities, but we will shortly so that you can easily reset the world.
Just one small question, when you reset the world, the nodes remain connected to Gazebo, right?

from webots_ros2.

LuisYordano avatar LuisYordano commented on May 29, 2024

Affirmative!!!
Nodes only terminate communication with ROS Master (ROS1) and ROS2 when the user press CTRL+C.

from webots_ros2.

DavidMansolino avatar DavidMansolino commented on May 29, 2024

Ok, thank you for the confirmation, I have added a new issue specific to these missing services: #40 (do not hesitate to comment if you think some other important services are missing).

from webots_ros2.

lukicdarkoo avatar lukicdarkoo commented on May 29, 2024

What about respawning the driver?

def generate_launch_description():
    webots_driver = Node(
        package='webots_ros2_driver',
        executable='driver',
        parameters=[
            {'robot_description': robot_description }
        ],

        # Every time one resets the simulation the controller is automatically respawned
        respawn=True
    )

    webots = WebotsLauncher(world=PathJoinSubstitution([package_dir, 'worlds', world]))

    return LaunchDescription([webots, webots_driver])

If you have some other nodes that have to be restarted (e.g. ros2_control) then you can use the OnProcessExit event handler:

def get_ros2_control_spawners(*args):
    return [
        Node(
            package='controller_manager',
            executable='spawner.py',
            arguments=['diffdrive_controller']
        )
    ]

def generate_launch_description():
    webots_driver = Node(
        package='webots_ros2_driver',
        executable='driver',
        parameters=[
            {'robot_description': robot_description }
        ],

        # Every time one resets the simulation the controller is automatically respawned
        respawn=True
    )

    webots = WebotsLauncher(world=PathJoinSubstitution([package_dir, 'worlds', world]))

    return LaunchDescription([
        webots,
        webots_driver,
        launch.actions.RegisterEventHandler(
            event_handler=launch.event_handlers.OnProcessExit(
                target_action=tiago_driver,
                on_exit=get_ros2_control_spawners,
            )
        )
    ] + get_ros2_control_spawners())

from webots_ros2.

lukicdarkoo avatar lukicdarkoo commented on May 29, 2024

I will close the issue. Feel free to re-open it if the answer doesn't solve your problem

from webots_ros2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.