diff --git a/src/rktl_control/launch/ball.launch.py b/src/rktl_control/launch/ball.launch.py index 22237402..f7f03052 100644 --- a/src/rktl_control/launch/ball.launch.py +++ b/src/rktl_control/launch/ball.launch.py @@ -1,10 +1,7 @@ -import os -import sys - import launch import launch_ros.actions -from ament_index_python.packages import get_package_share_directory - +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare def generate_launch_description(): ld = launch.LaunchDescription([ @@ -16,7 +13,7 @@ def generate_launch_description(): output='screen', parameters=[ { - launch.substitutions.PathJoinSubstitution(launch_ros.substitutions.FindPackageShare('rktl_control'), '/config/mean_odom_filter.yaml') + PathJoinSubstitution([FindPackageShare('rktl_control'), '/config/mean_odom_filter.yaml']) } ] ) diff --git a/src/rktl_control/launch/car.launch.py b/src/rktl_control/launch/car.launch.py index 11ec08fd..c14293a4 100644 --- a/src/rktl_control/launch/car.launch.py +++ b/src/rktl_control/launch/car.launch.py @@ -1,9 +1,9 @@ -import os -import sys - import launch import launch_ros.actions +from launch.substitutions import * +from launch.conditions import IfCondition +from launch_ros.substitutions import FindPackageShare def generate_launch_description(): ld = launch.LaunchDescription([ @@ -17,20 +17,22 @@ def generate_launch_description(): ), launch.actions.GroupAction( actions=[ - launch_ros.actions.PushRosNamespace("cars/" + launch.substitutions.LaunchConfiguration("car_name")), + #launch_ros.actions.PushRosNamespace("cars/" + launch.substitutions.LaunchConfiguration("car_name")), launch_ros.actions.Node( package='rktl_control', executable='particle_odom_filter', name='particle_odom_filter', output='screen', - condition=launch.conditions.LaunchConfigurationEquals('use_particle_filter', True), + condition=IfCondition( + EqualsSubstitution(LaunchConfiguration('use_particle_filter'), 'true') + ), parameters=[ { - launch.substitutions.PathJoinSubstitution(launch_ros.substitutions.FindPackageShare('rktl_control'), '/config/particle_odom_filter.yaml') + PathJoinSubstitution([FindPackageShare('rktl_control'), '/config/particle_odom_filter.yaml']) }, { - 'frame_ids/body': launch.substitutions.LaunchConfiguration('car_name') + 'frame_ids/body': LaunchConfiguration('car_name') } ] ), @@ -40,13 +42,15 @@ def generate_launch_description(): executable='mean_odom_filter', name='mean_odom_filter', output='screen', - condition=launch.conditions.LaunchConfigurationNotEquals('use_particle_filter', True), + condition=IfCondition( + EqualsSubstitution(LaunchConfiguration('use_particle_filter'), 'true') + ), parameters=[ { - launch.substitutions.PathJoinSubstitution(launch_ros.substitutions.FindPackageShare('rktl_control'), '/config/mean_odom_filter.yaml') + PathJoinSubstitution([FindPackageShare('rktl_control'), '/config/mean_odom_filter.yaml']) }, { - 'frame_ids/body': launch.substitutions.LaunchConfiguration('car_name') + 'frame_ids/body': LaunchConfiguration('car_name') } ] ), @@ -58,8 +62,8 @@ def generate_launch_description(): output='screen', parameters=[ { - launch.substitutions.PathJoinSubstitution(launch_ros.substitutions.FindPackageShare('rktl_control'), '/config/controller.yaml') - }, + PathJoinSubstitution([FindPackageShare('rktl_control'), '/config/controller.yaml']) + } ] ) ] diff --git a/src/rktl_control/rktl_control/__init__.py b/src/rktl_control/rktl_control/__init__.py new file mode 100644 index 00000000..b2673365 --- /dev/null +++ b/src/rktl_control/rktl_control/__init__.py @@ -0,0 +1,31 @@ +""" +This package manipulates a ROS network so that it provides an enviornment to +train an AI. In short, it uses the sim time mechanism used to replay bag files +to mess with how time progresses, so that an arbitrary ROS network can be used +as an environment, specifically, an OpenAI Gym environment. + +This can be used for both training and evaluation purposes. When training, it +manipulates time so that the network gets what it needs. It evaluation, it +runs the network as fast as real time is progressing. + +License: + BSD 3-Clause License + Copyright (c) 2023, Autonomous Robotics Club of Purdue (Purdue ARC) + All rights reserved. +""" + +from ._ros_interface import ROSInterface +# from .cartpole_interface import CartpoleInterface +# from .cartpole_direct_interface import CartpoleDirectInterface +# from .snake_interface import SnakeInterface +from .rocket_league_interface import RocketLeagueInterface +# from .env_counter import EnvCounter + +__all__ = [ + "ROSInterface", + # "CartpoleInterface", + # "CartpoleDirectInterface", + # "SnakeInterface", + "RocketLeagueInterface" + # "EnvCounter" +] \ No newline at end of file diff --git a/src/rktl_control/rktl_control/mean_odom_filter.py b/src/rktl_control/rktl_control/mean_odom_filter.py index 39f20d7c..498dcf35 100644 --- a/src/rktl_control/rktl_control/mean_odom_filter.py +++ b/src/rktl_control/rktl_control/mean_odom_filter.py @@ -149,6 +149,8 @@ def sample_velocity(self): return (avg_vx, avg_vy, avg_omega) +def main(): + MeanOdomFilter() if __name__ == "__main__": - MeanOdomFilter() + main() diff --git a/src/rktl_control/rktl_control/particle_odom_filter.py b/src/rktl_control/rktl_control/particle_odom_filter.py index 2b7282f8..2c4201c4 100644 --- a/src/rktl_control/rktl_control/particle_odom_filter.py +++ b/src/rktl_control/rktl_control/particle_odom_filter.py @@ -467,6 +467,8 @@ def particle_init(self, num_particles): random_internal), axis=1) +def main(): + ParticleOdomFilter() if __name__ == "__main__": - ParticleOdomFilter() + main() diff --git a/src/rktl_control/setup.py b/src/rktl_control/setup.py index ece9e9a2..4b950dd9 100644 --- a/src/rktl_control/setup.py +++ b/src/rktl_control/setup.py @@ -23,7 +23,9 @@ tests_require=['pytest'], entry_points={ 'console_scripts': [ - "controller_node = rktl_control2.controller:main" + "controller = rktl_control.controller:main", + "mean_odom_filter = rktl_control.mean_odom_filter:main", + "particle_odom_filter = rktl_control.particle_odom_filter:main" ], }, )