Basic Kinematics of Mobile Robots -> Unit 2: Rigid-Body Motions: coke_can model rotatin about wrong orientation point

Hi! I’m having issue with rotating coke_can model. When applied y axes rotation to the model its not rotating as expected from notebook. I expected to rotate the can about the button but its rotating about head. It there is way to solve it?
Edit


What is expected

Here is the code

import math
import rospy
from utilities import set_model_state, get_model_state, \
    pause_physics, unpause_physics, spawn_coke_can
from geometry_msgs.msg import Pose, Point, Quaternion
from tf.transformations import quaternion_about_axis


if get_model_state('coke_can').success == False:
    spawn_coke_can('coke_can', Pose(position=Point(0, 0, 0.5)))


pause_physics()
position = Point(x=0.0, y=0, z=0.5)


for angle in range(0, 370, 10):
    theta = math.radians(angle)
    q = quaternion_about_axis(theta, (0, 1, 0))
    orientation = Quaternion(*q)
    set_model_state('coke_can', Pose(position, orientation))
    rospy.sleep(0.1)

Hi @mequrbanov, Can you include the code you are using and also screenshots of the coke_can comparing the notebook version and the result you got. The more information you share, more information we have to work with.

Best
-Joseph

Thanks for reply, @Joseph1001 ! I added resulting and expected screenshots, and code used.

Change the z=0.5 to z=-0.5, as shown below

Let me know if this work

@Joseph1001 , changed position. With z = -0.5 it disappears to the ground. I think it can be solved with changing center of mass of coke_can model. Dont know how. No access to utility functions and coke_can model.

I agree with you, this does not seem to be a problem with the code, but rather with how the origin or center of mass was set for the coke_can.

You can actually view the center of mass by clicking the center of mass button under View
image

Also, the center of mass can be adjusted by modifying the URDF file, about which you will learn in the below shown course.
image

I suggest that you skip the coke_can’s center of mass problem for now and come back to it after you have completed the above mentioned course on URDF.

Thanks, @Joseph1001 !

1 Like