diff --git a/src/controllers/config/rl_policy.yaml b/src/controllers/config/rl_policy.yaml index 4afee5a2..a473e3f2 100644 --- a/src/controllers/config/rl_policy.yaml +++ b/src/controllers/config/rl_policy.yaml @@ -1,6 +1,6 @@ rl_policy: ros__parameters: - actor_path: Models/sac_actor.pht - critic_path: Models/sac_critic.pht + actor_path: training_logs/SAC-CarTrack-23_11_20_15:33:07/models/SAC_actor.pht + critic_path: training_logs/SAC-CarTrack-23_11_20_15:33:07/models/SAC_critic.pht algorithm: 'SAC' observation_mode: 'lidar_only' diff --git a/src/controllers/controllers/rl_policy.py b/src/controllers/controllers/rl_policy.py index 31f410c9..37161e87 100644 --- a/src/controllers/controllers/rl_policy.py +++ b/src/controllers/controllers/rl_policy.py @@ -6,7 +6,7 @@ from cares_reinforcement_learning.util.helpers import denormalize from cares_reinforcement_learning.algorithm.policy import TD3 from cares_reinforcement_learning.networks.TD3 import Actor, Critic -from cares_reinforcement_learning.util.NetworkFactory import NetworkFactory +from cares_reinforcement_learning.util.network_factory import NetworkFactory from reinforcement_learning.parse_args import parse_args def main(): diff --git a/src/controllers/launch/ftg.launch.py b/src/controllers/launch/ftg.launch.py deleted file mode 100644 index f014885f..00000000 --- a/src/controllers/launch/ftg.launch.py +++ /dev/null @@ -1,24 +0,0 @@ -from launch import LaunchDescription -from launch_ros.actions import Node -from launch.actions import DeclareLaunchArgument -from launch.substitutions import LaunchConfiguration, PythonExpression - -def generate_launch_description(): - car_name = LaunchConfiguration('car_name') - - car_name_arg = DeclareLaunchArgument( - 'car_name', - default_value='ftg_car' - ) - - main = Node( - package='controllers', - executable='ftg_policy', - output='screen', - parameters=[{'car_name': car_name}], - ) - - return LaunchDescription([ - car_name_arg, - main - ]) \ No newline at end of file diff --git a/src/controllers/launch/sim.launch.py b/src/controllers/launch/sim.launch.py index d9a6e564..51461c96 100644 --- a/src/controllers/launch/sim.launch.py +++ b/src/controllers/launch/sim.launch.py @@ -45,16 +45,9 @@ def generate_launch_description(): }.items() #TODO: this doesn't do anything ) - algorithm = IncludeLaunchDescription( - launch_description_source = PythonLaunchDescriptionSource( - os.path.join(pkg_controllers, f'{alg_launch[alg]}.launch.py')), - launch_arguments={ - 'car_name': TextSubstitution(text=str(config['sim']['ros__parameters']['car_name']) if 'car_name' in config['sim']['ros__parameters'] else 'f1tenth'), - }.items() - ) # Launch the Environment - main = Node( + sim = Node( package='controllers', executable='sim', parameters=[ @@ -65,11 +58,37 @@ def generate_launch_description(): emulate_tty=True, # Allows python print to show ) + """alg_config_path = os.path.join( + get_package_share_directory('controllers'), + f'{alg}_policy.yaml' + )""" + + if (f'{alg}' != 'rl'): + alg = Node( + package='controllers', + executable=f'{alg}_policy', + output='screen', + parameters=[{'car_name': TextSubstitution(text=str(config['sim']['ros__parameters']['car_name']) if 'car_name' in config['sim']['ros__parameters'] else 'f1tenth')}], + ) + #algorithm = 0 + else: + alg = IncludeLaunchDescription( + launch_description_source = PythonLaunchDescriptionSource( + os.path.join(pkg_controllers, f'{alg_launch[alg]}.launch.py')), + launch_arguments={ + 'car_name': TextSubstitution(text=str(config['sim']['ros__parameters']['car_name']) if 'car_name' in config['sim']['ros__parameters'] else 'f1tenth'), + }.items() + ) + + + + return LaunchDescription([ #TODO: Find a way to remove this SetEnvironmentVariable(name='GZ_SIM_RESOURCE_PATH', value=pkg_f1tenth_description[:-19]), SetParameter(name='use_sim_time', value=True), environment, - algorithm, - main + alg, + sim, + #algorithm ]) \ No newline at end of file