ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Custom action goal: "has no attribute" error

asked 2021-04-12 10:32:27 -0500

sisko gravatar image

updated 2021-04-12 11:11:43 -0500

gvdhoorn gravatar image

I have created a custom action called TakePosition.action with the following data :

int64 x
int64 y
int64 z
string position
bool completed
string report

When I try using my TakePositionActionGoal in my script, I get an error saying :

  File "/home/sisko/catkin_ws/devel/lib/python2.7/dist-packages/sweepbot_tools/msg/", line 122, in serialize
_x.goal.y, _x.goal.z)) AttributeError: 'TakePositionActionGoal' object has no attribute 'x'

Here's my script :

#! /usr/bin/env python
from __future__ import print_function

import rospy
from sweepbot_tools.msg import TakePositionAction, TakePositionActionGoal

import actionlib

def setPosition():
    client = actionlib.SimpleActionClient('sweepbot_movebase_server', TakePositionAction)


    goal = TakePositionActionGoal()
    goal.goal.x = 7
    goal.goal.y = 7
    goal.goal.z = 7
    goal.goal.position = ''



    return client.get_result()

if __name__ == '__main__':
        result = setPosition()
    except rospy.ROSInterruptException:
        print("program interrupted before completion", file=sys.stderr)

The porpose is to create pose data which I can pass to my custom action server which would calls move_base with the recieved pose.

Clearly there is an x attribute in my action definition. I don't understand what the souce of this error is.

edit retag flag offensive close merge delete



I've updated the title of your question to better reflect the problem you were having.

Seeing as action servers are servers, using the words "not responding" makes it seem there is something wrong with your server, while you're having problems writing the client script.

gvdhoorn gravatar image gvdhoorn  ( 2021-04-12 11:12:55 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2021-04-12 11:10:03 -0500

gvdhoorn gravatar image

updated 2021-04-12 11:11:18 -0500

goal = TakePositionActionGoal()

I believe that should actually be:

goal = TakePositionGoal()

Refer also to the Writing a Simple Action Client (Python) tutorial:

# Creates a goal to send to the action server.
goal = actionlib_tutorials.msg.FibonacciGoal(order=20)

where they do the same.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2021-04-12 10:32:27 -0500

Seen: 1,392 times

Last updated: Apr 12 '21