switched battery topic to mavros::batterystatus

This commit is contained in:
dave 2018-11-18 23:12:36 +01:00
parent e84a24cd54
commit b996694976
2 changed files with 7 additions and 6 deletions

View File

@ -12,7 +12,7 @@
#include "mavros_msgs/SetMode.h" #include "mavros_msgs/SetMode.h"
#include "mavros_msgs/State.h" #include "mavros_msgs/State.h"
#include "mavros_msgs/BatteryStatus.h" #include "mavros_msgs/BatteryStatus.h"
#include "sensor_msgs/BatteryState.h" //#include "sensor_msgs/BatteryState.h"
#include "mavros_msgs/Mavlink.h" #include "mavros_msgs/Mavlink.h"
#include "mavros_msgs/PositionTarget.h" #include "mavros_msgs/PositionTarget.h"
#include "sensor_msgs/NavSatStatus.h" #include "sensor_msgs/NavSatStatus.h"
@ -240,7 +240,7 @@ private:
double gps_r_lat); double gps_r_lat);
/*battery status callback */ /*battery status callback */
void battery(const sensor_msgs::BatteryState::ConstPtr& msg); void battery(const mavros_msgs::BatteryStatus::ConstPtr& msg);
/*flight extended status callback*/ /*flight extended status callback*/
void flight_extended_status_update(const mavros_msgs::ExtendedState::ConstPtr& msg); void flight_extended_status_update(const mavros_msgs::ExtendedState::ConstPtr& msg);

View File

@ -352,7 +352,7 @@ void roscontroller::GetSubscriptionParameters(ros::NodeHandle& node_handle)
m_smTopic_infos.insert(pair<std::string, std::string>(topic, "sensor_msgs/LaserScan")); m_smTopic_infos.insert(pair<std::string, std::string>(topic, "sensor_msgs/LaserScan"));
node_handle.getParam("topics/battery", topic); node_handle.getParam("topics/battery", topic);
m_smTopic_infos.insert(pair<std::string, std::string>(topic, "sensor_msgs/BatteryState")); m_smTopic_infos.insert(pair<std::string, std::string>(topic, "mavros_msgs/BatteryStatus"));
node_handle.getParam("topics/status", topic); node_handle.getParam("topics/status", topic);
m_smTopic_infos.insert(pair<std::string, std::string>(topic, "mavros_msgs/State")); m_smTopic_infos.insert(pair<std::string, std::string>(topic, "mavros_msgs/State"));
@ -504,7 +504,7 @@ void roscontroller::Subscribe(ros::NodeHandle& n_c)
{ {
flight_status_sub = n_c.subscribe(it->first, 5, &roscontroller::flight_status_update, this); flight_status_sub = n_c.subscribe(it->first, 5, &roscontroller::flight_status_update, this);
} }
else if (it->second == "sensor_msgs/BatteryState") else if (it->second == "mavros_msgs/BatteryStatus")
{ {
battery_sub = n_c.subscribe(it->first, 5, &roscontroller::battery, this); battery_sub = n_c.subscribe(it->first, 5, &roscontroller::battery, this);
} }
@ -1035,12 +1035,13 @@ void roscontroller::gps_convert_ned(float& ned_x, float& ned_y, double gps_t_lon
ned_y = DEG2RAD(d_lon) * EARTH_RADIUS * cos(DEG2RAD(gps_t_lat)); ned_y = DEG2RAD(d_lon) * EARTH_RADIUS * cos(DEG2RAD(gps_t_lat));
}; };
void roscontroller::battery(const sensor_msgs::BatteryState::ConstPtr& msg) void roscontroller::battery(const mavros_msgs::BatteryStatus::ConstPtr& msg)
/* /*
/ Update battery status into BVM from subscriber / Update battery status into BVM from subscriber
/------------------------------------------------------*/ /------------------------------------------------------*/
{ {
buzzuav_closures::set_battery(msg->voltage, msg->current, msg->percentage); // buzzuav_closures::set_battery(msg->voltage, msg->current, msg->percentage);
buzzuav_closures::set_battery(msg->voltage, msg->current, msg->remaining*!00.0);
// DEBUG // DEBUG
// ROS_INFO("voltage : %d current : %d remaining : %d",msg->voltage, // ROS_INFO("voltage : %d current : %d remaining : %d",msg->voltage,
// msg->current, msg ->remaining); // msg->current, msg ->remaining);