54 views
# KnowRob Cheat-Sheet ## Start KnowRob mit Belive state 1. start roscore 2. source catkin workspace 3. start knowrob_refills/scripts/start_knowrob_with_beliefstate.py - Care current state demands that the neem_mode is set to false 5. start knowrob_refills 6. enjoy ## Start Docker with local believestate 1. choose Version 2. Check is image already there - if yes please delete 3. build filestructure - simulation_data (in init_image) - annotations/ - roslog - [DATA] (annotations.bson, annotations.metadata.json) - inferred/ - roslog - [DATA] (inferred.bson, inferred.metadata.json) - ros_tf/ - roslog - [DATA] (tf.bson, tf.metadata.json) - triples/ - roslog - [DATA] (triples.bson, triples.metadata.json) 4. build local - docker build -t iaik4r/knowrob-init:v0.2 [PATHTOSAVE] 5. docker com up ## Convert bson to json One-liner :D :::info bsondump --pretty --outFile FileName.json FileName.bson ::: The pretty command makes it nicely human readable. If you don't need it, you can leave it out and the file should be smaller in size. Not only that it also makes it harder to read via Code so try to avoid it or at least give a headsup through the name ## Working with Knowrob - Start KnowRob - roslaunch knowrob knowrob.launch - Prolog commandline - rosrun rosprolog rosprolog_commandline.py - running tests - rosrun rosprolog rosprolog-test [src/ros/neem_logs.pl] ## Example queries - product dimensions (Maybe not ready) - product_dimensions(Product,[Depth, Width, Height]) - Empty Facing Postions (something like this) - has_type(Facing, shop:'ProductFacingStanding'), \+ triple(Facing, shop:productInFacing, _ ).is_at(Facing, ['map', T, R]) - load owl File (not sure how this works) ([] ar not from me) - tripledb_load('package://knowrob/owl/test/swrl.owl',[ graph(user),namespace(test_swrl,'http://knowrob.org/kb/swrl_test.owl#')]). ### Reverse engineered Queries - get Shelves System IDs (80% sure) - findall(R, instance_of(R, dmshop:'DMShelfFrame'), Rs). - get (World)-Pose - lookup_pose("map", self.get_object_frame_id([shelf_system_id])) - Type of ID - has_type('{}', Type)".format(shelf_id) - Model path - subclass_of('{}', MeshDesc), has_description(MeshDesc, value(knowrob:pathToCadModel, FilePath))".format(biggestSet['Type']))['FilePath'] #### Get all Data with shop.pl - Get Shelfsystem data - findall([Shelf,Translation,Rotation,Modelname,Depth,Width,Height],(has_type(Shelf, dmshop:'DMShelfFrame'),is_at(Shelf, ['map', Translation, Rotation]),get_model_path(Shelf,Modelname),get_dimensions(Shelf,Depth,Width,Height)),Bag) - Get all Layer Data - findall([Layer,Translation,Rotation,Modelname,Depth,Width,Height],(has_type(Shelf, dmshop:'DMShelfFrame'),triple(Shelf, soma:hasPhysicalComponent, Layer),is_at(Layer, ['map', Translation, Rotation]),get_model_path(Layer,Modelname),get_dimensions(Layer,Depth,Width,Height)),Bag) - Get All Items - Short (without Modelname) cause it is not there - findall([Item,Translation,Rotation,Depth,Width,Height],(has_type(Shelf, dmshop:'DMShelfFrame'),triple(Shelf, soma:hasPhysicalComponent, Layer),triple(Facing, shop:layerOfFacing, Layer),triple(Facing, rdf:type, shop:'ProductFacingStanding'),triple(Facing, shop:productInFacing, Item),is_at(Item, ['map', Translation, Rotation]),get_dimensions(Item,Depth,Width,Height)),Bag) - long (with Modelname) - findall([Item,Translation,Rotation,Modelname,Depth,Width,Height],(has_type(Shelf, dmshop:'DMShelfFrame'),triple(Shelf, soma:hasPhysicalComponent, Layer),triple(Facing, shop:layerOfFacing, Layer),triple(Facing, rdf:type, shop:'ProductFacingStanding'),triple(Facing, shop:productInFacing, Item),is_at(Item, ['map', Translation, Rotation]),get_model_path(Item,Modelname),get_dimensions(Item,Depth,Width,Height)),Bag) ### Get all Data without shop.pl - Get Shelfsystem data - findall([Shelf,Translation,Rotation,Modelname,Depth,Width,Height],(has_type(Shelf, dmshop:'DMShelfFrame'),is_at(Shelf, ['map', Translation, Rotation]),triple(Shelf, soma:hasShape, Shape), triple(Shape, dul:hasRegion, ShapeRegion), triple(ShapeRegion, soma:hasFilePath, Modelname),object_dimensions(Shelf,Depth,Width,Height)),Bag) - Get all Layer Data - findall([Layer,Translation,Rotation,Modelname,Depth,Width,Height],(has_type(Shelf, dmshop:'DMShelfFrame'),triple(Shelf, soma:hasPhysicalComponent, Layer),is_at(Layer, ['map', Translation, Rotation]),triple(Shelf, soma:hasShape, Shape), triple(Shape, dul:hasRegion, ShapeRegion), triple(ShapeRegion, soma:hasFilePath, Modelname),object_dimensions(Layer,Depth,Width,Height)),Bag) - Get All Items - Short (without Modelname) cause it is not there - findall([Item,Translation,Rotation,Depth,Width,Height],(has_type(Shelf, dmshop:'DMShelfFrame'),triple(Shelf, soma:hasPhysicalComponent, Layer),triple(Facing, shop:layerOfFacing, Layer),triple(Facing, rdf:type, shop:'ProductFacingStanding'),triple(Facing, shop:productInFacing, Item),is_at(Item, ['map', Translation, Rotation]),object_dimensions(Item,Depth,Width,Height)),Bag) - 03.08.2021 --> Something was fishy with the first queries I redid them - Long - {"query": " has_type(ItemId, ItemType), transitive(subclass_of(ItemType, shop:'Product')),is_at(ItemId, ['map', Translation, Rotation]),object_dimensions(ItemId,Depth,Width,Height),triple(ItemId, soma:hasShape, Shape), triple(Shape, dul:hasRegion, ShapeRegion), triple(ShapeRegion, soma:hasFilePath, Modelname)", "maxSolutionCount": 1000000} - short - {"query": " has_type(ItemId, ItemType), transitive(subclass_of(ItemType, shop:'Product')),is_at(ItemId, ['map', Translation, Rotation]),object_dimensions(ItemId,Depth,Width,Height)", "maxSolutionCount": 1000000} - long (with Modelname) - findall([Item,Translation,Rotation,Modelname,Depth,Width,Height],(has_type(Shelf, dmshop:'DMShelfFrame'),triple(Shelf, soma:hasPhysicalComponent, Layer),triple(Facing, shop:layerOfFacing, Layer),triple(Facing, rdf:type, shop:'ProductFacingStanding'),triple(Facing, shop:productInFacing, Item),is_at(Item, ['map', Translation, Rotation]),triple(Shelf, soma:hasShape, Shape), triple(Shape, dul:hasRegion, ShapeRegion), triple(ShapeRegion, soma:hasFilePath, Modelname),object_dimensions(Item,Depth,Width,Height)),Bag) - Empty Facings - long (with missing Item dimensions) - triple(Facing, shop:labelOfFacing, Label),triple(Label, shop:articleNumberOfLabel, AN),is_restriction(R,value(shop:articleNumberOfProduct, AN)),subclass_of(ProductName, R),object_dimensions(ProductName, Depth, Width, Height) - short (without missing Item diemnsions) - has_type(Facing, shop:'ProductFacingStanding'), triple(Facing, shop:productInFacing, _ ), is_at(Facing, ['map', T, R]) - POSE ```prolog is_at('DMShelfMarkerLeft_KLZFMRSC', ['map', Position, Rotation]). is_at('child_frame_id', ['goal_frame, Position, Rotation']) findall([Shelf,Translation,Rotation,Modelname,Depth,Width,Height], (has_type(Shelf, dmshop:'DMShelfFrame'), is_at(Shelf, ['map', Translation, Rotation]), triple(Shelf, soma:hasShape, Shape), triple(Shape, dul:hasRegion, ShapeRegion), triple(ShapeRegion, soma:hasFilePath, Modelname), object_dimensions(Shelf,Depth,Width,Height)),Bag) ``` ### NEEM validation The NEEM should contain: 1. tf, triple collections 2. All meshes that are not standard (usually not available in iai repo) 3. URDFs for agent and map 4. and meta info for your neem(which basically is the info you see on neem card on openease) If you have a neem, try to let knowrob replay it: "for that you need to have tf, triple, collections in your local mongodb and then you just launch knowrob. and then in rosprolgo console, try load_knowrob_neem('')"" #### Random Queries I found somewhere (do they even work?) product_dimensions(Product,[Depth, Width, Height]) (?) Empty Facing: has_type(Facing, shop:'ProductFacingStanding'), \+ triple(Facing, shop:productInFacing, _ ). is_at(Facing, ['map', T, R]), Product dimensions in the facing: holds(Facing, shop:labelOfFacing, Label), holds(Label,shop:articleNumberOfLabel,ArticleNumber), subclass_of(ProductType, shop:'Product'), subclass_of(ProductType, R), has_description(R,value(shop:articleNumberOfProduct,ArticleNumber)), subclass_of(ProductType, R1), has_description(R1, value(shop:'depthOfProduct', D)), subclass_of(ProductType, R2), has_description(R2, value(shop:'widthOfProduct', W)), subclass_of(ProductType, R3), has_description(R3, value(shop:'heightOfProduct', H)).