
For understanding the code detail, I draw a diagram to analysis the code.
1. About the data of vehicle_command_ENU_
- 1.1
vehicle_command_ENU_ and vehicle_setpoint_ENU_ only updated in the initialization part, initilaize_setpoint == true.
- 1.2 When each direction of
joy_sp = 0, the vehicle_setpoint_ENU_ is the same as the initialized one and vehicle_command_ENU_ is simply copy position and attitude from vehicle_setpoint_ENU_. So during the real flight, without RC control, the /mavros/setpoint_position/local are same.
2. About the data of vision/pose
It takes these FLU coordinates and transforms them into ENU coordinates (fixed inertial frame) with the target at the origin.
- 2.1 the
vision_pose/pose describes the vehicle position in target-ENU coordinates, whose origin is the current target. This might be means that, when target is moving, the vision_pose/pose should be changed even though the quadrotor is hovering.
- 2.2 In this code snip,
/**
* This function takes the FLU target pose which is relative to the vehicle and transforms it into
* the intertial frame with the vehicle at the origin.
* Possibly a more efficient way to do this with ROS frames
*/
void convertTargetFLUtoENU();
the position of target convert from FLU coordinate (whose origin is the camera ) to ENU coodrinate. As the code comments said, the ENU coodrinate should be the quadrotor-fixed ENU coodrinate.
Then the updateFCULocation() should be get the quadrotor position in target-ENU coodrinate. But when the target_origin_ENU_ is (0, 0, 0), the publish position through vision_pose should be the same as the quadrotor position as above calculated.
- Is the coordinate conversion correct ?
3. About the data of vehicle_current_ENU
vehicle_current_ENU, which describes the local position (fusioned by the vision and IMU information) in ROS-ENU, was calculated from PX4 modules.
4. The whole process

4.1 At T = 0
- the
vehicle_command_ENU_ was set after calculated vision_pose_ when the target was detected.
- the
vehicle_current_ENU should not be (0, 0, 0), because it was calculated during the flight after arming the quadrotor.
4.2 At T = 1
- When the target moved to another position, the related fixed-ROS-ENU coordinate was also changed.
- However, the
vehicle_command_ENU_ was keep the same vector relate to the new ROS-ENU coodrinate.
- The current
/mavros/local_position/local updated as the target_pose_ changed, which is shown in the purple dashed lines.
- As the all
joy_sp=0, the quadrotor should move from the last position to the proposed one, which decpited by green arrow.
I am a little bit confusing about the /mavros/local_position/local. Is the data of this topic mainly influence by /mavros/vision_pose/pose even though fusion with IMU data?
For understanding the code detail, I draw a diagram to analysis the code.
1. About the data of
vehicle_command_ENU_vehicle_command_ENU_andvehicle_setpoint_ENU_only updated in the initialization part, initilaize_setpoint == true.joy_sp = 0, thevehicle_setpoint_ENU_is the same as the initialized one andvehicle_command_ENU_is simply copy position and attitude fromvehicle_setpoint_ENU_. So during the real flight, without RC control, the/mavros/setpoint_position/localare same.2. About the data of
vision/posevision_pose/posedescribes the vehicle position in target-ENU coordinates, whose origin is the current target. This might be means that, when target is moving, thevision_pose/poseshould be changed even though the quadrotor is hovering.the position of target convert from FLU coordinate (whose origin is the camera ) to ENU coodrinate. As the code comments said, the ENU coodrinate should be the quadrotor-fixed ENU coodrinate.
Then the
updateFCULocation()should be get the quadrotor position in target-ENU coodrinate. But when thetarget_origin_ENU_is (0, 0, 0), the publish position throughvision_poseshould be the same as the quadrotor position as above calculated.3. About the data of
vehicle_current_ENUvehicle_current_ENU, which describes the local position (fusioned by the vision and IMU information) in ROS-ENU, was calculated from PX4 modules.4. The whole process
4.1 At
T = 0vehicle_command_ENU_was set after calculatedvision_pose_when the target was detected.vehicle_current_ENUshould not be (0, 0, 0), because it was calculated during the flight after arming the quadrotor.4.2 At
T = 1vehicle_command_ENU_was keep the same vector relate to the new ROS-ENU coodrinate./mavros/local_position/localupdated as thetarget_pose_changed, which is shown in the purple dashed lines.joy_sp=0, the quadrotor should move from the last position to the proposed one, which decpited by green arrow.I am a little bit confusing about the
/mavros/local_position/local. Is the data of this topic mainly influence by/mavros/vision_pose/poseeven though fusion with IMU data?