ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
0

Custom action goal: "has no attribute" error

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

sisko gravatar image

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

gvdhoorn gravatar image

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

#goal
int64 x
int64 y
int64 z
string position
---
#result
bool completed
---
#feeback
string report

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

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

Here's my client.py 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)

    client.wait_for_server()

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

    client.send_goal(goal)

    client.wait_for_result()

    return client.get_result()

if __name__ == '__main__':
    try:
        rospy.init_node('sweepbot_movebase_client')
        result = setPosition()
        rospy.logdebug(result)
    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

Comments

1

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 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

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

gvdhoorn gravatar image

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

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

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: 2021-04-12 10:32:27 -0600

Seen: 725 times

Last updated: Apr 12 '21