"raise Typeerror()" when sending a goal to "FollowWaypoints" server of Nav2 [closed]

asked 2021-04-27 14:56:24 -0500

jingCNinDE gravatar image

updated 2021-05-04 12:37:08 -0500

hi everyone, i am new for ros. i tried the example in the nav2(https://navigation.ros.org/getti... and want to use the 'FollowWaypoints' action server to navigate the robot by the given points. i wrote a pythonscript for the client. the robot should go to the given point, for example(0.2,1.3.0). but it does not work, i got a error 'rasing typeerror'. here is my python code for my "FollowWaypoints" client:

class ClientFollowPoints(Node):

    def __init__(self):
        super().__init__('client_follow_points')
        self._client = ActionClient(self, FollowWaypoints, '/FollowWaypoints')

    def send_points(self, points):
        msg = FollowWaypoints.Goal
        msg.poses = points

        self._client.wait_for_server()
        self._send_goal_future = self._client.send_goal_async(msg, feedback_callback=self.feedback_callback)
        self._send_goal_future.add_done_callback(self.goal_response_callback)

    def goal_response_callback(self, future):
        goal_handle = future.result()
        if not goal_handle.accepted:
            self.get_logger().info('Goal rejected')
            return

        self.get_logger().info('Goal accepted')

        self._get_result_future = goal_handle.get_result_async()
        self._get_result_future.add_done_callback(self.get_result_callback)

    def get_result_callback(self, future):
        result = future.result().result
        self.get_logger().info('Result: {0}'.format(result.missed_waypoints))

    def feedback_callback(self, feedback_msg):
        feedback = feedback_msg.feedback
        self.get_logger().info('Received feedback: {0}}'.format(feedback.current_waypoint))

and my main:

    rclpy.init(args=args)

    follow_points_client = ClientFollowPoints()
    print('client inited')

    rgoal = PoseStamped()
    rgoal.header.frame_id = "map"
    rgoal.header.stamp.sec = 0
    rgoal.header.stamp.nanosec = 0
    rgoal.pose.position.z = 0.0
    rgoal.pose.position.x = 0.2
    rgoal.pose.position.y = 1.3
    rgoal.pose.orientation.w = 1.0
    print(rgoal)
    mgoal = [rgoal]

    follow_points_client.send_points(mgoal)

    rclpy.spin(follow_points_client)

and my Trace back:

Traceback (most recent call last):
  File "/home/jing/htwg/tryForROS/dev_ws/install/follow_points_client/lib/follow_points_client/fp_client", line 11, in <module>
    load_entry_point('follow-points-client==0.0.0', 'console_scripts', 'fp_client')()
  File "/home/jing/htwg/tryForROS/dev_ws/install/follow_points_client/lib/python3.8/site-packages/follow_points_client/follow_points_client.py", line 58, in main
    follow_points_client.send_points([rgoal])
  File "/home/jing/htwg/tryForROS/dev_ws/install/follow_points_client/lib/python3.8/site-packages/follow_points_client/follow_points_client.py", line 20, in send_points
    self._send_goal_future = self._client.send_goal_async(msg, feedback_callback=self.feedback_callback)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/action/client.py", line 421, in send_goal_async
    raise TypeError()
TypeError

Really appreciate it. Thank you!

forgot to add () after the goal.

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by jingCNinDE
close date 2021-05-04 12:37:24.996324