forked from fossasia/pslab-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fossasia#509] Robotic arm config saving feature
- Loading branch information
1 parent
2af5d90
commit 028042a
Showing
10 changed files
with
121 additions
and
29 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
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
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 |
---|---|---|
@@ -1,22 +1,34 @@ | ||
import sys | ||
import time | ||
import json | ||
from playback_robot import PlaybackRobot | ||
|
||
playbackRobot = PlaybackRobot() | ||
|
||
|
||
def main(): | ||
print('script started') | ||
sys.stdout.flush() | ||
while(True): | ||
in_stream_data = input() | ||
parsed_stream_data = json.loads(in_stream_data) | ||
command = parsed_stream_data['command'] | ||
|
||
# # -------------------------- Script termination block ---------------------------- | ||
if command == 'SAVE_CONFIG_ROB_ARM': | ||
output = {'type': 'FETCH_ROB_ARM'} | ||
print(json.dumps(output)) | ||
sys.stdout.flush() | ||
|
||
if command == 'WRITE_ROB_ARM': | ||
servo1 = parsed_stream_data['servo1'] | ||
servo2 = parsed_stream_data['servo2'] | ||
servo3 = parsed_stream_data['servo3'] | ||
servo4 = parsed_stream_data['servo4'] | ||
data_path = parsed_stream_data['dataPath'] | ||
playbackRobot.write(data_path, servo1, servo2, servo3, servo4) | ||
|
||
if command == 'KILL': | ||
exit() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() | ||
print("app exited successfully") | ||
sys.stdout.flush() |
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,22 @@ | ||
import time | ||
import datetime | ||
import sys | ||
import json | ||
|
||
|
||
class PlaybackRobot: | ||
def write(self, data_path, servo1, servo2, servo3, servo4): | ||
file_name = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S:000") | ||
file_pointed = open(data_path + '/' + file_name + '.csv', "w+") | ||
file_pointed.write("%s, %s \n\n" % ( | ||
'RobotArm', str(datetime.datetime.now()))) | ||
file_pointed.write( | ||
"Time, Servo1, Servo2, Servo3, Servo4, Latitude, Longitude\n") | ||
for i in range(len(servo1)): | ||
file_pointed.write( | ||
"%s, %s, %s, %s, %s\n" % ( | ||
str(i + 1), str(servo1[i]), str(servo2[i]), str(servo3[i]), str(servo4[i]))) | ||
file_pointed.close() | ||
print(json.dumps({'type': 'DATA_WRITING_STATUS', | ||
'message': 'Config saved', })) | ||
sys.stdout.flush() |
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
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
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