forked from igor-lirussi/baxter-python3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfaces.py
More file actions
29 lines (26 loc) · 1.22 KB
/
faces.py
File metadata and controls
29 lines (26 loc) · 1.22 KB
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
"""
Description: Module to change face of Baxter Robot, requires the interface, import it in your project to show some emotions!
Author: Igor Lirussi (https://igor-lirussi.github.io)
"""
#!/usr/bin/env python3
import cv2
def _set_face(robot, face="look_down", activated=True, path="./baxter-python3/faces/"):
"""
sets the robot face to a specific one
activated is a default true variable that can be passed with a global variable in your code if you want to deactivate the face change all together
"""
if activated:
path=path+str(face)+".jpg"
print(path)
img = cv2.imread(path)
if img is not None:
image = cv2.resize(img, (1024,600))
robot._set_display_data(image)
else:
print("Face file not found!")
def _set_look(robot, look_direction="down", activated=True, path="./baxter-python3/faces/"):
"""
sets the robot looking direction to a specific one (down, up, left, right, frontal, left_up,...)
activated is a default true variable that can be passed with a global variable in your code if you want to deactivate the face change all together
"""
_set_face(robot=robot,face="look_"+look_direction,activated=activated,path=path)