ROS Basic Real Robot proyect

Hi, I’m finishing making the client for the project’s action server, and when I run to start the action server with rosrun actionlib_tools axclient.py /my_action(which would be the name I want to give my action server), I get throws an error that is the following:


here I leave the code that I made

#! /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

feedback.current_total = 0

result.list_of_odoms = []

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

    rospy.sleep(1)

def feedback_callback(msg):
    global feedback.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)
    

rospy.init_node('odometria_robot')

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

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

client.wait_for_server()

client.send_goal(goal, feedback_cb=feedback_callback)

if feedback.current_total == goal.meter:
    client.wait_for_result()

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

Hi @FranROS99 ,

I believe you are working on the course project (rosject) for ROS Basics in 5 Days with Python.

From my understanding of the project instructions, you would not require a subscriber for Odometry in the action client program.

Are you sure you are having your /my_action service server initialized and running? Because running a client without service will not work or give error (stating the service is not available or something similar).

You need to assign this to a variable, say odom_sub = ...

You seem a little confused (I guess).

Will the server return the response immediately once current_total == goal.meter?
I think you must use >= rather than ==. You have declared goal.meter = 10 which is a rounded (whole) number. While simulation it could be something like 9.89 and then jump straight to 10.02. So the value will never be strictly 10.

This line, I believe, must be on the server side.

The client has only three functions:
0. Wait for server to become active/online. (This is one of the important steps for action client to work, so step 0).

  1. Call the goal by sending the goal to the server.
  2. Keep getting feedback messages.
  3. Report the result when complete.

The errors you are getting seems to be associated with axclient.py. I believe from the last line of the error that the Goal message that it receives seems to be a NoneType.
When you are using the axclient.py program, are you typing in 10 in the textbox and clicking on send goal button? Probably you are just clicking on the send goal button without filling in the Goal textbox.

Could you please share a picture of how you are using axclient.py? That would help find the cause of your error.

Also could you please share your action message file contents?

Regards,
Girish

1 Like

Yes, now I send you, with respect to axclient.py I use it like this:
Captura de pantalla 2022-11-07 103433
and the structure of the action message:
Captura de pantalla 2022-11-07 103625

Hi @FranROS99 ,

This is the command with which you start axclient.py from terminal.

I would like to see what you do with the axclient GUI. Please send me a picture of your axclient GUI before you click “Send Goal” button on the GUI.

– Girish

@FranROS99 ,

You can directly specify int32 datatype as int32 meter. You do not have to define it as std_msgs/Int32.
Also, it would be better (and easy) if you make meter as float32 and not int32.
Subsequently, you can make goal.meter = 10.0 in your code to reflect the change from int to float. Unlike C++, Python will intrinsically convert int to float when required.
And in the axclient GUI, you can send the goal as 10.0.

– Girish

ok, thank you very much