forked from miguelasd688/4-legged-robot-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serial_test.py
34 lines (25 loc) · 975 Bytes
/
serial_test.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 15 20:31:07 2021
@author: miguel-asd
"""
import numpy as np
import time
from src.serial_com import ArduinoSerial
arduino = ArduinoSerial('/dev/ttyACM0') #need to specify the serial port
startTime = time.time()
lastTime = startTime
interval = 0.002
Command = np.array([11.11 , 22.22 , 33.33 ,
11.11 , 22.22 , 33.33 ,
11.11 , 22.22 , 33.33 ,
11.11 , 22.22 , 33.33])
for k in range(100000000000):
if (time.time()-lastTime >= interval):
loopTime = time.time() - lastTime
lastTime = time.time()
t = time.time() - startTime
arduinoLoopTime , Xacc , Yacc , realRoll , realPitch = arduino.serialRecive()#recive serial message
arduino.serialSend(Command)#send serial command to arduino
print (loopTime , arduinoLoopTime , Xacc , Yacc , realRoll , realPitch)