AP_VisualOdom_MAV.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. This program is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation, either version 3 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>.
  12. */
  13. #include <AP_HAL/AP_HAL.h>
  14. #include "AP_VisualOdom_MAV.h"
  15. #include <AP_SerialManager/AP_SerialManager.h>
  16. extern const AP_HAL::HAL& hal;
  17. // constructor
  18. AP_VisualOdom_MAV::AP_VisualOdom_MAV(AP_VisualOdom &frontend) :
  19. AP_VisualOdom_Backend(frontend)
  20. {
  21. }
  22. // consume VISIOIN_POSITION_DELTA MAVLink message
  23. void AP_VisualOdom_MAV::handle_msg(const mavlink_message_t &msg)
  24. {
  25. // decode message
  26. mavlink_vision_position_delta_t packet;
  27. mavlink_msg_vision_position_delta_decode(&msg, &packet);
  28. const Vector3f angle_delta(packet.angle_delta[0], packet.angle_delta[1], packet.angle_delta[2]);
  29. const Vector3f position_delta(packet.position_delta[0], packet.position_delta[1], packet.position_delta[2]);
  30. set_deltas(angle_delta, position_delta, packet.time_delta_usec, packet.confidence);
  31. }