Ask Your Question
1

Drone doesn't stop taking off

asked 2017-08-30 13:57:15 -0600

patricia gravatar image

updated 2017-08-31 05:03:37 -0600

Hi,

my problem is that after I send a takeoff message to my drone (in gazebo) it doesn't stop taking off. It keeps moving upwards until I publish to land topic. I would like it to hover in place or at least fly forward WITHOUT FLYING UP. I couldn't find any command to stop takeoff.

This is an example of a script that I've tried (takeoff than hover and finally land):

if __name__ == '__main__':
    try:
        rospy.init_node('fly_x_meters', anonymous=True)
        rate = rospy.Rate(10)  # 10hz
        pub_takeoff = rospy.Publisher("ardrone/takeoff", Empty, queue_size=1)
        pub_land = rospy.Publisher("ardrone/land", Empty, queue_size=1)
        pub_twist = rospy.Publisher("cmd_vel", Twist, queue_size=1)
        pub_reset = rospy.Publisher("ardrone/reset", Empty, queue_size=10)

        hover_msg = Twist()
        hover_msg.linear.x = 0
        hover_msg.linear.y = 0
        hover_msg.linear.z = 0
        hover_msg.angular.x = 0
        hover_msg.angular.y = 0
        hover_msg.angular.z = 0

        # starts simulated clock
        while rospy.get_time() == 0:
            rospy.get_time()

        start_time = rospy.get_time()
        print(start_time)

        while not rospy.is_shutdown():
            print(rospy.get_time())
            if rospy.get_time() < start_time+3.0:
                pub_takeoff.publish(Empty())
                pub_twist.publish(hover_msg)
            elif rospy.get_time() > start_time+10.0:
                pub_reset.publish(Empty())
                break
            elif rospy.get_time() > start_time+8.0:
                pub_twist.publish(hover_msg)
                pub_land.publish(Empty())
            else:
                pub_twist.publish(hover_msg)
            rate.sleep()

    except rospy.ROSInterruptException:
        pass

In navdata topic I only get two states during running this script: 2-takeoff and 6-land. No hover or fly.

I tried publishing only once to takeoff, latching, nothing helped. I tried flying forward/rotating instead of hovering, but it still keeps moving up (while moving forward). I'm new to ROS, sorry if it's a dumb question, but could anybody help me, please?

Note: using https://github.com/angelsantamaria/tu...

My spawn_quadrotor.launch file:

 <launch>
   <arg name="model" default="$(find cvg_sim_gazebo)/urdf/quadrotor.urdf.xacro"/>
   <arg name="x" default="0"/>
   <arg name="y" default="0"/>
   <arg name="z" default="0.5"/>
   <arg name="R" default="0"/>
   <arg name="P" default="0"/>
   <arg name="Y" default="0"/>
   <!-- send the robot XML to param server -->
   <param name="robot_description" command="$(find xacro)/xacro.py '$(arg model)' --inorder" />

   <!-- push robot_description to factory and spawn robot in gazebo -->
   <node name="spawn_robot" pkg="gazebo_ros" type="spawn_model"
   args="-param robot_description
   -urdf
   -x '$(arg x)'
   -y '$(arg y)'
   -z '$(arg z)'
   -R '$(arg R)'
   -P '$(arg P)'
   -Y '$(arg Y)'
   -model quadrotor"
     respawn="false" output="screen"/>

   <!-- start robot state publisher -->
   <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher" output="screen" >
     <param name="publish_frequency" type="double" value="50.0" />
     <param name="tf_prefix" type="string" value="" />
   </node>

   <node name="ground_truth_to_tf" pkg="message_to_tf" type="message_to_tf" output="screen">
     <param name="odometry_topic" value="ground_truth/state" />
     <param name="frame_id" value="nav" />
   </node>
   <!-- node name="hector_pose_estimation" pkg="hector_pose_estimation" type="hector_pose_estimation_node" output="screen"/-->

 </launch>

My quadrotor_sensors.urdf.xacro file:

<?xml version="1.0"?>

<robot name="quadrotor_hokuyo_utm30lx"
xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"
xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"
xmlns:xacro="http://ros.org/wiki/xacro"
xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface">

    <xacro:property name="M_PI" value="3 ...
