even further documentation
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"A script for calibrating the color and saving parameters."
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
"""Script explaining how HSV works."""
|
||||
|
||||
from __future__ import division, print_function
|
||||
|
||||
import sys
|
||||
@@ -6,13 +8,15 @@ import cv2
|
||||
import numpy as np
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
image = np.zeros((200, 200, 3), dtype=np.uint8)
|
||||
window = 'HSV Explained'
|
||||
h, s, v = 0, 255, 255
|
||||
|
||||
print('u, i, o: increase h, s, v respectively\n',
|
||||
'j, k, l: decrease h, s, v respectively\n',
|
||||
'(focus on the image window for this)\n', sep='')
|
||||
print('u, i, o: increase h, s, v respectively',
|
||||
'j, k, l: decrease h, s, v respectively',
|
||||
'(focus on the image window for this and look at the terminal)',
|
||||
sep='\n')
|
||||
|
||||
while True:
|
||||
image[:] = h, s, v
|
||||
|
||||
@@ -155,8 +155,7 @@ class VideoReader(object):
|
||||
raise ValueError('Error while reading video.\n' +
|
||||
'Or video is over.')
|
||||
self.ctr += 1
|
||||
if (self.ctr == self.cap.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT) and
|
||||
self.loop):
|
||||
if (self.ctr == self.cap.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT) and self.loop):
|
||||
self.ctr = 0
|
||||
self.cap.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, 0)
|
||||
return frame
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
"""Class with functions for easier movement of NAO.
|
||||
|
||||
And a command line script for some movements.
|
||||
"""
|
||||
|
||||
# from time import sleep
|
||||
import argparse
|
||||
from math import radians, pi
|
||||
@@ -8,7 +13,7 @@ from .utils import read_config
|
||||
|
||||
class NaoMover(object):
|
||||
|
||||
KICK_SEQUENCE = [
|
||||
KICK_SEQUENCE = [ # DON'T USE THIS ONE
|
||||
|
||||
# lean to the side using the ankle joints
|
||||
[[(0, 1, 'ShoulderRoll', -70),
|
||||
@@ -25,7 +30,7 @@ class NaoMover(object):
|
||||
]
|
||||
|
||||
# fancy kick
|
||||
KICK_SEQUENCE_FANCY = [
|
||||
KICK_SEQUENCE_FANCY = [ # USE THIS ONE
|
||||
# base_or_kicking, unsymmetric, joint, angle
|
||||
|
||||
# lift the arm
|
||||
@@ -53,7 +58,6 @@ class NaoMover(object):
|
||||
0.5],
|
||||
]
|
||||
|
||||
|
||||
def __init__(self, nao_ip, nao_port=9559):
|
||||
nao_ip = bytes(nao_ip)
|
||||
self.mp = ALProxy('ALMotion', nao_ip, nao_port)
|
||||
@@ -70,6 +74,12 @@ class NaoMover(object):
|
||||
self.ready_to_move = False
|
||||
|
||||
def kick(self, foot='L', fancy=False):
|
||||
"""Kick the ball with the foot.
|
||||
|
||||
For now optimized for Left foot. Also please always
|
||||
set fancy to True when calling this.
|
||||
|
||||
"""
|
||||
self.set_arm_stiffness(0.8)
|
||||
self.set_hip_stiffness(0.8)
|
||||
self.set_knee_stiffness(0.8)
|
||||
@@ -106,6 +116,7 @@ class NaoMover(object):
|
||||
self.set_arm_stiffness()
|
||||
|
||||
def rest(self):
|
||||
"""Send robot to resting position."""
|
||||
self.mp.rest()
|
||||
self.ready_to_move = False
|
||||
|
||||
@@ -150,10 +161,19 @@ class NaoMover(object):
|
||||
return self.mp.getAngles(('HeadYaw', 'HeadPitch'), False)
|
||||
|
||||
def change_head_angles(self, d_yaw, d_pitch, speed=0.5):
|
||||
"""Change the head angles by a relative amount.
|
||||
|
||||
This function DOES return before movement is finished.
|
||||
"""
|
||||
self.mp.changeAngles(('HeadYaw', 'HeadPitch'),
|
||||
(d_yaw, d_pitch), speed)
|
||||
|
||||
def change_head_angles_blocking(self, d_yaw, d_pitch, speed=0.5):
|
||||
"""Same as `change_head_angles` but block until finished.
|
||||
|
||||
Doesn't work quite as expected though. You may need to work on it.
|
||||
|
||||
"""
|
||||
self.mp.angleInterpolatioWithSpeed(('HeadYaw', 'HeadPitch'),
|
||||
(d_yaw, d_pitch), speed, False)
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
"""Some convenience functions which I leave up to you to explore."""
|
||||
|
||||
from __future__ import division
|
||||
|
||||
import os
|
||||
@@ -41,6 +43,7 @@ def hsv_mask(hsv, hsv_lower, hsv_upper):
|
||||
else:
|
||||
return cv2.inRange(hsv, tuple(hsv_lower), tuple(hsv_upper))
|
||||
|
||||
|
||||
class InterruptDelayed(object):
|
||||
|
||||
def __enter__(self):
|
||||
|
||||
Reference in New Issue
Block a user