latest pushes
This commit is contained in:
parent
97bb453ebf
commit
9a468a116c
@ -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')},
|
||||
],
|
||||
))
|
||||
|
||||
|
@ -18,14 +18,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
<!-- Arguments -->
|
||||
<arg name="initial_state" default="idle"/>
|
||||
<arg name="name" default="BellandeControlSystem"/>
|
||||
<arg name="connectivity_passcode" default="default_passcode"/>
|
||||
<arg name="bellande_framework_access_key" default="bellande_web_api_opensource"/>
|
||||
|
||||
<!-- Launch the BellandeControlSystem node -->
|
||||
<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="name" value="$(arg name)"/>
|
||||
<param name="connectivity_passcode" value="$(arg connectivity_passcode)"/>
|
||||
<param name="bellande_framework_access_key" value="$(arg bellande_framework_access_key)"/>
|
||||
</node>
|
||||
</launch>
|
||||
|
@ -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":
|
||||
|
Loading…
Reference in New Issue
Block a user