Hello I am trying to modify the offboard python example in ROS2.
In the example the UAS takeoff using the position passed when is already in offboard mode. What I wish to do is:
- ARM
- TAKEOFF
- OFFBOARD
- Do some stuff
- LAND
At the moment I can ARM with VEHICLE_CMD_COMPONENT_ARM_DISARM, but when I try to takeoff with VEHICLE_CMD_NAV_TAKEOFF on the PX4 simulation terminal (and in QGC) I get:
WARN [navigator] Using minimum takeoff altitude: 2.50 m
This is my command:
self.publish_vehicle_command(VehicleCommand.VEHICLE_CMD_NAV_TAKEOFF,param1=self.vehicle_start_odometry_orientation[1], #desired pitch
param4=self.vehicle_start_odometry_orientation[2],#Yaw angle
param5=self.vehicle_start_global_position[0],#Latitude
param6=self.vehicle_start_global_position[1],#Longitude
param7=self.vehicle_start_global_position[2]+self.takeoff_height)#Altitude
The parameter are taken from the odometry and global position topics:
def vehicle_odometry_callback(self, msg):
"""Callback function for vehicle_odometry_position topic subscriber."""
self.vehicle_odometry_position[0] = msg.position[0]
self.vehicle_odometry_position[1] = -msg.position[1]
self.vehicle_odometry_position[2] = -msg.position[2]
self.vehicle_odometry_orientation=euler_from_quaternion(msg.q[0], msg.q[1], msg.q[2], msg.q[3])
if(self.get_start_ground_position==False):
self.vehicle_start_odometry_position[0] = self.vehicle_odometry_position[0]
self.vehicle_start_odometry_position[1] = self.vehicle_odometry_position[1]
self.vehicle_start_odometry_position[2] = self.vehicle_odometry_position[2]
self.vehicle_start_odometry_orientation = self.vehicle_odometry_orientation
self.get_start_ground_position=True
def vehicle_global_position_callback(self, msg):
"""Callback function for vehicle_global_position topic subscriber."""
self.vehicle_global_position[0] = msg.lat # Latitude, (degrees)
self.vehicle_global_position[1] = msg.lon # Longitude, (degrees)
self.vehicle_global_position[2] = msg.alt # Altitude AMSL, (meters)
if(self.get_start_global_position==False):
self.vehicle_start_global_position[0] = msg.lat # Latitude, (degrees)
self.vehicle_start_global_position[1] = msg.lon # Longitude, (degrees)
self.vehicle_start_global_position[2] = msg.alt # Altitude AMSL, (meters)
self.get_start_global_position=True
And the variable self.takeoff_height is defined as:
self.takeoff_height = -14.0 #m
I have notice that my vehicle is incrementing the altitude by steps of 2.5m, I can stop at the desired height by a simple if, but I can not understand why it did not rise and stop at the defined quote.