How to request a service with complex service type(in python)?
I want to request this service, so I wrote a snippet of code to do this:
Edit (The code works if you create a package named generate_semantic_map by "roscreate-pkg generate_semantic_map mod_semantic_map, and put this file in the package)
#!/usr/bin/env python
import roslib;
roslib.load_manifest('generate_semantic_map') #For loading srv in generate_semantic_map
import rospy
from mod_semantic_map.srv import *
from mod_semantic_map.msg import *
rospy.wait_for_service('/knowrob_semantic_map_to_owl/generate_owl_map')
request_sem_map=rospy.ServiceProxy('knowrob_semantic_map_to_owl/generate_owl_map', GenerateSemanticMapOWL)
request = GenerateSemanticMapOWLRequest()
request.map.header.frame_id = "map"
request.map.objects = [SemMapObject(id=1, type='Cupboard', width=1.0, depth=1.0, height=1.0, pose = [0.99999856179, -8.178859999999999e-07, -0.0016959996980000001, 1.0, 3.18211e-06, 0.99999902838, 0.00139399691, 1.0, 0.00169599691, -0.001394000302, 0.999997590174, 1.0, 0, 0, 0, 1])]
owlmap = request_sem_map(request)
print owlmap
The question is, I don't know how to generate the request. I know how to request simple service type since I already learn from the tutorial, but I don't know how to handle structural request.
In C++, I can create a object of request type and fill the data member in this object, and then send this object as request, but I don't know how to do this in python.
This seems to be a stupid question...but I don't know how to solve it, thanks in advance.
Note that your pose matrix is invalid.
Oh thanks, I should use the function static double [] edu::tum::cs::ias::knowrob::tutorial::ROSClient::quaternionToMatrix(Point p,Quaternion q) to get the matrix. The weird thing is, I can visualize the object in visualization canvas now, maybe the visualizer ignores this error?
Possibly. The method you mention is a java method not a python method, right? And it will give you only a 3x3 matrix which is missing the translational component.
Yes it is a java method. On this page, http://ros.informatik.uni-freiburg.de/roswiki/doc/api/knowrob_tutorial/html/classedu_1_1tum_1_1cs_1_1ias_1_1knowrob_1_1tutorial_1_1ROSClient.html, it says the Returns of quaternionToMatrix is a 4x4 pose matrix.
You are right. The name just confused me :)
Thanks for reminding me of the matrix~ I 'll update the code once I got the valid value: )