Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.

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.