hit in gazebo world and i created a co i got the problem that the camera is shaking all the time probably is getting two different msgs and i don't know how can do it can someone help me please
hello my name is georgios I am doing my final project. I created camera_box link and launch it in gazebo world and i created a code to use ursim and same time make the camera follow the robot but i got the problem that the camera is shaking all the time probably is getting two different msgs and i don't know how can do it can someone help me please
!/usr/bin/env python3
---------------Import Libraries and msgs---------------:
from gazebo_msgs.msg import ModelState from gazebo_msgs.srv import SetModelState from gazebo_msgs.srv import GetModelState import rospy import rospkg import time import math import numpy as np from std_msgs.msg import * from geometry_msgs.msg import * import tf2_msgs.msg from tf.transformations import euler_from_quaternion from collections import Counter from control_lib import UR_Controller from geometry_msgs.msg import Twist
---------------Initialise---------------:
print("Please Wait While System Starts Up...") rospy.init_node("move_l_example", anonymous=False) ur_script = rospy.Publisher('/ur_hardware_interface/script_command', String, queue_size=10) ur_con = UR_Controller() time.sleep(2) print("System Started")
""" def main():
#rospy.init_node('set_pose')
state_msg = ModelState()
state_msg.model_name = 'camera_box'
state_msg.pose.position.x = 0
state_msg.pose.position.y = 0
state_msg.pose.position.z = 0.3
state_msg.pose.orientation.x = 0
state_msg.pose.orientation.y = 0
state_msg.pose.orientation.z = 0
state_msg.pose.orientation.w = 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 as e:
print ("Service call failed: %s" % e)
if __name__ == '__main__': try: main() except rospy.ROSInterruptException: pass
"""
---------------Main Code---------------:
Home robot
while loop
while True:
my_pos = ur_con.get_pose() #get the pose from ur10
print(my_pos) # print the pose of the ur10
rospy.wait_for_service('/gazebo/set_model_state') # wait the service to be available
robot_arm = rospy.ServiceProxy('/gazebo/set_model_state', SetModelState) # creat broxy talking to the service (set-up) (from ModelState to SetModelState)
UR10_State = SetModelState() #initialize modelstate msgs
UR10_State.pose=my_pos # UR10 pose
UR10_State.twist=Twist() #initialize modelstate msgs # get ur10 twist
UR10_State.model_name = "camera_box" # get camera model name
#time.sleep(5)
print('')
UR10_State.reference_frame = "world" # get world name
resp1 = robot_arm(UR10_State) # talk to the service
#print('my_pose')
time.sleep(1) # time for sent the next msg system to run