Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Smehnov authored Mar 18, 2024
1 parent cd1a826 commit e3d54ac
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,55 @@
import os
import time
from spot_controller import SpotController
import cv2

ROBOT_IP = "10.0.0.3"#os.environ['ROBOT_IP']
SPOT_USERNAME = "admin"#os.environ['SPOT_USERNAME']
SPOT_PASSWORD = "2zqa8dgw7lor"#os.environ['SPOT_PASSWORD']


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
import cv2
def capture_image():
camera_capture = cv2.VideoCapture(0)
rv, image = camera_capture.read()
print(f"Image Dimensions: {image.shape}")
camera_capture.release()
cv2.imwrite(os.path.join('/merklebot/job_data/result.jpg'), img)


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
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)


Expand Down

0 comments on commit e3d54ac

Please sign in to comment.