Skip to content

Commit

Permalink
fix (hack) a problem in quaternion issue using QuadStateEstiamte
Browse files Browse the repository at this point in the history
  • Loading branch information
yun-long committed Sep 1, 2020
1 parent adb07d9 commit 12a90eb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions flightlib/src/common/math.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "flightlib/common/math.hpp"
#include "iostream"

namespace flightlib {

Expand Down
1 change: 0 additions & 1 deletion flightros/include/flightros/flight_pilot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class FlightPilot {
uint16_t receive_id_{0};

// auxiliary variables
quadrotor_common::QuadStateEstimate state_est_;
Scalar main_loop_freq_{50.0};
};
} // namespace flightros
2 changes: 1 addition & 1 deletion flightros/launch/rotors_gazebo.launch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<arg name="model" value="$(find rotors_description)/urdf/mav_generic_odometry_sensor.gazebo"/>
<arg name="world_name" default="$(find rotors_gazebo)/worlds/basic.world"/>

<arg name="use_unity_editor" value="false" />
<arg name="use_unity_editor" default="true" />
<arg name="paused" value="true"/>
<arg name="gui" value="true"/>
<arg name="use_mpc" default="false"/>
Expand Down
12 changes: 8 additions & 4 deletions flightros/src/flight_pilot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ FlightPilot::FlightPilot(const ros::NodeHandle &nh, const ros::NodeHandle &pnh)
FlightPilot::~FlightPilot() {}

void FlightPilot::poseCallback(const nav_msgs::Odometry::ConstPtr &msg) {
state_est_ = quadrotor_common::QuadStateEstimate(*msg);

quad_state_.p = state_est_.position.cast<Scalar>();
quad_state_.qx = state_est_.orientation.coeffs().cast<Scalar>();
quad_state_.x[QS::POSX] = (Scalar)msg->pose.pose.position.x;
quad_state_.x[QS::POSY] = (Scalar)msg->pose.pose.position.y;
quad_state_.x[QS::POSZ] = (Scalar)msg->pose.pose.position.z;
quad_state_.x[QS::ATTW] = (Scalar)msg->pose.pose.orientation.w;
quad_state_.x[QS::ATTX] = (Scalar)msg->pose.pose.orientation.x;
quad_state_.x[QS::ATTY] = (Scalar)msg->pose.pose.orientation.y;
quad_state_.x[QS::ATTZ] = (Scalar)msg->pose.pose.orientation.z;
//
quad_ptr_->setState(quad_state_);

if (unity_render_ && unity_ready_) {
Expand Down

0 comments on commit 12a90eb

Please sign in to comment.