forked from dji-sdk/Onboard-SDK-ROS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:add get_whole_battery_info service
OSDK-2507
- Loading branch information
Showing
11 changed files
with
198 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
uint8 isFakeSingleBatteryMode | ||
uint8 isSingleBatteryMode | ||
uint8 batteryNotReady # The battery is not ready (the battery has not communicated just after being powered on, | ||
# or has not passed the first battery certification). | ||
uint8 voltageNotSafety # Generally caused by low temperature, the battery has electricity, | ||
# but the battery voltage is too low. | ||
uint8 veryLowVoltageAlarm | ||
uint8 LowVoltageAlarm | ||
uint8 seriousLowCapacityAlarm | ||
uint8 LowCapacityAlarm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
uint16 remainFlyTime | ||
uint16 goHomeNeedTime # Time required for the gohome flight (s) | ||
uint16 landNeedTime # Time required for the land flight (s).max value:100*/ | ||
uint16 goHomeNeedCapacity # Capacity required for the gohome flight (%).max value:100*/ | ||
uint16 landNeedCapacity # Capacity required for the land flight (%).max value:100*/ | ||
float32 safeFlyRadius # Safe flight area radius (m)*/ | ||
float32 capacityConsumeSpeed # (mAh/sec)*/ | ||
BatteryState batteryState | ||
uint8 goHomeCountDownState # Countdown status of smart battery gohome | ||
# 0/2:not in gohome state | ||
# 1 :in gohome state | ||
# | ||
uint8 gohomeCountDownvalue # uint:s.max value:10 | ||
uint16 voltage # mv | ||
uint8 batteryCapacityPercentage # uint:%.max value:100 | ||
uint8 lowBatteryAlarmThreshold | ||
uint8 lowBatteryAlarmEnable | ||
uint8 seriousLowBatteryAlarmThreshold | ||
uint8 seriousLowBatteryAlarmEnable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** @file battery_node.cpp | ||
* @version 4.1 | ||
* @date Dec 2020 | ||
* | ||
* @brief sample node of battery. | ||
* | ||
* @Copyright (c) 2020 DJI | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
*/ | ||
|
||
#include <ros/ros.h> | ||
#include <dji_osdk_ros/dji_vehicle_node.h> | ||
|
||
const uint8_t MAX_TIME_COUNT = 50; | ||
int main(int argc, char** argv) | ||
{ | ||
ros::init(argc, argv, "battery_node"); | ||
ros::NodeHandle nh; | ||
uint8_t time_count = 0; | ||
|
||
auto get_whole_battery_info = nh.serviceClient<dji_osdk_ros::GetWholeBatteryInfo>("get_whole_battery_info"); | ||
|
||
dji_osdk_ros::GetWholeBatteryInfo getWholeBatteryInfo; | ||
while (time_count < MAX_TIME_COUNT) | ||
{ | ||
get_whole_battery_info.call(getWholeBatteryInfo); | ||
ROS_INFO("(It's valid only for M210V2)batteryCapacityPercentage is %d",getWholeBatteryInfo.response.battery_whole_info.batteryCapacityPercentage); | ||
ROS_INFO("(It's valid only for M210V2)remainFlyTime is %d",getWholeBatteryInfo.response.battery_whole_info.remainFlyTime); | ||
ROS_INFO("(It's valid only for M210V2)goHomeNeedTime is %d",getWholeBatteryInfo.response.battery_whole_info.goHomeNeedTime); | ||
ROS_INFO("(It's valid only for M210V2)landNeedTime is %d",getWholeBatteryInfo.response.battery_whole_info.landNeedTime); | ||
ROS_INFO("(It's valid only for M210V2)goHomeNeedCapacity is %d",getWholeBatteryInfo.response.battery_whole_info.goHomeNeedCapacity); | ||
ROS_INFO("(It's valid only for M210V2)landNeedCapacity is %d",getWholeBatteryInfo.response.battery_whole_info.landNeedCapacity); | ||
ROS_INFO("(It's valid only for M210V2)safeFlyRadius is %f",getWholeBatteryInfo.response.battery_whole_info.safeFlyRadius); | ||
ROS_INFO("(It's valid only for M210V2)capacityConsumeSpeed is %f",getWholeBatteryInfo.response.battery_whole_info.capacityConsumeSpeed); | ||
ROS_INFO("(It's valid only for M210V2)goHomeCountDownState is %d",getWholeBatteryInfo.response.battery_whole_info.goHomeCountDownState); | ||
ROS_INFO("(It's valid only for M210V2)gohomeCountDownvalue is %d",getWholeBatteryInfo.response.battery_whole_info.gohomeCountDownvalue); | ||
ROS_INFO("(It's valid only for M210V2)voltage is %ld",getWholeBatteryInfo.response.battery_whole_info.voltage); | ||
ROS_INFO("(It's valid only for M210V2)lowBatteryAlarmThreshold is %d",getWholeBatteryInfo.response.battery_whole_info.lowBatteryAlarmThreshold); | ||
ROS_INFO("(It's valid only for M210V2)lowBatteryAlarmEnable is %d",getWholeBatteryInfo.response.battery_whole_info.lowBatteryAlarmEnable); | ||
ROS_INFO("(It's valid only for M210V2)seriousLowBatteryAlarmThreshold is %d",getWholeBatteryInfo.response.battery_whole_info.seriousLowBatteryAlarmThreshold); | ||
ROS_INFO("(It's valid only for M210V2)seriousLowBatteryAlarmEnable is %d",getWholeBatteryInfo.response.battery_whole_info.seriousLowBatteryAlarmEnable); | ||
ROS_INFO("(It's valid only for M210V2)isFakeSingleBatteryMode is %d",getWholeBatteryInfo.response.battery_whole_info.batteryState.isFakeSingleBatteryMode); | ||
ROS_INFO("(It's valid only for M210V2)isSingleBatteryMode is %d",getWholeBatteryInfo.response.battery_whole_info.batteryState.isSingleBatteryMode); | ||
ROS_INFO("(It's valid only for M210V2)batteryNotReady is %d",getWholeBatteryInfo.response.battery_whole_info.batteryState.batteryNotReady); | ||
ROS_INFO("(It's valid only for M210V2)voltageNotSafety is %d",getWholeBatteryInfo.response.battery_whole_info.batteryState.voltageNotSafety); | ||
ROS_INFO("(It's valid only for M210V2)veryLowVoltageAlarm is %d",getWholeBatteryInfo.response.battery_whole_info.batteryState.veryLowVoltageAlarm); | ||
ROS_INFO("(It's valid only for M210V2)LowVoltageAlarm is %d",getWholeBatteryInfo.response.battery_whole_info.batteryState.LowVoltageAlarm); | ||
ROS_INFO("(It's valid only for M210V2)seriousLowCapacityAlarm is %d",getWholeBatteryInfo.response.battery_whole_info.batteryState.seriousLowCapacityAlarm); | ||
ROS_INFO("(It's valid only for M210V2)LowCapacityAlarm is %d",getWholeBatteryInfo.response.battery_whole_info.batteryState.LowCapacityAlarm); | ||
|
||
ros::Duration(0.2).sleep(); | ||
time_count++; | ||
} | ||
|
||
ROS_INFO_STREAM("Finished. Press CTRL-C to terminate the node"); | ||
|
||
ros::spin(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#request | ||
--- | ||
#response | ||
BatteryWholeInfo battery_whole_info |