From f028f62c26cd6952d8e58775f3ef07267da11f07 Mon Sep 17 00:00:00 2001 From: emilysteiner71 Date: Tue, 23 Apr 2024 15:30:09 +1200 Subject: [PATCH] Random can launch --- src/controllers/config/sim.yaml | 2 +- src/controllers/controllers/random.py | 3 ++- src/controllers/controllers/sim.py | 2 +- src/controllers/launch/sim.launch.py | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/controllers/config/sim.yaml b/src/controllers/config/sim.yaml index 5c11625e..547e86d2 100644 --- a/src/controllers/config/sim.yaml +++ b/src/controllers/config/sim.yaml @@ -1,6 +1,6 @@ sim: ros__parameters: - algorithm: 'ftg' + algorithm: 'random' observation_mode: 'lidar_only' environment: 'CarTrack' track: 'multi_track' diff --git a/src/controllers/controllers/random.py b/src/controllers/controllers/random.py index 718bbe41..6552c70d 100644 --- a/src/controllers/controllers/random.py +++ b/src/controllers/controllers/random.py @@ -20,10 +20,11 @@ def main(): CAR_NAME = params[0] controller = Controller('random_', CAR_NAME, 0.25) + policy_id = 'random' while True: action = np.asarray([random.uniform(0, 3), random.uniform(-3.14, 3.14)]) - controller.step(action) + controller.step(action, policy_id) if __name__ == '__main__': diff --git a/src/controllers/controllers/sim.py b/src/controllers/controllers/sim.py index 3796fc20..6d5cc270 100644 --- a/src/controllers/controllers/sim.py +++ b/src/controllers/controllers/sim.py @@ -5,7 +5,7 @@ import rclpy import torch -from cares_reinforcement_learning.util.network_factory import NetworkFactory +#from cares_reinforcement_learning.util.network_factory import NetworkFactory import cares_reinforcement_learning.util.configurations as cfg from reinforcement_learning.parse_args import parse_args diff --git a/src/controllers/launch/sim.launch.py b/src/controllers/launch/sim.launch.py index 51461c96..e0ca8d2f 100644 --- a/src/controllers/launch/sim.launch.py +++ b/src/controllers/launch/sim.launch.py @@ -18,6 +18,7 @@ alg_launch = { 'ftg': 'ftg', 'rl': 'rl', + 'random': 'random', } def generate_launch_description():