Adding modelState to gazebo simulator using python node
Hello,
I would like to add a model to gazebo simulator not in the world file but while executing a node. Therefore, I created the following node:
#!/usr/bin/env python
import rospy
import roslib
from std_msgs.msg import String
from gazebo_msgs.msg import ModelState
def setObject():
pub = rospy.Publisher('setObjectTopic', ModelState, queue_size=10)
rospy.init_node('setObject', anonymous=True)
rate = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
msg = ModelState()
msg.pose.position.x = 1.0
msg.pose.position.y = 1.0
msg.model_name = "grey_wall"
pub.publish(msg)
rate.sleep()
print "here"
if __name__ == '__main__':
try:
setObject()
except rospy.ROSInterruptException:
pass
I didnt git any syntax error but I could not see the object on the gazebo. So, what should I do to make this thing works?
There is some gazebo services existing : http://gazebosim.org/tutorials/?tut=ros_comm#Services:Createanddestroymodelsinsimulation
I am getting this issue as well. Are you saying that the Gazebo model cannot be moved like this because there is a gazebo service that is charged to do this? If that is the case, how can we move the model? Also, I think that it should be: pub = rospy.Publisher('/gazebo/set_model_state'.....