From 1fae87f0fc09a8d6dd2baf985448668c1da41509 Mon Sep 17 00:00:00 2001 From: AnaxGotJuice <64612032+ImenKedir@users.noreply.github.com> Date: Sat, 23 Mar 2024 09:47:24 -0700 Subject: [PATCH 01/12] commit --- main.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/main.py b/main.py index 3e8ba5d..16e875b 100644 --- a/main.py +++ b/main.py @@ -18,13 +18,13 @@ def capture_image(): def main(): #example of using micro and speakers - print("Start recording audio") - sample_name = "aaaa.wav" - cmd = f'arecord -vv --format=cd --device={os.environ["AUDIO_INPUT_DEVICE"]} -r 48000 --duration=10 -c 1 {sample_name}' - print(cmd) - os.system(cmd) - print("Playing sound") - os.system(f"ffplay -nodisp -autoexit -loglevel quiet {sample_name}") + # print("Start recording audio") + # sample_name = "aaaa.wav" + # cmd = f'arecord -vv --format=cd --device={os.environ["AUDIO_INPUT_DEVICE"]} -r 48000 --duration=10 -c 1 {sample_name}' + # print(cmd) + # os.system(cmd) + # print("Playing sound") + # os.system(f"ffplay -nodisp -autoexit -loglevel quiet {sample_name}") # # Capture image @@ -33,24 +33,24 @@ def main(): with SpotController(username=SPOT_USERNAME, password=SPOT_PASSWORD, robot_ip=ROBOT_IP) as spot: time.sleep(2) - capture_image() + # capture_image() # Move head to specified positions with intermediate time.sleep spot.move_head_in_points(yaws=[0.2, 0], pitches=[0.3, 0], rolls=[0.4, 0], sleep_after_point_reached=1) - capture_image() + # capture_image() time.sleep(3) # Make Spot to move by goal_x meters forward and goal_y meters left spot.move_to_goal(goal_x=0.5, goal_y=0) time.sleep(3) - capture_image() + # capture_image() # Control Spot by velocity in m/s (or in rad/s for rotation) - spot.move_by_velocity_control(v_x=-0.3, v_y=0, v_rot=0, cmd_duration=2) - capture_image() - time.sleep(3) + # spot.move_by_velocity_control(v_x=-0.3, v_y=0, v_rot=0, cmd_duration=2) + # capture_image() + # time.sleep(3) if __name__ == '__main__': From 8e4f1986cf834e6e87604fedbb10ee42d880d2a1 Mon Sep 17 00:00:00 2001 From: AnaxGotJuice <64612032+ImenKedir@users.noreply.github.com> Date: Sat, 23 Mar 2024 10:38:37 -0700 Subject: [PATCH 02/12] commit --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 16e875b..cf88344 100644 --- a/main.py +++ b/main.py @@ -45,7 +45,7 @@ def main(): # Make Spot to move by goal_x meters forward and goal_y meters left spot.move_to_goal(goal_x=0.5, goal_y=0) time.sleep(3) - # capture_image() + capture_image() # Control Spot by velocity in m/s (or in rad/s for rotation) # spot.move_by_velocity_control(v_x=-0.3, v_y=0, v_rot=0, cmd_duration=2) From 29fe6dab919c674283504b7b935e72304b2bec3a Mon Sep 17 00:00:00 2001 From: AnaxGotJuice <64612032+ImenKedir@users.noreply.github.com> Date: Sat, 23 Mar 2024 11:03:36 -0700 Subject: [PATCH 03/12] commit --- main.py | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/main.py b/main.py index cf88344..27c07d4 100644 --- a/main.py +++ b/main.py @@ -17,41 +17,10 @@ def capture_image(): def main(): - #example of using micro and speakers - # print("Start recording audio") - # sample_name = "aaaa.wav" - # cmd = f'arecord -vv --format=cd --device={os.environ["AUDIO_INPUT_DEVICE"]} -r 48000 --duration=10 -c 1 {sample_name}' - # print(cmd) - # os.system(cmd) - # print("Playing sound") - # os.system(f"ffplay -nodisp -autoexit -loglevel quiet {sample_name}") - - # # Capture image - - # Use wrapper in context manager to lease control, turn on E-Stop, power on the robot and stand up at start - # and to return lease + sit down at the end + msg = input("YO SAY SOMETHING") + print(msg) with SpotController(username=SPOT_USERNAME, password=SPOT_PASSWORD, robot_ip=ROBOT_IP) as spot: - - time.sleep(2) - # capture_image() - # Move head to specified positions with intermediate time.sleep - spot.move_head_in_points(yaws=[0.2, 0], - pitches=[0.3, 0], - rolls=[0.4, 0], - sleep_after_point_reached=1) - # capture_image() - time.sleep(3) - - # Make Spot to move by goal_x meters forward and goal_y meters left - spot.move_to_goal(goal_x=0.5, goal_y=0) - time.sleep(3) capture_image() - # Control Spot by velocity in m/s (or in rad/s for rotation) - # spot.move_by_velocity_control(v_x=-0.3, v_y=0, v_rot=0, cmd_duration=2) - # capture_image() - # time.sleep(3) - - if __name__ == '__main__': main() From 26567df0aefa7f4f8c233ce7aefbdf5a62f0d209 Mon Sep 17 00:00:00 2001 From: AnaxGotJuice <64612032+ImenKedir@users.noreply.github.com> Date: Sat, 23 Mar 2024 11:08:21 -0700 Subject: [PATCH 04/12] commit --- main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 27c07d4..6d44603 100644 --- a/main.py +++ b/main.py @@ -17,10 +17,14 @@ def capture_image(): def main(): - msg = input("YO SAY SOMETHING") - print(msg) with SpotController(username=SPOT_USERNAME, password=SPOT_PASSWORD, robot_ip=ROBOT_IP) as spot: + + msg = input("YO SAY SOMETHING") + + print(msg) + capture_image() + if __name__ == '__main__': main() From ab98789230c5cacd9ad956cd1c58c1daefbecb7a Mon Sep 17 00:00:00 2001 From: AnaxGotJuice <64612032+ImenKedir@users.noreply.github.com> Date: Sat, 23 Mar 2024 11:09:46 -0700 Subject: [PATCH 05/12] commit --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4f804a2..f8b7b5f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: Build image on: push: - branches: [ main ] + branches: [ master ] tags: - "*" workflow_dispatch: From 5142e0964aeb0f0d8842bfb14da5c19a7c156d4f Mon Sep 17 00:00:00 2001 From: AnaxGotJuice <64612032+ImenKedir@users.noreply.github.com> Date: Sat, 23 Mar 2024 11:18:11 -0700 Subject: [PATCH 06/12] commit --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 6d44603..b296020 100644 --- a/main.py +++ b/main.py @@ -19,7 +19,7 @@ def capture_image(): def main(): with SpotController(username=SPOT_USERNAME, password=SPOT_PASSWORD, robot_ip=ROBOT_IP) as spot: - msg = input("YO SAY SOMETHING") + msg = input("Input: ") print(msg) From 95946a7b7ccd9c3af6659a4d5502aaa5ccb82b1a Mon Sep 17 00:00:00 2001 From: AnaxGotJuice <64612032+ImenKedir@users.noreply.github.com> Date: Sat, 23 Mar 2024 11:58:17 -0700 Subject: [PATCH 07/12] commit --- .vscode/settings.json | 11 +++++++++ __pycache__/backend.cpython-310.pyc | Bin 0 -> 345 bytes __pycache__/main.cpython-310.pyc | Bin 0 -> 962 bytes __pycache__/spot_controller.cpython-310.pyc | Bin 0 -> 7604 bytes backend.py | 7 ++++++ main.py | 5 ++-- req.py | 24 ++++++++++++++++++++ 7 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 __pycache__/backend.cpython-310.pyc create mode 100644 __pycache__/main.cpython-310.pyc create mode 100644 __pycache__/spot_controller.cpython-310.pyc create mode 100644 backend.py create mode 100644 req.py diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e6e7934 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "files.exclude": { + "**/.git": true, + "**/.svn": true, + "**/.hg": true, + "**/CVS": true, + "**/.DS_Store": true, + "**/Thumbs.db": true + }, + "hide-files.files": [] +} \ No newline at end of file diff --git a/__pycache__/backend.cpython-310.pyc b/__pycache__/backend.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3a984393e9614aa475c789489175a8afdb475c6e GIT binary patch literal 345 zcmYjLyH3O~5cJx42{^t1QIP^%&>{p4g64#DLP+U+x638EB#!KW1QqD`5GeT${vs_E zzijsgUs7G$ zy<6*Q{17f?=bBc>`o@#8sW}L@GddF!^SGf>vP^Rk!HK+dXef{l!mjp|8(pbE&=@eM`jA=(CGLyUT E3s?Y2O#lD@ literal 0 HcmV?d00001 diff --git a/__pycache__/main.cpython-310.pyc b/__pycache__/main.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a3708e5391178a3e8e61f7e277bbfbd2ea9a172e GIT binary patch literal 962 zcmY+CPfrvv6u{fg3{#d}LFHf~F~r*(WB?BuVvGnJFmWNQKx|AV!?sz5oqu+^Y~1Xg z@M`=3goHi%Q9OB{t0%t#7kqD63ATB!e_s3g-mfofG-?FeuZ3&%lM(V87k3-%kvAa4 z0Vqi%jfuD!si3fCF-t6A(VIP6*wPY?w8fNkge#|{`;`bTxtxY^TGeE&%e1Ga&j{S0 ztxCL^Kj51*JzCyt<(b*YQlqmtR(il!mY1+U7fvXXC>8b9!RPR$?DSv6nQr5?f6ao4 z1F`{9yaQ#(C6#ncM`TDY*_eD{BRXQnl5EIM>~nI#&L~BjGlpQ`^pv!Wd+CnJIg$2- zHDqIkX|;&wG&Kc}g9qD5*inm{QKHf!%F<$Oaq!qrlXV{Ba|BkfCd>g((%^N+)JH#Emt`m6xFeiBCM zQvRiEOq>OkpBdzao@%sC=P0KORM%noA7rcs4sr*wp$4JSZ`Swu5izy|tRrfiAw|4q z3V-?#Fxt@1syb10>+iQF%iZ->>u_gpv*dd_Z^691TRIWm(^wu=P976BqA0DT z=v4S_6f!7n$ZwcV@2xwsAf^k wp+cg!jxf(4xbr^Z*HsYwRg%eGtX^Z?6^}r1!r@~$wV6$A$}P@$tw!zZzc>Tu761SM literal 0 HcmV?d00001 diff --git a/__pycache__/spot_controller.cpython-310.pyc b/__pycache__/spot_controller.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9372d15ac105f9051180ffc697f6f748d915c2e3 GIT binary patch literal 7604 zcmZ`;&2J;emG3V$o8J^gNt9-6)AqzRlXxbX{XnouY|HxESFTCtNK?RW#(SL0VlN4>00#>Ma1KF$oOZAKU-W5%92Rrg+aA^kGWor#CPh(76J1?Z z{i?d^)$je@t71?nWEEV$(_gy(^_rsmfeQ1Nj=~4H!~aCW6sCHLEuX5bp{#kjZ`g*P zvQ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)Ic|?^2F}ZK1X6mLRr%AOZ3op-8X|twR-V QN&YBz6V3@6G_9il8P%zmlmGw# literal 0 HcmV?d00001 diff --git a/backend.py b/backend.py new file mode 100644 index 0000000..8e3dfea --- /dev/null +++ b/backend.py @@ -0,0 +1,7 @@ +from fastapi import FastAPI + +app = FastAPI() + +@app.get("/") +async def root(): + return {"message": "Hello World"} \ No newline at end of file diff --git a/main.py b/main.py index b296020..279653e 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,7 @@ import time from spot_controller import SpotController import cv2 +from req import fetch ROBOT_IP = "10.0.0.3"#os.environ['ROBOT_IP'] SPOT_USERNAME = "admin"#os.environ['SPOT_USERNAME'] @@ -19,9 +20,7 @@ def capture_image(): def main(): with SpotController(username=SPOT_USERNAME, password=SPOT_PASSWORD, robot_ip=ROBOT_IP) as spot: - msg = input("Input: ") - - print(msg) + fetch() capture_image() diff --git a/req.py b/req.py new file mode 100644 index 0000000..7046e66 --- /dev/null +++ b/req.py @@ -0,0 +1,24 @@ +import http.client + +def fetch(url='http://192.168.2.189:8000', method='GET'): + # Define the URL and headers + headers = {} + + # Create an HTTP connection + conn = http.client.HTTPConnection(url.split("/")[2]) + + # Send a GET request + conn.request("GET", "/", headers=headers) + + # Get the response + response = conn.getresponse() + + # Print the response status and data + print("Status:", response.status, response.reason) + data = response.read() + print("Data:", data.decode()) + + # Close the connection + conn.close() + +print(fetch()) \ No newline at end of file From a53c8685189f8564edff106e8def0088b6f1c346 Mon Sep 17 00:00:00 2001 From: AnaxGotJuice <64612032+ImenKedir@users.noreply.github.com> Date: Sat, 23 Mar 2024 12:30:41 -0700 Subject: [PATCH 08/12] commit --- main.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 279653e..94f14ac 100644 --- a/main.py +++ b/main.py @@ -19,9 +19,17 @@ def capture_image(): def main(): with SpotController(username=SPOT_USERNAME, password=SPOT_PASSWORD, robot_ip=ROBOT_IP) as spot: - fetch() - + capture_image() + spot.move_head_in_points(yaws=[0.2, 0], + pitches=[0.3, 0], + rolls=[0.4, 0], + sleep_after_point_reached=1) + capture_image() + spot.move_head_in_points(yaws=[0, 0.4], + pitches=[0, 0.5], + rolls=[0, 0.7], + sleep_after_point_reached=1) capture_image() From 3d23fc2d38ff50f6f229a8fbffad1e8db56cf36e Mon Sep 17 00:00:00 2001 From: AnaxGotJuice <64612032+ImenKedir@users.noreply.github.com> Date: Sat, 23 Mar 2024 12:36:10 -0700 Subject: [PATCH 09/12] commit --- main.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index 94f14ac..5448313 100644 --- a/main.py +++ b/main.py @@ -19,18 +19,10 @@ def capture_image(): def main(): with SpotController(username=SPOT_USERNAME, password=SPOT_PASSWORD, robot_ip=ROBOT_IP) as spot: - fetch() - capture_image() - spot.move_head_in_points(yaws=[0.2, 0], - pitches=[0.3, 0], - rolls=[0.4, 0], - sleep_after_point_reached=1) - capture_image() - spot.move_head_in_points(yaws=[0, 0.4], - pitches=[0, 0.5], - rolls=[0, 0.7], - sleep_after_point_reached=1) capture_image() + for i in range(2): + spot.move_by_velocity_control(0, 0, 0.1) + capture_image() if __name__ == '__main__': From 5b0904ed92c71a6670e45803ef03909bc1220e1b Mon Sep 17 00:00:00 2001 From: AnaxGotJuice <64612032+ImenKedir@users.noreply.github.com> Date: Sat, 23 Mar 2024 12:39:55 -0700 Subject: [PATCH 10/12] commit --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 5448313..89f3194 100644 --- a/main.py +++ b/main.py @@ -21,7 +21,7 @@ def main(): with SpotController(username=SPOT_USERNAME, password=SPOT_PASSWORD, robot_ip=ROBOT_IP) as spot: capture_image() for i in range(2): - spot.move_by_velocity_control(0, 0, 0.1) + spot.move_by_velocity_control(1, 1, 10) capture_image() From 1232066c7680cc09615bf10cc98720897a9be2f7 Mon Sep 17 00:00:00 2001 From: AnaxGotJuice <64612032+ImenKedir@users.noreply.github.com> Date: Sat, 23 Mar 2024 12:46:32 -0700 Subject: [PATCH 11/12] commit --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 89f3194..c42eafd 100644 --- a/main.py +++ b/main.py @@ -21,7 +21,7 @@ def main(): with SpotController(username=SPOT_USERNAME, password=SPOT_PASSWORD, robot_ip=ROBOT_IP) as spot: capture_image() for i in range(2): - spot.move_by_velocity_control(1, 1, 10) + spot.move_by_velocity_control(1, 1, 10, 10) capture_image() From f00b561ea2b85fb56781181956ace4149492c49a Mon Sep 17 00:00:00 2001 From: Josiah Griggs Date: Sat, 23 Mar 2024 12:55:31 -0700 Subject: [PATCH 12/12] Added to server code --- backend.py | 12 +++++++++--- main.py | 6 +++++- req.py | 7 +++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/backend.py b/backend.py index 8e3dfea..3d445b7 100644 --- a/backend.py +++ b/backend.py @@ -2,6 +2,12 @@ app = FastAPI() -@app.get("/") -async def root(): - return {"message": "Hello World"} \ No newline at end of file +@app.post("/") +async def handle_command(cmd: str): + cmd = input() + if cmd == "0": + return {cmd} + elif cmd == "1": + return {cmd} + else: + return {"Invalid input. Please enter a valid cmd."} \ No newline at end of file diff --git a/main.py b/main.py index 94f14ac..4c35f9b 100644 --- a/main.py +++ b/main.py @@ -19,7 +19,9 @@ def capture_image(): def main(): with SpotController(username=SPOT_USERNAME, password=SPOT_PASSWORD, robot_ip=ROBOT_IP) as spot: - fetch() + response = fetch("/", method='POST') + print(response) + capture_image() spot.move_head_in_points(yaws=[0.2, 0], pitches=[0.3, 0], @@ -32,6 +34,8 @@ def main(): sleep_after_point_reached=1) capture_image() + + if __name__ == '__main__': main() diff --git a/req.py b/req.py index 7046e66..daf5af2 100644 --- a/req.py +++ b/req.py @@ -1,6 +1,9 @@ import http.client -def fetch(url='http://192.168.2.189:8000', method='GET'): +def fetch(path = "/", method='GET'): + # Url + url='http://192.168.2.189:8000' + # Define the URL and headers headers = {} @@ -8,7 +11,7 @@ def fetch(url='http://192.168.2.189:8000', method='GET'): conn = http.client.HTTPConnection(url.split("/")[2]) # Send a GET request - conn.request("GET", "/", headers=headers) + conn.request("GET", path, headers=headers) # Get the response response = conn.getresponse()