From 9a468a116c9167942a84063f3add0104b5f26b91 Mon Sep 17 00:00:00 2001 From: RonaldsonBellande Date: Mon, 29 Jul 2024 14:00:02 -0400 Subject: [PATCH] latest pushes --- .../launch/bellande_control_system.launch.py | 10 +++------ .../ros1/bellande_control_system.launch | 4 ---- .../src/bellande_control_system.py | 22 +++++++++---------- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/ros_web_api_bellande_adaptive_continuious_control_system/launch/bellande_control_system.launch.py b/ros_web_api_bellande_adaptive_continuious_control_system/launch/bellande_control_system.launch.py index 428ebc3..8bad798 100644 --- a/ros_web_api_bellande_adaptive_continuious_control_system/launch/bellande_control_system.launch.py +++ b/ros_web_api_bellande_adaptive_continuious_control_system/launch/bellande_control_system.launch.py @@ -23,30 +23,26 @@ from launch.substitutions import LaunchConfiguration def ros1_launch_description(): args = sys.argv[1:] - roslaunch_command = ["roslaunch", "bellande_control_system", "bellande_control_system.launch"] + args + roslaunch_command = ["roslaunch", "ros_web_api_bellande_adaptive_continuious_control_system", "bellande_control_system.launch"] + args subprocess.call(roslaunch_command) def ros2_launch_description(): initial_state_arg = DeclareLaunchArgument('initial_state', default_value='idle') name_arg = DeclareLaunchArgument('name', default_value='BellandeControlSystem') - connectivity_passcode_arg = DeclareLaunchArgument('connectivity_passcode', default_value='default_passcode') - bellande_framework_access_key_arg = DeclareLaunchArgument('bellande_framework_access_key', default_value='bellande_web_api_opensource') nodes_to_launch = [] ros_launch_arguments = [ - initial_state_arg, name_arg, connectivity_passcode_arg, bellande_framework_access_key_arg, + initial_state_arg, name_arg, ] nodes_to_launch.append(Node( - package='bellande_control_system', + package='ros_web_api_bellande_adaptive_continuious_control_system', executable='bellande_control_system.py', name='bellande_control_system_node', output='screen', parameters=[ {'initial_state': LaunchConfiguration('initial_state')}, {'name': LaunchConfiguration('name')}, - {'connectivity_passcode': LaunchConfiguration('connectivity_passcode')}, - {'bellande_framework_access_key': LaunchConfiguration('bellande_framework_access_key')}, ], )) diff --git a/ros_web_api_bellande_adaptive_continuious_control_system/launch/ros1/bellande_control_system.launch b/ros_web_api_bellande_adaptive_continuious_control_system/launch/ros1/bellande_control_system.launch index 8b21291..cf6b16d 100644 --- a/ros_web_api_bellande_adaptive_continuious_control_system/launch/ros1/bellande_control_system.launch +++ b/ros_web_api_bellande_adaptive_continuious_control_system/launch/ros1/bellande_control_system.launch @@ -18,14 +18,10 @@ along with this program. If not, see . - - - - diff --git a/ros_web_api_bellande_adaptive_continuious_control_system/src/bellande_control_system.py b/ros_web_api_bellande_adaptive_continuious_control_system/src/bellande_control_system.py index 9a1c3bf..c0b22a8 100755 --- a/ros_web_api_bellande_adaptive_continuious_control_system/src/bellande_control_system.py +++ b/ros_web_api_bellande_adaptive_continuious_control_system/src/bellande_control_system.py @@ -18,15 +18,14 @@ import os import requests from std_msgs.msg import String -def bellande_control_system(state, action, parameters, connectivity_passcode): +def bellande_control_system(state, action, parameters): payload = { "state": state, "action": action, - "parameters": parameters, - "connectivity_passcode": connectivity_passcode + "parameters": parameters } headers = { - "Authorization": f"Bearer {Bellande_Framework_Access_Key}", + "Authorization": f"Bearer {api_access_key}", "X-Connectivity-Passcode": connectivity_passcode } response = requests.post(api_url, json=payload, headers=headers) @@ -39,25 +38,23 @@ def bellande_control_system(state, action, parameters, connectivity_passcode): def control_callback(msg): data = json.loads(msg.data) - connectivity_passcode = data['connectivity_passcode'] - current_state = rospy.get_param(f'current_state_{connectivity_passcode}', 'idle') + current_state = rospy.get_param('current_state', 'idle') action = data['action'] parameters = data['parameters'] - output, next_state = bellande_control_system(current_state, action, parameters, connectivity_passcode) + output, next_state = bellande_control_system(current_state, action, parameters) if output is not None: output_msg = String() output_msg.data = json.dumps({ "output": output, - "next_state": next_state, - "connectivity_passcode": connectivity_passcode + "next_state": next_state }) pub.publish(output_msg) if next_state: - rospy.set_param(f'current_state_{connectivity_passcode}', next_state) + rospy.set_param('current_state', next_state) def main(): - global api_url, Bellande_Framework_Access_Key, pub + global api_url, api_access_key, connectivity_passcode, pub config_file_path = os.path.join(os.path.dirname(__file__), '../config/configs.json') if not os.path.exists(config_file_path): @@ -68,7 +65,8 @@ def main(): config = json.load(config_file) url = config['url'] endpoint_path = config['endpoint_path']["bellande_control_system_base"] - Bellande_Framework_Access_Key = config["Bellande_Framework_Access_Key"] + connectivity_passcode = config["connectivity_passcode"] + api_access_key = config["Bellande_Framework_Access_Key"] # Initialize ROS node if ros_version == "1":