Unable to see the Coke can to rotate around the Turtlebot

Hello, community, and Merry Christmas!

I’m trying to execute the following script in Unit 2 section 2.3:

import math, rospy
from utilities import set_model_state, get_model_state
from geometry_msgs.msg import Pose, Point, Quaternion

x, y, z = 1, 0, 0.22
for angle in range(0,360,10):
    theta = math.radians(angle)
    xp = x * math.cos(theta) - y * math.sin(theta)
    yp = x * math.sin(theta) + y * math.cos(theta)
    set_model_state('coke_can', Pose(position=Point(xp,yp,z)))
    rospy.sleep(0.1)

but unfortunately, the coke can doesn’t rotate around the Turtlebot nor appears.
A short sample:

Why that?

I think extra code is missing from the script

import math, rospy
from utilities import set_model_state, get_model_state, \
                      spawn_coke_can
from geometry_msgs.msg import Pose, Point, Quaternion

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

x, y, z = 1, 0, 0.22

for angle in range(0,360,10):
    theta = math.radians(angle)
    xp = x * math.cos(theta) - y * math.sin(theta)
    yp = x * math.sin(theta) + y * math.cos(theta)
    set_model_state('coke_can', Pose(position=Point(xp,yp,z)))
    rospy.sleep(0.1)

Hello @vasileios.tzimas ,

Yes, you are right. This script, unit2_rotations.py, is meant to be executed right after the previous script, unit2_positions.py (which does the spawn of the coke). Therefore, it expects the coke to be already spawned. If it is not, then it’s not going to work properly. I’ll add some notes to the notebook to indicate this.