Ask Your Question
0

TypeError: expected [string] but got [gazebo_msgs/ApplyBodyWrenchResponse]

asked 2020-01-30 10:01:50 -0500

505852124@qq.com gravatar image

I use rosservice to drive the rrbot model, python code is as follows:

#!/usr/bin/env python
import rospy

from geometry_msgs.msg import Pose, Quaternion, Point, PoseStamped, PoseWithCovariance, TwistWithCovariance, Twist, Vector3, Wrench

from gazebo_msgs.srv import ApplyBodyWrench
wrench = Wrench()

wrench.torque.x = 0
wrench.torque.y = 5
wrench.torque.z = 0
rospy.wait_for_service ('/gazebo/apply_body_wrench')
apply_body_wrench = rospy.ServiceProxy('/gazebo/apply_body_wrench', ApplyBodyWrench)
resp = apply_body_wrench(apply_body_wrench(body_name = "rrbot::link3",reference_frame = "rrbot::link3", wrench = wrench,start_time = rospy.Time(0), duration = rospy.Duration(5)))

Although successfully driven the robot, however, the results does not receive srv information(such as success) and some errors as follows:

    Traceback (most recent call last):
  File "test.py", line 38, in <module>
    torque_node(point , wrench, start_time, duration)
  File "test.py", line 15, in torque_node
    resp = apply_body_wrench(apply_body_wrench(body_name = "rrbot::link3"))
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 439, in __call__
    return self.call(*args, **kwds)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 495, in call
    request = rospy.msg.args_kwds_to_message(self.request_class, args, kwds) 
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/msg.py", line 121, in args_kwds_to_message
    raise TypeError("expected [%s] but got [%s]"%(data_class._slot_types[0], arg._type))
TypeError: expected [string] but got [gazebo_msgs/ApplyBodyWrenchResponse]
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2020-01-30 10:34:21 -0500

gvdhoorn gravatar image
resp = apply_body_wrench(apply_body_wrench(..))

shouldn't that second apply_body_wrench be ApplyBodyWrench instead (and perhaps even ApplyBodyWrenchRequest)?

edit flag offensive delete link more

Comments

You are right.I have soved this problem.Thank you.

505852124@qq.com gravatar image 505852124@qq.com  ( 2020-01-31 01:42:18 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-01-30 10:01:50 -0500

Seen: 290 times

Last updated: Jan 30 '20