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/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 ...
What packages are you using (links are helpful)?
tum simulator: https://github.com/angelsantamaria/tu...
and ros kinetic from the official webpage: http://wiki.ros.org/kinetic/Installation
This is from the original repository of the tum_simulator, but it may be relevant https://github.com/tum-vision/tum_sim...
I added the two mentioned files to my question, but I can't see what's wrong with them.