Skip to content

Commit

Permalink
Fix resource_manager for simulation (#304)
Browse files Browse the repository at this point in the history
* Fix resource_manager for simulation

* fix start points

* update readme

* update readme

---------

Co-authored-by: Marija Golubovic <[email protected]>
  • Loading branch information
lukicdarkoo and MarijaGolubovic authored Jan 3, 2025
1 parent 46ff4f8 commit 1775c0f
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 97 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ git clone [email protected]: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

Expand All @@ -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
Expand Down Expand Up @@ -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
```
Expand Down
7 changes: 6 additions & 1 deletion docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
2 changes: 1 addition & 1 deletion mep3_bringup/launch/simulation_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
181 changes: 94 additions & 87 deletions mep3_simulation/resource/big_description.urdf
Original file line number Diff line number Diff line change
Expand Up @@ -43,109 +43,116 @@
<command_interface name="output" />
</gpio>
<joint name="m1">
<command_interface name="position"/>
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
<joint name="m2">
<command_interface name="position"/>
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
<joint name="m3">
<command_interface name="position"/>
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
<joint name="m4">
<command_interface name="position"/>
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
<joint name="m5">
<command_interface name="position"/>
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
<joint name="m6">
<command_interface name="position"/>
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
<joint name="m7">
<command_interface name="position"/>
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
<joint name="m8">
<command_interface name="position"/>
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
<joint name="m9">
<command_interface name="position"/>
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
<joint name="m10">
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
<joint name="m10">
<command_interface name="position"/>
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
</joint>
<joint name="m10">
<command_interface name="position"/>
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
</joint>
<joint name="m11">
<command_interface name="position"/>
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
</joint>
<joint name="m12">
<command_interface name="position"/>
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
</joint>
<joint name="m13">
<command_interface name="position"/>
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
</joint>
<joint name="m14">
<command_interface name="position"/>
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
</joint>
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
<joint name="m11">
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
<joint name="m12">
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
<joint name="m13">
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
<joint name="m14">
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
<joint name="m15">
<command_interface name="position" />
<command_interface name="velocity" />
<state_interface name="position" />
<state_interface name="velocity" />
<state_interface name="effort" />
</joint>
</ros2_control>
</robot>
</robot>
2 changes: 1 addition & 1 deletion mep3_simulation/src/mep3_webots_hardware_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 5 additions & 6 deletions mep3_simulation/webots_data/controllers/judge/judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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])
]


Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 1775c0f

Please sign in to comment.