(more)
edit retag flag offensive close merge delete

Comments

What packages are you using (links are helpful)?

jayess gravatar imagejayess ( 2017-08-30 14:26:45 -0600 )edit

tum simulator: https://github.com/angelsantamaria/tu...

and ros kinetic from the official webpage: http://wiki.ros.org/kinetic/Installation

patricia gravatar imagepatricia ( 2017-08-30 14:49:55 -0600 )edit

This is from the original repository of the tum_simulator, but it may be relevant https://github.com/tum-vision/tum_sim...

jayess gravatar imagejayess ( 2017-08-30 16:55:57 -0600 )edit

I added the two mentioned files to my question, but I can't see what's wrong with them.

patricia gravatar imagepatricia ( 2017-08-31 05:04:57 -0600 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2017-09-15 08:28:56 -0600

patricia gravatar image

Amazing! Thank you mahe_antoine! :)

I tried installing some hector packages that seemed relevant to me, to be precise I did this:

sudo apt-get install ros-kinetic-hector-gazebo
sudo apt-get install ros-kinetic-hector-sensors-gazebo
sudo apt-get install ros-kinetic-hector-xacro-tools

Not sure which one, but one of them must have fixed it because it works perfectly now :)

edit flag offensive delete link more
0

answered 2017-08-31 12:58:07 -0600

jayess gravatar image

updated 2017-09-01 11:43:13 -0600

I believe that the issues is with the following block of code:

elif rospy.get_time() > start_time+10.0:
    pub_reset.publish(Empty())
    break

The reset topic probably doesn't do what you think it does. It resets the odometry making the drone think that it's on the ground. So, with that in mind this behavior of never stopping taking off actually makes sense. It always thinks that it's on the ground (at this point) and just stays in the takeoff state (or, whatever it's called) and keeps trying to reach it's takeoff altitude.

If you want to have the drone hover, instead of publishing to the reset topic you need to publish empty Twist() messages to the cmd_vel topic. According to the docs:

Hover Modes

geometry_msgs::Twist has two other member variables angular.x and angular.y which can be used to enable/disable “auto-hover” mode. “auto-hover” is enabled when all six components are set to zero.


Edit:

I tried looking for a parameter to set that would change the takeoff altitude, but couldn't find one. I looked back at my own code and realized that I was just pushing the drone to my desired altitude. I also experienced issues with getting the drone to takeoff (with a real drone, however) so I made a work around like this

for i in range(51):
    takeoff.launch()
    rate.sleep()

which for some reason worked. Once you're up in the air continue pushing the drone to your desired height by publishing a Twist message with the desired velocity and then stopping once you reach your target altitude.

Thinking back (I was using the AR.Drone 2.0 just over a year ago) we stopped using the simulator because of an issue just like this and we needed the tag that came with the drone. So, this may or may not work for you.

edit flag offensive delete link more

Comments

I understand where you're heading, but this code doesn't get called until after the drone landed so it is already in the landing state. My code first publishes takeoff for 3 secs, then hover (exactly the message you described), then land, and THEN reset, so I believe this doesn't affect takeoff.

patricia gravatar imagepatricia ( 2017-08-31 17:22:55 -0600 )edit

You mentioned takeoff altitude, is there a way to set it? Could it be that it is set to be too high or something?? Because until now I just assumed the drone will stop takeoff when I stop publishing to the takeoff topic...

patricia gravatar imagepatricia ( 2017-08-31 17:25:32 -0600 )edit

it doesn't work for me...however, I found out that although I initialize sonar sensor, nothing gets published to /sonar_height topic - so I guess there must be some problem with the sensor...I'll keep looking...

patricia gravatar imagepatricia ( 2017-09-11 10:19:04 -0600 )edit

Hi, I used to have the same problem, I solved it by installing a missing ros package. Sadly I don't remember the package name but I think it was part of the hector_quadrotor packages.

mahe_antoine gravatar imagemahe_antoine ( 2017-09-14 08:52:39 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2017-08-30 13:57:15 -0600

Seen: 989 times

Last updated: Sep 15 '17