Ask Your Question

Difficulty getting hector quadrotor actions to work

asked 2020-05-21 09:12:13 -0500

Ganach9 gravatar image


I've been working with the hector_quadrotor package on ROS Melodic with Ubuntu 18.04 and I wanted to write a node that would move multiple drones from point to point simultaneously. I saw that the package has an action server called PoseAction that I want to use to send these commands, but I am unfamiliar with using actions. I've read the Turtlebot move_base tutorial and this is what my code looks like right now:

import rospy
import time
import random
from hector_uav_msgs.srv import EnableMotors
from geometry_msgs.msg import PoseStamped
import actionlib
import hector_uav_msgs.msg

def hector_pose_client():
     # First enable motor service
     enabler1 = rospy.ServiceProxy("/drone1/enable_motors", EnableMotors)
     resp1 = enabler1(True)

     rospy.loginfo("Creating Action Client.")
     client = actionlib.SimpleActionClient('/drone1/pose_action', hector_uav_msgs.msg.PoseAction)
     rospy.loginfo("Client created.")

     # This is where the program seems to hang even though I assumed hector would automatically run the action server

     # Create a random goal
     g = hector_uav_msgs.msg.PoseGoal()
     g.target_pose.header.frame_id = 'drone1/world'
     g.target_pose.pose.position.x = random.randint(-5, 5)
     g.target_pose.pose.position.y = random.randint(-5, 5)
     g.target_pose.pose.position.z = 3

     rospy.loginfo("Sending goal")

if __name__ == "__main__":
         result = hector_pose_client()
         rospy.loginfo("Client navigated")
     except rospy.ROSInterruptException:
         print("program interrupted before completion", file=sys.stderr)

I've checked rqt_graph and my node does show up but it doesn't appear to have a link to /drone1/action. How would I fix the hang on waiting for the server? Am I using incorrect syntax?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-05-21 09:34:39 -0500

Ganach9 gravatar image

I solved the issue on my own. I was using the wrong name for the action server. Instead when creating the client, it should be:

client = actionlib.SimpleActionClient('/drone1/action/pose', hector_uav_msgs.msg.PoseAction)

It started working immediately after

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


Asked: 2020-05-21 09:12:13 -0500

Seen: 288 times

Last updated: May 21 '20