Acciones en ROS

Hola, estoy realizando el ejercicio 8.6 de la unidad 8 del curso de ROS en 5 dias. Y tengo una duda al mover el drone. Yo lo que hize fue publicar en cmd_vel para poder mover el drone, pero resulta que no me lo mueve. Probe con muchas instrucciones pero no me lo movia. Me fije en las soluciones que dan ustedes pero no entendi porque publican en los topicos /drone/land y /drone/takeoff. ¿Què harian esos topicos? Busque la informacion y vi que tiene un tipo de mensaje vacio por eso quiero saber. Desde ya muchas gracias!!
El còdigo que yo habia hecho antes de ver las soluciones es el siguiente:
#! /usr/bin/env python

import rospy

import time

import actionlib

from ardrone_as.msg import ArdroneAction, ArdroneGoal, ArdroneResult, ArdroneFeedback

from geometry_msgs.msg import Twist

nImage = 1

pub = rospy.Publisher(‘cmd_vel’, Twist, queue_size=1)

move = Twist()

definition of the feedback callback. This will be called when feedback

is received from the action server

it just prints a message indicating a new message has been received

def feedback_callback(feedback):

global nImage

print('[Feedback] image n.%d received'%nImage)

nImage += 1

initializes the action client node

rospy.init_node(‘drone_action_client’)

create the connection to the action server

client = actionlib.SimpleActionClient(’/ardrone_action_server’, ArdroneAction)

waits until the action server is up and running

client.wait_for_server()

creates a goal to send to the action server

goal = ArdroneGoal()

goal.nseconds = 10 # indicates, take pictures along 10 seconds

sends the goal to the action server, specifying which feedback function

to call when feedback received

client.send_goal(goal, feedback_cb=feedback_callback)

Uncomment these lines to test goal preemption:

#time.sleep(3.0)

#client.cancel_goal() # would cancel the goal 3 seconds after starting

wait until the result is obtained

you can do other stuff here instead of waiting

and check for status from time to time

status = client.get_state()

check the client API link below for more info

while client.get_state() < 2:

move.linear.x = 0.5

move.angular.z = 0.5

while pub.get_num_connections() < 1:

    rospy.loginfo("wait to connection")

pub.publish(move)

rospy.sleep(2)

if client.get_state() == 3:

rospy.loginfo("WARN")

if client.get_state() == 4:

rospy.loginfo("ERROR")

move.linear.x = 0

move.angular.z = 0

pub.publish(move)

Estos mensajes están vacíos porque llaman a un servidor en el que hace que el dron despegue. Una vez en el aire, deberías poder moverlo con cmd_vel

1 Like