This is an old revision of the document!


Marker-based visualization canvas

Based on rviz Markers, this visualization module can display the current or past belief states in the web-based visualization. The browser-based 3D canvas has been built using the ros3djs library.

Visualizing object meshes

Inside the ROS ecosystem, resources like binary files can be described using different kinds of URLs like file://, http:// or package://, which specifies the path relative to a ROS package. These URLs can be resolved using the resource_retriever tool. Since the webserver does not access to the whole file system, this mechanism does not work any more if requests are made from a website. The ros3djs library therefore rewrites package:// URLs to point to the docroot of the website. For example, meshes in the package pr2_description are now searched for at http://localhost/pr2_description.

In order to visualize meshes contained in ROS packages, these meshes therefore have to be put into the docroot of the webserver, which is usually /var/www/<pkg_name>.

register_ros_package(knowrob_cad_models).

Some of the objects in the demo set have CAD models attached. They are used for visualization as well as for reasoning (see below). These models are automatically used when they are specified for either a complete class of objects (using an OWL hasValue restriction) or for an object instance as shown below:

 <owl:NamedIndividual rdf:about="&map_obj;milk1">
     <rdf:type rdf:resource="&knowrob;CowsMilk-Product"/>
     <knowrob:widthOfObject rdf:datatype="&xsd;double">0.1</knowrob:widthOfObject>
     <knowrob:depthOfObject rdf:datatype="&xsd;double">0.1</knowrob:depthOfObject>
     <knowrob:heightOfObject rdf:datatype="&xsd;double">0.25</knowrob:heightOfObject>
     <knowrob:pathToCadModel rdf:datatype="&xsd;string">
                             package://knowrob_tutorial/cad/milk.kmz</knowrob:pathToCadModel>
 </owl:NamedIndividual>

The package://... identifier references files inside ROS packages.

Example queries

The following queries read data from the semantic map and from the logged data and visualize it in the browser-based visualization. The robot pose at time 1377780296 is read from the MongoDB using the tfMemory extension.

$ roslaunch knowrob_vis knowrob_vis.launch
$ rosrun rosprolog  rosprolog knowrob_vis

% load packages, start marker publisher
?- register_ros_package(knowrob_mongo), 
   register_ros_package(mod_srdl), 
   register_ros_package(mod_execution_trace), 
   visualisation_canvas.

% load CRAM log file
?- owl_parse('pick-and-place-no-details.owl', false, false, true).

% load and visualize semantic map
?- owl_individual_of(A, knowrob:'SemanticEnvironmentMap'), add_object_with_children(A).

% read start time of grasp action from MongoDB
?- task_goal(T, 'GRASP'), task_start(T, St).

% read robot pose at this time and add to the visualization
?- mng_robot_pose_at_time(pr2:'PR2Robot1', '/map', $St, Pose),
   add_object_with_children(pr2:'PR2Robot1', $St).

% highlight all cameras that are part of the SRDL model of the robot
?- owl_individual_of(A, srdl2comp:'Camera'), highlight_object(A, @(true), 0, 255, 255, 255).

The following is to be performed from the roslog_2013_08_29_1445 folder:

# Is some part of the right arm blocking the view on the object?
?- register_ros_package(mod_srdl), owl_parse('perceive-no-details.owl', false, false, true).
?- mng_obj_pose_by_desig('http://ias.cs.tum.edu/kb/cram_log.owl#VisualPerception_Z9fXhEae_object_0', Pose).
?- sub_component(pr2:pr2_right_arm, Part), 
   once(owl_individual_of(Part, srdl2comp:'UrdfLink')),
   obj_blocked_by_in_camera(log:'VisualPerception_Z9fXhEae_object_0', Part, 
   pr2:pr2_head_mount_kinect_rgb_link, log:'timepoint_1377780296').
   
# Is the object visible in the camera, given the camera's field of view?
?- obj_visible_in_camera(log:'VisualPerception_Z9fXhEae_object_0', 
                         pr2:pr2_head_mount_kinect_rgb_link,
                         log:'timepoint_1377780271').
true .