-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from small-thinking/all-joint-move
Add all-joints move command
- Loading branch information
Showing
7 changed files
with
120 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import json | ||
import os | ||
|
||
import requests | ||
|
||
|
||
def send_commands_to_service(json_file_path, service_url): | ||
# Load the JSON commands from the specified file | ||
with open(json_file_path, "r") as file: | ||
commands = json.load(file) | ||
print(f"Commands: {commands}") | ||
# commands = f""" | ||
# {{ | ||
# "operations": [] | ||
# }} | ||
# """ | ||
# Send the JSON commands to the HTTP service | ||
response = requests.post(service_url, json=commands) | ||
|
||
# Check the response status | ||
if response.status_code == 200: | ||
print("Commands sent successfully.") | ||
print("Response:", response) | ||
else: | ||
print("Failed to send commands.") | ||
print("Status Code:", response.status_code) | ||
print("Response:", response.text) | ||
|
||
|
||
if __name__ == "__main__": | ||
json_file_path = os.path.join( | ||
os.path.dirname(os.path.dirname(__file__)), "knowledge/dummy_command.json" | ||
) | ||
service_url = "http://0.0.0.0:5678/robot_command" | ||
|
||
send_commands_to_service(json_file_path, service_url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"operations": [ | ||
{ | ||
"operation": "move_all_servos", | ||
"parameters": {"angles": [0, 45, 60, 60, 0, 0, 0], "time": 500} | ||
}, | ||
{ | ||
"operation": "move_single_servo", | ||
"parameters": {"id": "servo0", "angle": -60, "time": 500} | ||
}, | ||
{ | ||
"operation": "move_single_servo", | ||
"parameters": {"id": "servo0", "angle": 60, "time": 500} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters