forked from facebookresearch/pyrobot
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcamera_control.py
More file actions
35 lines (28 loc) · 1.06 KB
/
camera_control.py
File metadata and controls
35 lines (28 loc) · 1.06 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
30
31
32
33
34
35
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Example for controlling pan-tilt active camera system and get image data
"""
from __future__ import print_function
from pyrobot.utils.util import try_cv2_import
cv2 = try_cv2_import()
from pyrobot import Robot
if __name__ == "__main__":
bot = Robot("locobot")
bot.camera.reset()
camera_poses = [[0, 0.7], [0.4, 0.4], [0.4, -0.4], [-0.4, 0.4], [-0.4, -0.4]]
for pose in camera_poses:
print("Setting pan: {}, tilt: {}".format(pose[0], pose[1]))
bot.camera.set_pan_tilt(pose[0], pose[1], wait=True)
rgb = bot.camera.get_rgb()
depth = bot.camera.get_depth()
cv2.imshow("Color", rgb[:, :, ::-1])
cv2.imshow("Depth", 1000* depth)
cv2.waitKey(2000)
bot.camera.reset()
rgb = bot.camera.get_rgb()
depth = bot.camera.get_depth()
cv2.imshow("Color", rgb[:, :, ::-1])
cv2.imshow("Depth", 1000* depth)
cv2.waitKey(5000)