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