Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
write_an_interface_to_your_perception_system [2013/01/07 08:43] – [Publisher] tenorth | write_an_interface_to_your_perception_system [2014/06/05 11:38] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Write an interface to your perception system ====== | + | #REDIRECT doc:writing_an_interface_to_your_perception_system |
- | + | ||
- | There are two main approaches how perception can be performed: Some perception algorithms continuously detect objects and output the results (in ROS terminology: | + | |
- | + | ||
- | In this tutorial, we explain on two minimal examples how to write interfaces to these two kinds of perception systems. Currently, there is no ' | + | |
- | + | ||
- | Before starting with the tutorial, it is important to first understand how [[object_pose_representation|object detections]] are represented in KnowRob. Further information on this topic can be found in Sections 3.2 and 6.1 in http:// | + | |
- | + | ||
- | ====== Setting up the perception tutorial ====== | + | |
- | + | ||
- | The knowrob_perception tutorial is part of the knowrob_tutorials repository. You need to check it out into your ROS workspace (i.e. into a directory that is part of your ROS_PACKAGE_PATH). | + | |
- | https:// | + | |
- | < | + | |
- | git clone https:// | + | |
- | </ | + | |
- | + | ||
- | After the checkout, you should be able to '' | + | |
- | + | ||
- | < | + | |
- | roscd knowrob_perception | + | |
- | rosmake | + | |
- | </ | + | |
- | ====== Interfacing topic-based perception systems ====== | + | |
- | + | ||
- | ===== Publisher ===== | + | |
- | + | ||
- | The file src/ | + | |
- | < | + | |
- | rosrun knowrob_perception_tutorial dummy_publisher | + | |
- | </ | + | |
- | + | ||
- | Once the publisher is running, you can have a look at the generated object poses by calling the following command from a different terminal. | + | |
- | < | + | |
- | rostopic echo / | + | |
- | </ | + | |
- | It should output messages of the following form: | + | |
- | < | + | |
- | type: DinnerFork | + | |
- | pose: | + | |
- | header: | + | |
- | seq: 0 | + | |
- | stamp: | + | |
- | secs: 1357547989 | + | |
- | nsecs: 196672575 | + | |
- | frame_id: map | + | |
- | pose: | + | |
- | position: | + | |
- | x: 0.300724629488 | + | |
- | y: 2.96134330258 | + | |
- | z: 1.56672560148 | + | |
- | orientation: | + | |
- | x: 0.0 | + | |
- | y: 0.0 | + | |
- | z: 0.0 | + | |
- | w: 1.0 | + | |
- | </ | + | |
- | ===== Subscriber ===== | + | |
- | + | ||
- | src/ | + | |
- | + | ||
- | ===== KnowRob integration ===== | + | |
- | + | ||
- | prolog/ | + | |
- | + | ||
- | < | + | |
- | obj_detections_listener(Listener) :- | + | |
- | jpl_new(' | + | |
- | jpl_call(Listener, | + | |
- | </ | + | |
- | + | ||
- | + | ||
- | ====== Interfacing service-based perception systems ====== | + | |
- | + | ||
- | ===== Perception service ===== | + | |
- | + | ||
- | src/ | + | |
- | + | ||
- | + | ||
- | ===== Service client ===== | + | |
- | + | ||
- | src/ | + | |
- | + | ||
- | + | ||
- | + | ||
- | ===== KnowRob integration ===== | + | |
- | + | ||
- | implemented in prolog/ | + | |
- | + | ||
- | integrated as computable prolog class | + | |
- | + | ||
- | in contrast to topic-based example, which performed most processing on the Java side, we are doing more of the processing on the Prolog side | + | |
- | + | ||
- | < | + | |
- | comp_object_detection(_ObjClass, | + | |
- | + | ||
- | % Call the DetectObject service for retrieving a new object detection. | + | |
- | % The method returns a reference to the Java ObjectDetection message object | + | |
- | jpl_call(' | + | |
- | + | ||
- | + | ||
- | % Read information from the ObjectDetection object | + | |
- | + | ||
- | % Read type -> simple string; combine with KnowRob namespace | + | |
- | jpl_get(ObjectDetection, | + | |
- | atom_concat(' | + | |
- | + | ||
- | + | ||
- | % Read pose -> convert from quaternion to pose list | + | |
- | jpl_get(ObjectDetection, | + | |
- | jpl_get(PoseStamped, | + | |
- | + | ||
- | jpl_call(' | + | |
- | knowrob_coordinates: | + | |
- | + | ||
- | + | ||
- | % Create the object representations in the knowledge base | + | |
- | % The third argument is the type of object perception describing | + | |
- | % the method how the object has been detected | + | |
- | create_object_perception(Type, | + | |
- | </ | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | ====== Adapting the examples to your system ====== | + | |
- | + | ||
- | + | ||
- | + | ||
- | ====== Other kinds of perception systems ====== | + | |
- | + | ||
- | In this tutorial, we have concentrated on object recognition as a special case of a perception task. There are of course other perception tasks like the identification and pose estimation of humans, recognition and interpretation of spoken commands, etc. Most of these systems can however be interfaced in a very similar way: If they produce information continuously and asynchronously, | + | |
- | + |