Hello, I ask you a question, I am making an actions client in which the actions server is going to be axclient.py. 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 axclient.py 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])
rospy.sleep(1)
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)
rospy.init_node('odometria_robot')
client = actionlib.SimpleActionClient('/my_action', OdomRecordAction)
client.wait_for_server()
rospy.Subscriber('/odom', Odometry, callback)
client.send_goal(goal, feedback_cb=feedback_callback)
rospy.sleep(1)
if feedback.current_total >= goal.meter:
client.wait_for_result()
print(result.list_of_odoms)
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