From 1775c0f2abbeea72a62eebac86694d92b2702860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darko=20Luki=C4=87?= Date: Fri, 3 Jan 2025 19:54:32 +0100 Subject: [PATCH] Fix resource_manager for simulation (#304) * Fix resource_manager for simulation * fix start points * update readme * update readme --------- Co-authored-by: Marija Golubovic --- README.md | 6 +- docker/Dockerfile.base | 7 +- mep3_bringup/launch/simulation_launch.py | 2 +- mep3_simulation/resource/big_description.urdf | 181 +++++++++--------- .../src/mep3_webots_hardware_interface.cpp | 2 +- .../webots_data/controllers/judge/judge.py | 11 +- 6 files changed, 112 insertions(+), 97 deletions(-) diff --git a/README.md b/README.md index 61360118d..b583d4cbc 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ git clone git@github.com:memristor/mep3.git src/mep3 # Install dependencies sudo apt install python3-vcstool -vcs import src < src/mep3/mep3.repos +# vcs import src < src/mep3/mep3.repos rosdep update rosdep install --from-paths src --ignore-src -r @@ -29,6 +29,7 @@ colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo source install/local_setup.bash ``` +⚠️ **Recommended:** Please check alternative installation methods [here](./docker). ## Bringup @@ -64,6 +65,9 @@ Important parameters are: ### Demo #### Teleoperation +>[!NOTE] +Run simulation without behavior tree + ```sh ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -r cmd_vel:=big/cmd_vel ``` diff --git a/docker/Dockerfile.base b/docker/Dockerfile.base index d0dad864d..46605adb0 100644 --- a/docker/Dockerfile.base +++ b/docker/Dockerfile.base @@ -83,11 +83,16 @@ RUN curl -L -o /opt/Groot2.AppImge \ RUN python3 -m pip install scipy transforms3d -#HOTFIX: https://github.com/ros-controls/ros2_controllers/issues/482 +# HOTFIX: https://github.com/ros-controls/ros2_controllers/issues/482 RUN wget -O /tmp/diff_drive_controller.deb http://snapshots.ros.org/humble/2022-11-23/ubuntu/pool/main/r/ros-humble-diff-drive-controller/ros-humble-diff-drive-controller_2.12.0-1jammy.20221108.202153_amd64.deb && \ apt install -y --allow-downgrades /tmp/diff_drive_controller.deb && \ rm -f /tmp/diff_drive_controller.deb +# HOTFIX: https://github.com/ros-controls/ros2_control/pull/1960 +RUN wget -O /tmp/hotfix.deb http://snapshots.ros.org/humble/2024-08-28/ubuntu/pool/main/r/ros-humble-hardware-interface/ros-humble-hardware-interface_2.43.0-1jammy.20240823.145349_amd64.deb && \ + apt install -y --allow-downgrades /tmp/hotfix.deb && \ + rm -f /tmp/hotfix.deb + # User config COPY ./config/bashrc /tmp/bashrc COPY ./config/fish/. /memristor/.config/fish/ diff --git a/mep3_bringup/launch/simulation_launch.py b/mep3_bringup/launch/simulation_launch.py index fe263b7a6..27b325e29 100644 --- a/mep3_bringup/launch/simulation_launch.py +++ b/mep3_bringup/launch/simulation_launch.py @@ -14,7 +14,7 @@ def generate_launch_description(): use_behavior_tree = LaunchConfiguration('bt', default=True) - big_strategy = LaunchConfiguration('big_strategy', default='test_mechanism') + big_strategy = LaunchConfiguration('big_strategy', default='blue_new_a') small_strategy = LaunchConfiguration('small_strategy', default='wait_everytime') color = LaunchConfiguration('color', default='blue') namespace = LaunchConfiguration('namespace', default='big') diff --git a/mep3_simulation/resource/big_description.urdf b/mep3_simulation/resource/big_description.urdf index 871934012..daa11d27b 100644 --- a/mep3_simulation/resource/big_description.urdf +++ b/mep3_simulation/resource/big_description.urdf @@ -43,109 +43,116 @@ - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/mep3_simulation/src/mep3_webots_hardware_interface.cpp b/mep3_simulation/src/mep3_webots_hardware_interface.cpp index a1cb57c9c..98fe9277d 100644 --- a/mep3_simulation/src/mep3_webots_hardware_interface.cpp +++ b/mep3_simulation/src/mep3_webots_hardware_interface.cpp @@ -94,7 +94,7 @@ namespace mep3_simulation for (FakeJoint &fake_joint : fake_joints_) { fake_joint.write_counter++; - fake_joint.position += sign(fake_joint.command_position - fake_joint.position) * 0.005; + fake_joint.position = fake_joint.command_position; fake_joint.velocity = fake_joint.command_velocity; fake_joint.effort = fake_joint.write_counter % 80; } diff --git a/mep3_simulation/webots_data/controllers/judge/judge.py b/mep3_simulation/webots_data/controllers/judge/judge.py index ba9dfd4f4..edb568ce0 100644 --- a/mep3_simulation/webots_data/controllers/judge/judge.py +++ b/mep3_simulation/webots_data/controllers/judge/judge.py @@ -7,7 +7,7 @@ INITIAL_POSE_MATRIX = [ # ('big', 'blue', [0.03, -1.15, pi/2]), # centralno polje - ('big', 'blue', [0.815, -1.33, -pi/2]), # polje kod panela + ('big', 'blue', [0.815, -1.33, pi/2]), # polje kod panela ('big', 'yellow', [0.80, 1.33, -pi/2]), # polje kod panela ('big', 'blue_a', [0.045, 1.31, -pi/2]), # centralno polje @@ -16,11 +16,10 @@ ('big', 'blue_b', [0.81, -1.34, -pi/2]), # unazad kod panela ('big', 'yellow_b', [0.045, -1.31, pi/2]), # unazad kod panela - # ('small', 'blue', [-0.72, -1.16, pi/2]), - - # ('small', 'green', [-0.72, 1.16, pi/2]), - # ('big', 'green', [-0.72, -1.16, pi/2]) + ('small', 'blue', [-0.72, -1.16, pi/2]), + ('small', 'yellow', [-0.72, 1.16, pi/2]), + ('big', 'yellow', [-0.72, -1.16, pi/2]) ] @@ -65,7 +64,7 @@ def main(): robot_small.set_position(x=pose_small[0], y=pose_small[1], theta=pose_small[2]) robot_opponent_big.set_position(x=pose_big[0], y=-pose_big[1], theta=pose_big[2]) - robot_opponent_small.set_position(x=-pose_small[0], y=pose_small[1], theta=pose_small[2]) + robot_opponent_small.set_position(x= pose_small[0], y=-pose_small[1], theta=pose_small[2]) supervisor.step(timestep)