Is it possible to tilt or give some orientation to the objects in planning scene?

asked 2019-09-27 23:19:42 -0500

Adwait_Naik gravatar image

updated 2019-10-01 04:25:33 -0500

ffusco gravatar image


I am trying to add objects like sphere, cylinder, cube to my planning scene I want to tilt the object by some angle. How to do it using python?

edit retag flag offensive close merge delete


When you fill the collision object message, you specify the geometry using the field primitives, which you can translate/rotate individually by specifying a corresponding pose in primitive_poses. Is this enough information or do you need a more detailed explanation?

ffusco gravatar image ffusco  ( 2019-09-28 01:00:29 -0500 )edit

Thanks for responding.

This is my code for adding objects to planning scene. I would be really grateful if you could guide me how to implement the primitive poses in my code.

Thanks a lot

def addBox(self, name, size_x, size_y, size_z, x, y, z, use_service=True):
        s = SolidPrimitive()
        s.dimensions = [size_x, size_y, size_z]
        s.type = s.BOX

        ps = PoseStamped()
        ps.header.frame_id = self._fixed_frame
        ps.pose.position.x = x
        ps.pose.position.y = y
        ps.pose.position.z = z
        ps.pose.orientation.w = 1.0

        self.addSolidPrimitive(name, s, ps.pose, use_service)
Adwait_Naik gravatar image Adwait_Naik  ( 2019-09-28 03:15:26 -0500 )edit

You're almost there: just change the orientation part and you're good to go! Keep in mind that orientation uses unit quaternions. Given a unit axis of rotation u=[ux,uy,uz] and an angle theta, the quaternion [w,x,y,z] is defined as [cos(theta/2), ux*sin(theta/2), uy*sin(theta/2), uz*sin(theta/2)]. As an example, if you want the box to be rotated around the x-axis of -90 degrees, the w and x components would be 1/√2 and -1/√2 respectively, ie, ps.pose.orientation.w=0.5**0.5 and ps.pose.orientation.x=-0.5**0.5. You can easily find more info about unit quaternions online if you wish! As a side note: I assume that your class method addSolidPrimitive actually informs move_group's planning scene about the object, meaning that you already know how to use ...(more)

ffusco gravatar image ffusco  ( 2019-10-01 03:00:48 -0500 )edit

Sir, Thanks for explaining in depth. No, I am not well versed with the planning scene interface otherwise why would I ask such question. I am still learning.

Adwait_Naik gravatar image Adwait_Naik  ( 2019-10-01 03:19:51 -0500 )edit

I hope my comment did not sound "offending": since you posted a class method that was calling another method for which code was not provided, I assumed the problem was not about adding the object but just about properly setting its orientation. Could you please edit your question by adding a slim version of your class code? In particular, the class definition (just to know whether you are inheriting from another class), the constructor and the method addSolidPrimitive. In this way it will be easier to understand what additional information you need. Meanwhile, I can point you to the relevant section from the MoveIt tutorial (kinetic) - you likely read it already, but I believe it is worth mentioning it anyway!

ffusco gravatar image ffusco  ( 2019-10-01 03:48:27 -0500 )edit

Not at all offending. Sir, Its pleasure to have people like you who are giving guidance. Thank a lot I will try to implement as per your suggestion.

Adwait_Naik gravatar image Adwait_Naik  ( 2019-10-01 03:51:38 -0500 )edit