Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You created a publisher for the /cmd_vel topic, but you're not using it. You need to publish a speed at which you want to move, in the direction that you want to move using a geometry_msgs::Twist message.

So, in this case you need to set the linear.z to a value greater than 0 and up to1. Once you reach your desired altitude, then publish a geometry_msgs::Twist message with every value (linear.{x,y,z} and angular.{x,y,z}) set to 0 which will enable the auto-hover mode and let your drone hover in (hopefully) one spot. (See the docs for more information about sending commands to your drone).

Again, the Command_directions method needs to publish these commands otherwise you'll see the behavior that you've described. For example,

def Command_directions(self, lin_x=0,lin_y=0,lin_z=0,ang_x=0,ang_y=0,ang_z=0):
        self.Control = Twist()

        self.Control.linear.x = lin_x 
        self.Control.linear.y = lin_y
        self.Control.linear.z = lin_z
        self.Control.angular.x = ang_x
        self.Control.angular.y = ang_y
        self.Control.angular.z = ang_z
        self.command.publish(self.Control) # Add this line