Robotics StackExchange | Archived questions

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 gazebomsgs.msg import ModelState from gazebomsgs.srv import SetModelState from gazebomsgs.srv import GetModelState import rospy import rospkg import time import math import numpy as np from stdmsgs.msg import * from geometrymsgs.msg import * import tf2msgs.msg from tf.transformations import eulerfromquaternion from collections import Counter from controllib import URController from geometry_msgs.msg import Twist

---------------Initialise---------------:

print("Please Wait While System Starts Up...") rospy.initnode("movelexample", anonymous=False) urscript = rospy.Publisher('/urhardwareinterface/scriptcommand', String, queuesize=10) urcon = URController() 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 

Asked by georgios on 2023-03-15 08:46:07 UTC

Comments

Answers

(just make it clear because it is not showing my question very well) 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

Asked by georgios on 2023-03-15 08:48:27 UTC

Comments