Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Drone doesn't stop taking off

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?

click to hide/show revision 2
None

Drone doesn't stop taking off

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?

click to hide/show revision 3
retagged

Drone doesn't stop taking off

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?

click to hide/show revision 4
None

Drone doesn't stop taking off

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/tum_simulator

Drone doesn't stop taking off

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/tum_simulator

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.1415926535897931" />

    <!-- Included URDF Files -->
    <xacro:include filename="$(find cvg_sim_gazebo)/urdf/quadrotor_base.urdf.xacro" />

    <!-- Instantiate quadrotor_base_macro once (has no parameters atm) -->
    <quadrotor_base_macro />


    <!-- Sonar height sensor -->
    <xacro:include filename="$(find cvg_sim_gazebo)/urdf/sensors/sonar_sensor.urdf.xacro" />
    <xacro:sonar_sensor name="sonar" parent="base_link" ros_topic="sonar_height" update_rate="10" min_range="0.01" max_range="3.0" field_of_view="${40*M_PI/180}" ray_count="3">
      <origin xyz="-0.15 0.0 0.0" rpy="0 ${90*M_PI/180} 0"/>
    </xacro:sonar_sensor>


    <!-- Hokuyo UTM-30LX mounted upside down below the quadrotor body 
    <xacro:include filename="$(find cvg_sim_gazebo)/urdf/sensors/hokuyo_utm30lx.urdf.xacro" />
    <xacro:hokuyo_utm30lx name="laser0" parent="base_link" ros_topic="scan" update_rate="40" ray_count="1081" min_angle="135" max_angle="-135">
      <origin xyz="0.0 0.0 0.08" rpy="${M_PI} 0 0"/>
    </xacro:hokuyo_utm30lx>-->

    <!-- The following two cameras should be united to one! -->
    <!-- Forward facing camera -->
    <xacro:include filename="$(find cvg_sim_gazebo)/urdf/sensors/generic_camera.urdf.xacro" />
    <xacro:generic_camera name="front" sim_name="ardrone" parent="base_link" update_rate="60" res_x="640" res_y="360" image_format="R8G8B8" hfov="${81*M_PI/180}">
      <origin xyz="0.21 0.0 0.01" rpy="0 0 0"/>
    </xacro:generic_camera>

    <!-- Downward facing camera -->
    <xacro:include filename="$(find cvg_sim_gazebo)/urdf/sensors/generic_camera.urdf.xacro" />
    <xacro:generic_camera name="bottom" sim_name="ardrone" parent="base_link" update_rate="60" res_x="640" res_y="360" image_format="R8G8B8" hfov="${81*M_PI/180}">
        <origin xyz="0.15 0.0 0.0" rpy="0 ${M_PI/2} 0"/>
    </xacro:generic_camera>

</robot>