latest pushes
This commit is contained in:
parent
6e05e79256
commit
97bb453ebf
@ -18,5 +18,7 @@
|
|||||||
"url": "https://bellanderoboticssensorsresearchinnovationcenter-kot42qxp.b4a.run",
|
"url": "https://bellanderoboticssensorsresearchinnovationcenter-kot42qxp.b4a.run",
|
||||||
"endpoint_path": {
|
"endpoint_path": {
|
||||||
"bellande_control_system_base": "/api/Bellande_Adaptive_Continuious_Control_System/bellande_adaptive_continuious_control_system"
|
"bellande_control_system_base": "/api/Bellande_Adaptive_Continuious_Control_System/bellande_adaptive_continuious_control_system"
|
||||||
}
|
},
|
||||||
|
"connectivity_passcode": "user_input_passcode",
|
||||||
|
"Bellande_Framework_Access_Key": "bellande_web_api_opensource"
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,12 @@ def ros1_launch_description():
|
|||||||
def ros2_launch_description():
|
def ros2_launch_description():
|
||||||
initial_state_arg = DeclareLaunchArgument('initial_state', default_value='idle')
|
initial_state_arg = DeclareLaunchArgument('initial_state', default_value='idle')
|
||||||
name_arg = DeclareLaunchArgument('name', default_value='BellandeControlSystem')
|
name_arg = DeclareLaunchArgument('name', default_value='BellandeControlSystem')
|
||||||
action_parameters_arg = DeclareLaunchArgument('action_parameters', default_value='{}')
|
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 = []
|
nodes_to_launch = []
|
||||||
|
|
||||||
ros_launch_arguments = [
|
ros_launch_arguments = [
|
||||||
initial_state_arg, name_arg, action_parameters_arg,
|
initial_state_arg, name_arg, connectivity_passcode_arg, bellande_framework_access_key_arg,
|
||||||
]
|
]
|
||||||
|
|
||||||
nodes_to_launch.append(Node(
|
nodes_to_launch.append(Node(
|
||||||
@ -45,7 +45,8 @@ def ros2_launch_description():
|
|||||||
parameters=[
|
parameters=[
|
||||||
{'initial_state': LaunchConfiguration('initial_state')},
|
{'initial_state': LaunchConfiguration('initial_state')},
|
||||||
{'name': LaunchConfiguration('name')},
|
{'name': LaunchConfiguration('name')},
|
||||||
{'action_parameters': LaunchConfiguration('action_parameters')},
|
{'connectivity_passcode': LaunchConfiguration('connectivity_passcode')},
|
||||||
|
{'bellande_framework_access_key': LaunchConfiguration('bellande_framework_access_key')},
|
||||||
],
|
],
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!-- Copyright (C) 2024 Bellande Robotics Sensors Research Innovation Center, Ronaldson Bellande
|
<!-- Copyright (C) 2024 Bellande Robotics Sensors Research Innovation Center, Ronaldson Bellande
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
@ -19,12 +18,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
<!-- Arguments -->
|
<!-- Arguments -->
|
||||||
<arg name="initial_state" default="idle"/>
|
<arg name="initial_state" default="idle"/>
|
||||||
<arg name="name" default="BellandeControlSystem"/>
|
<arg name="name" default="BellandeControlSystem"/>
|
||||||
<arg name="action_parameters" default="{}"/>
|
<arg name="connectivity_passcode" default="default_passcode"/>
|
||||||
|
<arg name="bellande_framework_access_key" default="bellande_web_api_opensource"/>
|
||||||
|
|
||||||
<!-- Launch the BellandeControlSystem node -->
|
<!-- Launch the BellandeControlSystem node -->
|
||||||
<node name="bellande_control_system_node" pkg="bellande_control_system" type="bellande_control_system.py" output="screen">
|
<node name="bellande_control_system_node" pkg="bellande_control_system" type="bellande_control_system.py" output="screen">
|
||||||
<param name="initial_state" value="$(arg initial_state)"/>
|
<param name="initial_state" value="$(arg initial_state)"/>
|
||||||
<param name="name" value="$(arg name)"/>
|
<param name="name" value="$(arg name)"/>
|
||||||
<param name="action_parameters" value="$(arg action_parameters)"/>
|
<param name="connectivity_passcode" value="$(arg connectivity_passcode)"/>
|
||||||
|
<param name="bellande_framework_access_key" value="$(arg bellande_framework_access_key)"/>
|
||||||
</node>
|
</node>
|
||||||
</launch>
|
</launch>
|
||||||
|
@ -18,14 +18,16 @@ import os
|
|||||||
import requests
|
import requests
|
||||||
from std_msgs.msg import String
|
from std_msgs.msg import String
|
||||||
|
|
||||||
def bellande_control_system(state, action, parameters):
|
def bellande_control_system(state, action, parameters, connectivity_passcode):
|
||||||
payload = {
|
payload = {
|
||||||
"state": state,
|
"state": state,
|
||||||
"action": action,
|
"action": action,
|
||||||
"parameters": parameters
|
"parameters": parameters,
|
||||||
|
"connectivity_passcode": connectivity_passcode
|
||||||
}
|
}
|
||||||
headers = {
|
headers = {
|
||||||
"Authorization": f"Bearer {api_access_key}"
|
"Authorization": f"Bearer {Bellande_Framework_Access_Key}",
|
||||||
|
"X-Connectivity-Passcode": connectivity_passcode
|
||||||
}
|
}
|
||||||
response = requests.post(api_url, json=payload, headers=headers)
|
response = requests.post(api_url, json=payload, headers=headers)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
@ -36,20 +38,26 @@ def bellande_control_system(state, action, parameters):
|
|||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
def control_callback(msg):
|
def control_callback(msg):
|
||||||
current_state = rospy.get_param('current_state', 'idle')
|
data = json.loads(msg.data)
|
||||||
action = msg.data
|
connectivity_passcode = data['connectivity_passcode']
|
||||||
parameters = json.loads(rospy.get_param('action_parameters', '{}'))
|
current_state = rospy.get_param(f'current_state_{connectivity_passcode}', 'idle')
|
||||||
|
action = data['action']
|
||||||
|
parameters = data['parameters']
|
||||||
|
|
||||||
output, next_state = bellande_control_system(current_state, action, parameters)
|
output, next_state = bellande_control_system(current_state, action, parameters, connectivity_passcode)
|
||||||
if output is not None:
|
if output is not None:
|
||||||
output_msg = String()
|
output_msg = String()
|
||||||
output_msg.data = json.dumps({"output": output, "next_state": next_state})
|
output_msg.data = json.dumps({
|
||||||
|
"output": output,
|
||||||
|
"next_state": next_state,
|
||||||
|
"connectivity_passcode": connectivity_passcode
|
||||||
|
})
|
||||||
pub.publish(output_msg)
|
pub.publish(output_msg)
|
||||||
if next_state:
|
if next_state:
|
||||||
rospy.set_param('current_state', next_state)
|
rospy.set_param(f'current_state_{connectivity_passcode}', next_state)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global api_url, api_access_key, pub
|
global api_url, Bellande_Framework_Access_Key, pub
|
||||||
config_file_path = os.path.join(os.path.dirname(__file__), '../config/configs.json')
|
config_file_path = os.path.join(os.path.dirname(__file__), '../config/configs.json')
|
||||||
|
|
||||||
if not os.path.exists(config_file_path):
|
if not os.path.exists(config_file_path):
|
||||||
@ -60,7 +68,7 @@ def main():
|
|||||||
config = json.load(config_file)
|
config = json.load(config_file)
|
||||||
url = config['url']
|
url = config['url']
|
||||||
endpoint_path = config['endpoint_path']["bellande_control_system_base"]
|
endpoint_path = config['endpoint_path']["bellande_control_system_base"]
|
||||||
api_access_key = config["Bellande_Framework_Access_Key"]
|
Bellande_Framework_Access_Key = config["Bellande_Framework_Access_Key"]
|
||||||
|
|
||||||
# Initialize ROS node
|
# Initialize ROS node
|
||||||
if ros_version == "1":
|
if ros_version == "1":
|
||||||
|
Loading…
Reference in New Issue
Block a user