#!/usr/bin/env python

import rospy 
import rospkg 
from gazebo_msgs.msg import ModelState 
from gazebo_msgs.srv import SetModelState

def main():
    rospy.init_node('set_pose', anonymous=True)

    state_msg = ModelState()
    state_msg.model_name = 'sphere'
    state_msg.reference_frame = 'ground_plane'
    state_msg.pose.position.x = 0
    state_msg.pose.position.y = 0
    state_msg.pose.position.z = 0
    state_msg.pose.orientation.x = 0
    state_msg.pose.orientation.y = 0
    state_msg.pose.orientation.z = 0
    state_msg.pose.orientation.w = 0
    print("runnnnnnnnnnnnnnn")
    rospy.wait_for_service('/gazebo/set_model_state')
    try:
        set_state = rospy.ServiceProxy('/gazebo/set_model_state', SetModelState)
        resp = set_state( state_msg )

    except rospy.ServiceException, e:
        print "Service call failed: %s" % e

if __name__ == '__main__':
    try:
        main()
    except rospy.ROSInterruptException:
        pass



# import rospy
# import rospkg
# from gazebo_msgs.msg import ModelState
# from gazebo_msgs.srv import SetModelState


# rospy.init_node("sphere_pub")

# state_msg = ModelState()
# state_msg.model_name = "sphere"
# state_msg.reference_frame = "ground_plane"
# state_msg.pose.position.x = 1.0
# state_msg.pose.position.y = 2.0
# state_msg.pose.position.z = 1.0
# state_msg.pose.orientation.x = 0.0
# state_msg.pose.orientation.y = 0.0
# state_msg.pose.orientation.z = 0.0
# state_msg.pose.orientation.w = 1.0

# rospy.wait_for_service("/gazebo/set_model_state")
# set_state = rospy.ServiceProxy('/gazebo/set_model_state', SetModelState)
# resp = set_state(state_msg)



# # def main():
# #     rospy.init_node("sphere_pub")

# #     state_msg = ModelState()
# #     state_msg.model_name = "sphere"
# #     state_msg.reference_frame = "ground_plane"
# #     state_msg.pose.position.x = 1.0
# #     state_msg.pose.position.y = 2.0
# #     state_msg.pose.position.z = 1.0
# #     state_msg.pose.orientation.x = 0
# #     state_msg.pose.orientation.y = 0
# #     state_msg.pose.orientation.z = 0
# #     state_msg.pose.orientation.w = 1.0

# #     rospy.wait_for_service("/gazebo/set_model_state")
# #     try:
# #         set_state = rospy.ServiceProxy('/gazebo/set_model_state', SetModelState)
# #         resp = set_state(state_msg)

# #     except rospy.ServiceException, e:
# #         print "Service call failed: %s" % e

# # if __name__ == '__main__':
# #     try:
# #         main()
# #     except rospy.ROSInterruptException:
# #         pass
