Ros Basics Real Robot Project Action Client

Hello, I ask you a question, I am making an actions client in which the actions server is going to be What you have to do is how goal receives the meters that the robot has to do, as a result the list (x,y,z) of its position that values ​​are added every 1 second and as feedback the meters traveled so far. I’m going to pass you the code, the problem I have is when the GUI opens, it tells me that no goal, disconnected from server.

#!/usr/bin/env python
# ---------------------IMPORTACION DE MODULOS Y MENSAJES--------------------------
import rospy

import actionlib

from scan_test.msg import OdomRecordAction,OdomRecordGoal, OdomRecordResult, OdomRecordFeedback

from nav_msgs.msg import Odometry

#----------------------DECLARACION DE OBJETOS Y INICIALIZACION DE VARIABLES-----------------

goal = OdomRecordGoal()

odom = Odometry()

feedback = OdomRecordFeedback()

result = OdomRecordResult()

goal.meter = 10.0

feedback.current_total = 0

result.list_of_odoms = []

def callback(msg):
    global list_of_odoms
    result.list_of_odoms.append([msg.pose.pose.position.x, msg.pose.pose.position.y, msg.pose.pose.position.z])


def feedback_callback(msg):
    global current_total
    if msg.pose.pose.position.x not in result.list_of_odoms:
        feedback.current_total += 1
        print('Cantidad de metros recorridos: ', feedback.current_total)

client = actionlib.SimpleActionClient('/my_action', OdomRecordAction)


rospy.Subscriber('/odom', Odometry, callback)

client.send_goal(goal, feedback_cb=feedback_callback)


if feedback.current_total >= goal.meter:

    print('[Result] State: %d'%(client.get_state()))

and I pass them the action message

float32 meter
geometry_msgs/Point32[] list_of_odoms
float32 current_total

Hi @FranROS99 ,

I am sure that you cannot use as “actions server”. You need to have action server programmed and running. You use as a action client. It is in the name itself.

ax = action
client = client (gui for action calling)
so, => action client gui in python

You must have the action server running and only then you can use Otherwise it will not work.

The code that you have posted is “action client” code, which is clear from the following line:
client = actionlib.SimpleActionClient('/my_action', OdomRecordAction).

Have you written the action server program yet?

Also, it would be better if you use OOP methods for your python program (just making an observation, not enforcing you to do so).


Ah Ok!! . Thank you very much!!.