recal
This commit is contained in:
@ -1,32 +1,35 @@
|
|||||||
import json
|
import json
|
||||||
import requests
|
|
||||||
import os
|
import os
|
||||||
|
import requests
|
||||||
|
|
||||||
# Get the parameters from the launch file
|
def main():
|
||||||
x1 = float(os.getenv('x1'))
|
# Read configuration from config.json
|
||||||
y1 = float(os.getenv('y1'))
|
with open('config.json', 'r') as config_file:
|
||||||
x2 = float(os.getenv('x2')) # Read x2 from launch file
|
config = json.load(config_file)
|
||||||
y2 = float(os.getenv('y2')) # Read y2 from launch file
|
url = config['url']
|
||||||
limit = int(os.getenv('limit'))
|
endpoint_path = config['endpoint_path']
|
||||||
|
|
||||||
# URL and endpoint path
|
# Get the parameters from the launch file
|
||||||
url = "https://bellanderoboticssensorsresearchinnovationcenter-kot42qxp.b4a.run"
|
x1 = float(os.getenv('x1'))
|
||||||
endpoint_path = "/api/Bellande_Step/bellande_step_2d"
|
y1 = float(os.getenv('y1'))
|
||||||
|
x2 = float(os.getenv('x2'))
|
||||||
|
y2 = float(os.getenv('y2'))
|
||||||
|
limit = int(os.getenv('limit'))
|
||||||
|
|
||||||
# JSON payload
|
# JSON payload
|
||||||
payload = {
|
payload = {
|
||||||
"node0": {"x": x1, "y": y1},
|
"node0": {"x": x1, "y": y1},
|
||||||
"node1": {"x": x2, "y": y2}
|
"node1": {"x": x2, "y": y2}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Headers
|
# Headers
|
||||||
headers = {
|
headers = {
|
||||||
'accept': 'application/json',
|
'accept': 'application/json',
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Make POST request
|
# Make POST request
|
||||||
try:
|
try:
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
url + endpoint_path + '?limit=' + str(limit),
|
url + endpoint_path + '?limit=' + str(limit),
|
||||||
json=payload,
|
json=payload,
|
||||||
@ -35,5 +38,8 @@ try:
|
|||||||
response.raise_for_status() # Raise an error for unsuccessful responses
|
response.raise_for_status() # Raise an error for unsuccessful responses
|
||||||
data = response.json()
|
data = response.json()
|
||||||
print("Next Step:", data['next_step'])
|
print("Next Step:", data['next_step'])
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
print("Error:", e)
|
print("Error:", e)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
Reference in New Issue
Block a user