Skip to content

Commit

Permalink
Rename variables for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
BillThePlatypus committed Sep 17, 2019
1 parent 31145dc commit 3401adf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions rosplane/include/estimator_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,25 @@ class estimator_base
ros::NodeHandle nh_;
ros::NodeHandle nh_private_;
ros::Publisher vehicle_state_pub_;
ros::Subscriber nav_sat_fix_sub_;
ros::Subscriber twist_stamped_sub_; //used in conjunction with the nav_sat_fix_sub_
ros::Subscriber gnss_fix_sub_;
ros::Subscriber gnss_vel_sub_; //used in conjunction with the gnss_fix_sub_
ros::Subscriber imu_sub_;
ros::Subscriber baro_sub_;
ros::Subscriber airspeed_sub_;
ros::Subscriber status_sub_;

void update(const ros::TimerEvent &);
void navSatFixCallback(const sensor_msgs::NavSatFix &msg);
void twistStampedCallback(const geometry_msgs::TwistStamped &msg);
void gnssFixCallback(const sensor_msgs::NavSatFix &msg);
void gnssVelCallback(const geometry_msgs::TwistStamped &msg);
void imuCallback(const sensor_msgs::Imu &msg);
void baroAltCallback(const rosflight_msgs::Barometer &msg);
void airspeedCallback(const rosflight_msgs::Airspeed &msg);
void statusCallback(const rosflight_msgs::Status &msg);

double update_rate_;
ros::Timer update_timer_;
std::string gps_topic_;
std::string vel_topic_;
std::string gnss_fix_topic_;
std::string gnss_vel_topic_;
std::string imu_topic_;
std::string baro_topic_;
std::string airspeed_topic_;
Expand Down
14 changes: 7 additions & 7 deletions rosplane/src/estimator_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ estimator_base::estimator_base():
nh_(ros::NodeHandle()),
nh_private_(ros::NodeHandle("~"))
{
nh_private_.param<std::string>("gps_topic", gps_topic_, "navsat_compat/fix");
nh_private_.param<std::string>("vel_topic", vel_topic_, "navsat_compat/vel");
nh_private_.param<std::string>("gps_topic", gnss_fix_topic_, "navsat_compat/fix");
nh_private_.param<std::string>("vel_topic", gnss_vel_topic_, "navsat_compat/vel");
nh_private_.param<std::string>("imu_topic", imu_topic_, "imu/data");
nh_private_.param<std::string>("baro_topic", baro_topic_, "baro");
nh_private_.param<std::string>("airspeed_topic", airspeed_topic_, "airspeed");
Expand All @@ -25,8 +25,8 @@ estimator_base::estimator_base():
nh_private_.param<double>("sigma_Vg_gps", params_.sigma_Vg_gps, 0.0500);
nh_private_.param<double>("sigma_couse_gps", params_.sigma_course_gps, 0.0045);

nav_sat_fix_sub_ = nh_.subscribe(gps_topic_, 10, &estimator_base::navSatFixCallback, this);
twist_stamped_sub_ = nh_.subscribe(vel_topic_, 10, &estimator_base::twistStampedCallback, this);
gnss_fix_sub_ = nh_.subscribe(gnss_fix_topic_, 10, &estimator_base::gnssFixCallback, this);
gnss_vel_sub_ = nh_.subscribe(gnss_vel_topic_, 10, &estimator_base::gnssVelCallback, this);
imu_sub_ = nh_.subscribe(imu_topic_, 10, &estimator_base::imuCallback, this);
baro_sub_ = nh_.subscribe(baro_topic_, 10, &estimator_base::baroAltCallback, this);
airspeed_sub_ = nh_.subscribe(airspeed_topic_, 10, &estimator_base::airspeedCallback, this);
Expand Down Expand Up @@ -95,7 +95,7 @@ void estimator_base::update(const ros::TimerEvent &)
vehicle_state_pub_.publish(msg);
}

void estimator_base::navSatFixCallback(const sensor_msgs::NavSatFix &msg)
void estimator_base::gnssFixCallback(const sensor_msgs::NavSatFix &msg)
{
bool has_fix = msg.status.status >= sensor_msgs::NavSatStatus::STATUS_FIX; // Higher values refer to augmented fixes
if (!has_fix || !std::isfinite(msg.latitude))
Expand All @@ -118,13 +118,13 @@ void estimator_base::navSatFixCallback(const sensor_msgs::NavSatFix &msg)
input_.gps_new = true;
}
}
void estimator_base::twistStampedCallback(const geometry_msgs::TwistStamped &msg)
void estimator_base::gnssVelCallback(const geometry_msgs::TwistStamped &msg)
{
double v_n = msg.twist.linear.x;
double v_e = msg.twist.linear.y;
double v_d = msg.twist.linear.z;
double ground_speed = sqrt(v_n * v_n + v_e * v_e);
double course = atan2(v_e, v_n); //TODO check this math. Also, degrees or radians. From North, right? What range?
double course = atan2(v_e, v_n); //Does this need to be in a specific range? All uses seem to accept anything.
input_.gps_Vg = ground_speed;
if(ground_speed > 0.3) //this is a magic number. What is it determined from?
input_.gps_course = course;
Expand Down

0 comments on commit 3401adf

Please sign in to comment.