Trying to apply wrench, getting 'not callable' error

asked 2020-05-04 03:42:14 -0500

bungalus gravatar image

updated 2020-05-04 03:45:32 -0500

Hi all, trying to apply wrench to a body and I am getting an error that something is not callable. I will attach the code below along with the error

rospy.wait_for_service("gazebo/spawn_sdf_model")
        spawn = rospy.ServiceProxy("gazebo/spawn_sdf_model",SpawnModel)
        projectile_path = os.getcwd() + "/maps/projectile.sdf"
        projectile_name = "projectile"+str(13-self.ammo)
        pose = Pose()
        posePos = Point()
        posePos.x = self.position[0]
        posePos.y = self.position[1]
        posePos.z = self.position[2]
        poseAng = Quaternion()
        poseAng.x = 0; poseAng.y = 0; poseAng.z = 0; poseAng.w = 1
        pose.position = posePos
        pose.orientation = poseAng
        pose.position.z += 0.25

        f = open(projectile_path)
        sdf = f.read()

        spawn(projectile_name, sdf, "", pose,"")
        rospy.wait_for_service("gazebo/apply_body_wrench")
        force = rospy.ServiceProxy("gazebo/apply_body_wrench",ApplyBodyWrench)          
        wrench = Wrench()
        force = 1.0
        wrench.force.x = force*np.cos(self.zangle*np.pi/180)
        wrench.force.y = force*np.sin(self.zangle*np.pi/180)
        self.ammo=self.ammo-1
        force(projectile_name,"", None, wrench,rospy.get_rostime(),rospy.Duration(0.2))

The projectile spawning is working and I have another section that deletes the projectile which is working, too. The error is as follows:

[ERROR] [1588581280.031841, 3322.056000]: bad callback: <bound method Shooter._update_target of <__main__.Shooter instance at 0x7f46f721ee10>>
Traceback (most recent call last):
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
cb(msg)
File "scripts/projectile.py", line 54, in _update_target
self.shoot()
File "scripts/projectile.py", line 91, in shoot
force(projectile_name,"", None, wrench,rospy.get_rostime(),rospy.Duration(0.2))
TypeError: 'float' object is not callable

Any help would be appreciated!I can supply more information if needed

edit retag flag offensive close merge delete

Comments

You are overwritting the service client

force = rospy.ServiceProxy("gazebo/apply_body_wrench",ApplyBodyWrench)          
force = 1.0
nlamprian gravatar imagenlamprian ( 2020-05-04 04:20:48 -0500 )edit