forked from zivid/zivid-ros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample_capture.py
executable file
·51 lines (38 loc) · 1.52 KB
/
sample_capture.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
import rospy
import rosnode
import dynamic_reconfigure.client
from zivid_camera.srv import *
from std_msgs.msg import String
from sensor_msgs.msg import PointCloud2
class Sample:
def __init__(self):
rospy.init_node("sample_capture_py", anonymous=True)
rospy.loginfo("Starting sample_capture.py")
rospy.wait_for_service("/zivid_camera/capture", 30.0)
rospy.Subscriber("/zivid_camera/points/xyzrgba", PointCloud2, self.on_points)
self.capture_service = rospy.ServiceProxy("/zivid_camera/capture", Capture)
rospy.loginfo("Enabling the reflection filter")
settings_client = dynamic_reconfigure.client.Client("/zivid_camera/settings/")
settings_config = {"processing_filters_reflection_removal_enabled": True}
settings_client.update_configuration(settings_config)
rospy.loginfo("Enabling and configure the first acquisition")
acquisition_0_client = dynamic_reconfigure.client.Client(
"/zivid_camera/settings/acquisition_0"
)
acquisition_0_config = {
"enabled": True,
"aperture": 5.66,
"exposure_time": 20000,
}
acquisition_0_client.update_configuration(acquisition_0_config)
def capture(self):
rospy.loginfo("Calling capture service")
self.capture_service()
def on_points(self, data):
rospy.loginfo("PointCloud received")
self.capture()
if __name__ == "__main__":
s = Sample()
s.capture()
rospy.spin()