Skip to content

Commit

Permalink
Merge pull request #290 from una-auxme/277-feature-run-agent-containe…
Browse files Browse the repository at this point in the history
…r-without-spawning-a-vehicle

277 feature run agent container without spawning a vehicle
  • Loading branch information
ll7 committed Sep 10, 2024
2 parents 4efecd3 + ab8720e commit 40ac660
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 18 deletions.
4 changes: 2 additions & 2 deletions build/agent_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ services:
- CARLA_SIM_HOST=carla-simulator
- ROS_HOSTNAME=agent
- XDG_RUNTIME_DIR=/tmp/runtime-carla
# - ROUTE=/opt/leaderboard/data/routes_devtest.xml
- ROUTE=/opt/leaderboard/data/routes_devtest.xml
# Simple route without special scenarios
- ROUTE=/workspace/code/routes/routes_simple.xml
# - ROUTE=/workspace/code/routes/routes_simple.xml
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
# if you change the volume here also change the copy command
Expand Down
4 changes: 3 additions & 1 deletion build/docker-compose_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ services:
extends:
file: agent_service.yaml
service: agent
command: bash -c "sleep 10 && roslaunch agent/launch/dev.launch"
environment:
- ROUTE=/workspace/code/routes/routes_simple.xml
command: bash -c "sleep 10 && sudo chown -R carla:carla ../code/ && sudo chmod -R a+w ../code/ && python3 /opt/leaderboard/leaderboard/leaderboard_evaluator.py --debug=0 --routes=$${ROUTE} --agent=/workspace/code/agent/src/agent/agent.py --host=$${CARLA_SIM_HOST} --track=MAP"
26 changes: 26 additions & 0 deletions build/docker-compose_dev_offline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
services:
agent-dev:
build:
dockerfile: build/docker/agent-dev/Dockerfile
context: ../
args:
- USER_UID=${DOCKER_HOST_UNIX_UID:-1000}
- USER_GID=${DOCKER_HOST_UNIX_GID:-1000}
init: true
tty: true
shm_size: 2gb
deploy:
resources:
reservations:
devices:
- driver: nvidia
capabilities: [ gpu ]
volumes:
- ../:/workspace
environment:
- DISPLAY=${DISPLAY}
network_mode: host
privileged: true
entrypoint: ["/dev_entrypoint.sh"]
command: bash

27 changes: 27 additions & 0 deletions build/docker/agent-dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# syntax = edrevo/dockerfile-plus

INCLUDE+ ./build/docker/agent/Dockerfile

# Add development tools
RUN sudo apt-get update && sudo apt-get install -y \
vim \
nano \
tmux \
git \
curl \
htop

# Create a development entry point script
# RUN echo '#!/bin/bash\n\
# source /opt/ros/noetic/setup.bash\n\
# source /catkin_ws/devel/setup.bash\n\
# exec "$@"' > /dev_entrypoint.sh && \
# chmod +x /dev_entrypoint.sh

ADD ./build/docker/agent-dev/dev_entrypoint.sh /dev_entrypoint.sh

# Set the development entry point
ENTRYPOINT ["/dev_entrypoint.sh"]

# Default to bash if no command is provided
CMD ["bash"]
19 changes: 19 additions & 0 deletions build/docker/agent-dev/dev_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Source ROS setup
source /opt/ros/noetic/setup.bash

# Source the catkin workspace setup
source /catkin_ws/devel/setup.bash

# Set up any additional environment variables if needed
export CARLA_ROOT=/opt/carla
export SCENARIO_RUNNER_ROOT=/opt/scenario_runner
export LEADERBOARD_ROOT=/opt/leaderboard

# Execute the command passed to the script, or start a bash session if no command was given
if [ $# -eq 0 ]; then
exec bash
else
exec "$@"
fi
2 changes: 1 addition & 1 deletion code/acting/src/acting/stanley_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def loop(timer_event=None):
:return:
"""
if self.__path is None:
self.logwarn("StanleyController hasn't received a path yet"
self.logwarn("StanleyController hasn't received a path yet "
"and can therefore not publish steering")
return
if self.__position is None:
Expand Down
2 changes: 1 addition & 1 deletion code/agent/config/dev_objects.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"yaw": 0.0
},
"range": 50,
"rotation_frequency": 10,
"rotation_frequency": 20,
"channels": 64,
"upper_fov": 10,
"lower_fov": -30,
Expand Down
2 changes: 1 addition & 1 deletion code/agent/launch/dev.launch
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<!-- Synchronous mode-->
<arg name='synchronous_mode_wait_for_vehicle_control_command' default='False'/>
<arg name='fixed_delta_seconds' default='0.1'/>
<arg name='fixed_delta_seconds' default='0.05'/>


<include file="$(find carla_ros_bridge)/launch/carla_ros_bridge.launch">
Expand Down
2 changes: 1 addition & 1 deletion code/test-route/launch/test-route.launch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<launch>
<arg name="role_name" default="hero" />
<arg name="control_loop_rate" default="0.02" />
<arg name="control_loop_rate" default="0.05" />

<node pkg="test-route" type="test_route.py" name="test_route" output="screen">
<param name="control_loop_rate" value="$(arg control_loop_rate)" />
Expand Down
28 changes: 17 additions & 11 deletions code/test-route/src/test_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,29 @@ def wait_for_hero(self):
self.hero = self.hero[0]
break

def set_spectator(self):
def set_spectator(self, set_rotation=False):
transform = self.hero.get_transform()
location = carla.Location(x=transform.location.x,
y=transform.location.y,
z=transform.location.z + 2)
self.spectator.set_transform(
carla.Transform(
location, carla.Rotation(
pitch=transform.rotation.pitch - 15,
yaw=transform.rotation.yaw,
roll=transform.rotation.roll
location = carla.Location(
x=transform.location.x,
y=transform.location.y,
z=transform.location.z + 2)

if set_rotation:
self.spectator.set_transform(
carla.Transform(
location, carla.Rotation(
pitch=transform.rotation.pitch - 15,
yaw=transform.rotation.yaw,
roll=transform.rotation.roll
)
)
)
)
else:
self.spectator.set_location(location)

def run(self):
self.loginfo('Test-Route node running')
self.set_spectator(set_rotation=True)

def loop(timer_event=None):
self.set_spectator()
Expand Down
12 changes: 12 additions & 0 deletions dc-run-file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# enable xhost
./xhost_enable.sh

# run docker compose
if [ $# -eq 0 ]; then
echo "Usage: $0 <path-to-docker-compose-file>"
exit 1
fi

docker compose -f "$1" up

0 comments on commit 40ac660

Please sign in to comment.