-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry.py
67 lines (58 loc) · 2.08 KB
/
entry.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import asyncio
import logging
import random
import argparse
from viam.robot.client import RobotClient
from viam.rpc.dial import Credentials, DialOptions
from viam.components.camera import Camera, RawImage
import PIL.Image as PILImage
from PIL.Image import Image
from viam.components.gantry import Gantry
from draw_wrapper import BezierDrawer, DrawWrapper
from robodraw import InternalRobot
import io
import os
import sys
import time
def getValue(minVal: float, maxVal: float) -> float:
return float(minVal + (maxVal - minVal) * random.random())
# async def main():
# logger = logging.getLogger("axidraw")
# image_path = "./puppy.jpg"
# output_contours = "./output-lines.svg"
# drawer = DrawWrapper(
# input_path=image_path, output_path=output_contours, logger=logger
# )
# robot_client = InternalRobot(
# drawer=drawer,
# logger=logger,
# api_key="3xa5lhmnugpf7xvhbjo54dfyakqjcg655wn03ze4yjfl3jga",
# )
# await robot_client.move_to_home()
# await robot_client.draw()
async def main():
svg_image_path = "./rectangle.svg"
logger = logging.getLogger("bezier_curve")
drawer = BezierDrawer(filepath=svg_image_path, logger=logger)
paths = drawer.convert_svg_to_paths()
points = drawer.convert_paths_to_coordinates(paths=paths)
print(points)
# start = await axidraw.get_position()
# minX, maxX, minY, maxY, z = -8, 8, -5.5, 5.5, 0
# # make sure its at the origin
# await axidraw.move_to_position([0, 0, 0], [])
# while True:
# nextX = getValue(minX, maxX)
# nextY = getValue(minY, maxY)
# print(f"move to {nextX} - {nextY}")
# _ = await axidraw.move_to_position([nextX, nextY, z], [])
# # Don't forget to close the robot when you're done!
# await robot.close()
# if __name__ == "__main__":
# parser = argparse.ArgumentParser(description="Parse the file to sketch on the robot")
# parser.add_argument("--path", dest="path")
# parser.add_argument("--output", dest="output")
# args = parser.parse_args()
# asyncio.run(draw(args.path, args.output))
if __name__ == "__main__":
asyncio.run(main())