Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sensor_msgs::BatteryState percentage with a negative value #1284

Closed
FaboNo opened this issue Jul 27, 2019 · 4 comments
Closed

sensor_msgs::BatteryState percentage with a negative value #1284

FaboNo opened this issue Jul 27, 2019 · 4 comments

Comments

@FaboNo
Copy link

FaboNo commented Jul 27, 2019

This is only bug and feature tracker, please use it
to report bugs or request features.


Issue details

Please describe the problem, or desired feature
When I am reading the battery status (/mavros/battery -- see below) I noticed that the percentage value is always small and negative. However in the documentation this value should be between 0 and 1. Can you tell me what is missing? Thank you

  seq: 216
  stamp: 
    secs: 1528206242
    nsecs: 464688044
  frame_id: ''
voltage: 65.5350036621
current: 0.00999999977648
charge: nan
capacity: nan
design_capacity: nan
percentage: -0.00999999977648
power_supply_status: 2
power_supply_health: 0
power_supply_technology: 3
present: True
cell_voltage: []
location: "id0"
serial_number: ''
---
header: 
  seq: 217
  stamp: 
    secs: 1528206242
    nsecs: 665512459
  frame_id: ''
voltage: 65.5350036621
current: 0.00999999977648
charge: nan
capacity: nan
design_capacity: nan
percentage: -0.00999999977648
power_supply_status: 2
power_supply_health: 0
power_supply_technology: 3
present: True
cell_voltage: []
location: "id0"
serial_number: ''

I added a screenshot of the px4 parameters associated with the battery in case I missed something?

batrery_params

MAVROS version and platform

Mavros: ?0.18.4?
ROS: ?Kinetic?
Ubuntu: ?16.04?

Autopilot type and version

[ ] ArduPilot
[ x ] PX4

Version: ?3.7.1?

Node logs

copy output of mavros_node. Usually console where you run roslaunch

SUMMARY
========

CLEAR PARAMETERS
 * /mavros/

PARAMETERS
 * /mavros/cmd/use_comp_id_system_control: False
 * /mavros/conn/heartbeat_rate: 1.0
 * /mavros/conn/system_time_rate: 0.0
 * /mavros/conn/timeout: 10.0
 * /mavros/conn/timesync_rate: 0.0
 * /mavros/distance_sensor/rangefinder_pub/field_of_view: 0.0
 * /mavros/distance_sensor/rangefinder_pub/frame_id: lidar
 * /mavros/distance_sensor/rangefinder_pub/id: 0
 * /mavros/distance_sensor/rangefinder_pub/send_tf: False
 * /mavros/distance_sensor/rangefinder_pub/sensor_position/x: 0.0
 * /mavros/distance_sensor/rangefinder_pub/sensor_position/y: 0.0
 * /mavros/distance_sensor/rangefinder_pub/sensor_position/z: -0.1
 * /mavros/distance_sensor/rangefinder_sub/id: 1
 * /mavros/distance_sensor/rangefinder_sub/orientation: PITCH_270
 * /mavros/distance_sensor/rangefinder_sub/subscriber: True
 * /mavros/fake_gps/eph: 2.0
 * /mavros/fake_gps/epv: 2.0
 * /mavros/fake_gps/fix_type: 3
 * /mavros/fake_gps/geo_origin/alt: 408.0
 * /mavros/fake_gps/geo_origin/lat: 47.3667
 * /mavros/fake_gps/geo_origin/lon: 8.55
 * /mavros/fake_gps/gps_rate: 5.0
 * /mavros/fake_gps/mocap_transform: True
 * /mavros/fake_gps/satellites_visible: 5
 * /mavros/fake_gps/tf/child_frame_id: fix
 * /mavros/fake_gps/tf/frame_id: map
 * /mavros/fake_gps/tf/listen: False
 * /mavros/fake_gps/tf/rate_limit: 10.0
 * /mavros/fake_gps/tf/send: False
 * /mavros/fake_gps/use_mocap: True
 * /mavros/fake_gps/use_vision: False
 * /mavros/fcu_protocol: v2.0
 * /mavros/fcu_url: /dev/ttyPIXEXT:92...
 * /mavros/gcs_url: 
 * /mavros/global_position/child_frame_id: base_link
 * /mavros/global_position/frame_id: map
 * /mavros/global_position/rot_covariance: 99999.0
 * /mavros/global_position/tf/child_frame_id: base_link
 * /mavros/global_position/tf/frame_id: map
 * /mavros/global_position/tf/global_frame_id: earth
 * /mavros/global_position/tf/send: False
 * /mavros/global_position/use_relative_alt: True
 * /mavros/image/frame_id: px4flow
 * /mavros/imu/angular_velocity_stdev: 0.000349065850399
 * /mavros/imu/frame_id: base_link
 * /mavros/imu/linear_acceleration_stdev: 0.0003
 * /mavros/imu/magnetic_stdev: 0.0
 * /mavros/imu/orientation_stdev: 1.0
 * /mavros/local_position/frame_id: map
 * /mavros/local_position/tf/child_frame_id: base_link
 * /mavros/local_position/tf/frame_id: map
 * /mavros/local_position/tf/send: False
 * /mavros/local_position/tf/send_fcu: False
 * /mavros/mission/pull_after_gcs: True
 * /mavros/mocap/use_pose: True
 * /mavros/mocap/use_tf: False
 * /mavros/odometry/estimator_type: 3
 * /mavros/odometry/frame_tf/desired_frame: ned
 * /mavros/plugin_blacklist: ['actuator_contro...
 * /mavros/plugin_whitelist: []
 * /mavros/px4flow/frame_id: px4flow
 * /mavros/px4flow/ranger_fov: 0.118682389136
 * /mavros/px4flow/ranger_max_range: 5.0
 * /mavros/px4flow/ranger_min_range: 0.3
 * /mavros/safety_area/p1/x: 1.0
 * /mavros/safety_area/p1/y: 1.0
 * /mavros/safety_area/p1/z: 1.0
 * /mavros/safety_area/p2/x: -1.0
 * /mavros/safety_area/p2/y: -1.0
 * /mavros/safety_area/p2/z: -1.0
 * /mavros/setpoint_accel/send_force: False
 * /mavros/setpoint_attitude/reverse_thrust: False
 * /mavros/setpoint_attitude/tf/child_frame_id: target_attitude
 * /mavros/setpoint_attitude/tf/frame_id: map
 * /mavros/setpoint_attitude/tf/listen: False
 * /mavros/setpoint_attitude/tf/rate_limit: 50.0
 * /mavros/setpoint_attitude/use_quaternion: False
 * /mavros/setpoint_position/mav_frame: LOCAL_NED
 * /mavros/setpoint_position/tf/child_frame_id: target_position
 * /mavros/setpoint_position/tf/frame_id: map
 * /mavros/setpoint_position/tf/listen: False
 * /mavros/setpoint_position/tf/rate_limit: 50.0
 * /mavros/setpoint_velocity/mav_frame: LOCAL_NED
 * /mavros/startup_px4_usb_quirk: False
 * /mavros/sys/disable_diag: False
 * /mavros/sys/min_voltage: 10.0
 * /mavros/target_component_id: 1
 * /mavros/target_system_id: 1
 * /mavros/tdr_radio/low_rssi: 40
 * /mavros/time/time_ref_source: fcu
 * /mavros/time/timesync_avg_alpha: 0.6
 * /mavros/time/timesync_mode: NONE
 * /mavros/vibration/frame_id: base_link
 * /mavros/vision_pose/tf/child_frame_id: vision_estimate
 * /mavros/vision_pose/tf/frame_id: map
 * /mavros/vision_pose/tf/listen: False
 * /mavros/vision_pose/tf/rate_limit: 10.0
 * /mavros/vision_speed/listen_twist: False
 * /rosdistro: kinetic
 * /rosversion: 1.12.12

NODES
  /
    mavros (mavros/mavros_node)

ROS_MASTER_URI=http://localhost:11311

process[mavros-1]: started with pid [1799]
[ INFO] [1528206344.692588039]: FCU URL: /dev/ttyPIXEXT:921600
[ INFO] [1528206344.694921613]: serial0: device: /dev/ttyPIXEXT @ 921600 bps
[ INFO] [1528206344.695710559]: GCS bridge disabled
[ INFO] [1528206344.706214005]: Plugin 3dr_radio loaded
[ INFO] [1528206344.709356631]: Plugin 3dr_radio initialized
[ INFO] [1528206344.709494584]: Plugin actuator_control blacklisted
[ INFO] [1528206344.712332662]: Plugin adsb loaded
[ INFO] [1528206344.810406399]: Plugin adsb initialized
[ INFO] [1528206344.810668325]: Plugin altitude loaded
[ INFO] [1528206344.853897936]: Plugin altitude initialized
[ INFO] [1528206344.854124649]: Plugin cam_imu_sync loaded
[ INFO] [1528206344.868517022]: Plugin cam_imu_sync initialized
[ INFO] [1528206344.868802633]: Plugin command loaded
[ INFO] [1528206345.023582253]: Plugin command initialized
[ INFO] [1528206345.023621549]: Plugin debug_value blacklisted
[ INFO] [1528206345.023896984]: Plugin distance_sensor loaded
[ INFO] [1528206345.367085740]: Plugin distance_sensor initialized
[ INFO] [1528206345.367292275]: Plugin fake_gps loaded
[ INFO] [1528206345.993291161]: Plugin fake_gps initialized
[ INFO] [1528206345.993324904]: Plugin ftp blacklisted
[ INFO] [1528206345.993495177]: Plugin global_position loaded
[ INFO] [1528206346.418543139]: Plugin global_position initialized
[ INFO] [1528206346.418593133]: Plugin hil blacklisted
[ INFO] [1528206346.418909048]: Plugin home_position loaded
[ INFO] [1528206346.424378383]: Plugin home_position initialized
[ INFO] [1528206346.424550102]: Plugin imu loaded
[ INFO] [1528206346.433827986]: Plugin imu initialized
[ INFO] [1528206346.434002484]: Plugin local_position loaded
[ INFO] [1528206346.440448943]: Plugin local_position initialized
[ INFO] [1528206346.440624059]: Plugin manual_control loaded
[ INFO] [1528206346.444635925]: Plugin manual_control initialized
[ INFO] [1528206346.444791787]: Plugin mocap_pose_estimate loaded
[ INFO] [1528206346.453000934]: Plugin mocap_pose_estimate initialized
[ INFO] [1528206346.453170617]: Plugin obstacle_distance loaded
[ INFO] [1528206346.456161860]: Plugin obstacle_distance initialized
[ INFO] [1528206346.456318749]: Plugin odom loaded
[ INFO] [1528206346.461227943]: Plugin odom initialized
[ INFO] [1528206346.461482062]: Plugin param loaded
[ INFO] [1528206346.464749572]: Plugin param initialized
[ INFO] [1528206346.464894610]: Plugin px4flow loaded
[ INFO] [1528206346.473668337]: Plugin px4flow initialized
[ INFO] [1528206346.473828517]: Plugin rangefinder loaded
[ INFO] [1528206346.474695426]: Plugin rangefinder initialized
[ INFO] [1528206346.474894133]: Plugin rc_io loaded
[ INFO] [1528206346.479374539]: Plugin rc_io initialized
[ INFO] [1528206346.479415076]: Plugin safety_area blacklisted
[ INFO] [1528206346.479571572]: Plugin setpoint_accel loaded
[ INFO] [1528206346.483592582]: Plugin setpoint_accel initialized
[ INFO] [1528206346.483845022]: Plugin setpoint_attitude loaded
[ INFO] [1528206346.496905739]: Plugin setpoint_attitude initialized
[ INFO] [1528206346.497093687]: Plugin setpoint_position loaded
[ INFO] [1528206346.513243304]: Plugin setpoint_position initialized
[ INFO] [1528206346.513398948]: Plugin setpoint_raw loaded
[ INFO] [1528206346.524861615]: Plugin setpoint_raw initialized
[ INFO] [1528206346.525023984]: Plugin setpoint_velocity loaded
[ INFO] [1528206346.531851581]: Plugin setpoint_velocity initialized
[ INFO] [1528206346.532195967]: Plugin sys_status loaded
[ INFO] [1528206346.543599443]: Plugin sys_status initialized
[ INFO] [1528206346.543766510]: Plugin sys_time loaded
[ INFO] [1528206346.547680180]: TM: Timesync mode: NONE
[ INFO] [1528206346.548386117]: Plugin sys_time initialized
[ INFO] [1528206346.548550715]: Plugin vfr_hud loaded
[ INFO] [1528206346.550089774]: Plugin vfr_hud initialized
[ INFO] [1528206346.550243132]: Plugin vibration loaded
[ INFO] [1528206346.551921768]: Plugin vibration initialized
[ INFO] [1528206346.552065219]: Plugin vision_pose_estimate loaded
[ INFO] [1528206346.561863598]: Plugin vision_pose_estimate initialized
[ INFO] [1528206346.562007222]: Plugin vision_speed_estimate loaded
[ INFO] [1528206346.565814058]: Plugin vision_speed_estimate initialized
[ INFO] [1528206346.566012320]: Plugin waypoint loaded
[ INFO] [1528206346.571839418]: Plugin waypoint initialized
[ INFO] [1528206346.571945153]: Built-in SIMD instructions: SSE, SSE2
[ INFO] [1528206346.571980376]: Built-in MAVLink package version: 2018.5.5
[ INFO] [1528206346.572017198]: Known MAVLink dialects: common ardupilotmega ASLUAV autoquad icarous matrixpilot paparazzi slugs standard uAvionix ualberta
[ INFO] [1528206346.572039917]: MAVROS started. MY ID 1.240, TARGET ID 1.1
[ INFO] [1528206346.580335923]: IMU: Attitude quaternion IMU detected!
[ INFO] [1528206346.582115271]: IMU: High resolution IMU detected!
[ INFO] [1528206347.474140678]: CON: Got HEARTBEAT, connected. FCU: PX4 Autopilot
[ INFO] [1528206347.478073978]: IMU: Attitude quaternion IMU detected!
[ INFO] [1528206347.479044770]: IMU: High resolution IMU detected!

Diagnostics

place here result of:
rostopic echo -n1 /diagnostics


ros@ros:~/catkin_ws$ rostopic echo -n1 /diagnostics
header:
seq: 27
stamp:
secs: 1528206472
nsecs: 230403402
frame_id: ''
status:

level: 0
name: "mavros: FCU connection"
message: "connected"
hardware_id: "/dev/ttyPIXEXT:921600"
values: 
  - 
    key: "Received packets:"
    value: "11545"
  - 
    key: "Dropped packets:"
    value: "0"
  - 
    key: "Buffer overruns:"
    value: "0"
  - 
    key: "Parse errors:"
    value: "0"
  - 
    key: "Rx sequence number:"
    value: "60"
  - 
    key: "Tx sequence number:"
    value: "61"
  - 
    key: "Rx total bytes:"
    value: "489944"
  - 
    key: "Tx total bytes:"
    value: "7797"
  - 
    key: "Rx speed:"
    value: "16228.000000"
  - 
    key: "Tx speed:"
    value: "271.000000"
  • level: 2
    name: "mavros: GPS"
    message: "No satellites"
    hardware_id: "/dev/ttyPIXEXT:921600"
    values:

    key: "Satellites visible"
    value: "0"
    
    • key: "Fix type"
      value: "0"
    • key: "EPH (m)"
      value: "Unknown"
    • key: "EPV (m)"
      value: "Unknown"
  • level: 0
    name: "mavros: Heartbeat"
    message: "Normal"
    hardware_id: "/dev/ttyPIXEXT:921600"
    values:

    key: "Heartbeats since startup"
    value: "28"
    
    • key: "Frequency (Hz)"
      value: "0.959974"
    • key: "Vehicle type"
      value: "Quadrotor"
    • key: "Autopilot type"
      value: "PX4 Autopilot"
    • key: "Mode"
      value: "AUTO.LOITER"
    • key: "System status"
      value: "Standby"
  • level: 0
    name: "mavros: System"
    message: "Normal"
    hardware_id: "/dev/ttyPIXEXT:921600"
    values:

    key: "Sensor present"
    value: "0x00000020"
    
  • level: 0
    name: "mavros: Battery"
    message: "Normal"
    hardware_id: "/dev/ttyPIXEXT:921600"
    values:

    key: "Voltage"
    value: "65.54"
    
    • key: "Current"
      value: "-0.0"
    • key: "Remaining"
      value: "-1.0"

Check ID

rosrun mavros checkidOK. I got messages from 1:1.

---
Received 5724 messages, from 1 addresses
sys:comp   list of messages
  1:1     0, 1, 132, 140, 141, 147, 4, 26, 30, 31, 32, 36, 74, 76, 83, 85, 230, 105, 111, 241, 242, 245



@vooon
Copy link
Member

vooon commented Jul 28, 2019

Battery messages are processed here:

Math is simple remaining / 100.0f (to map 0-100 to 0.0-1.0), and remaining may be -1 in case of unknown.
So probably we should define what to return in that case.
In any case, you may use r < 0 to check that condition.

@FaboNo
Copy link
Author

FaboNo commented Jul 29, 2019

@vooon Thank you for your message. I got the same values with Analyze (qgc) and I am surprised by the voltage value (65 volts and I have a 4C lipo battery). I am wondering whether I did not correctly configure the power panel with QGC or not.

@vooon
Copy link
Member

vooon commented Jul 29, 2019

@FaboNo yes, likely that battery monitor is misconfigured. But i don't know what exactly wrong, so probably first better to try reconfigure until you got possible values in QGC.
Also i suppose, that unknown remaining percentage may be because lack of current monitor (in config).

@FaboNo
Copy link
Author

FaboNo commented Aug 4, 2019

@vooon the cable from the power module was plugged inot POWER2 instead of POWER1 on the pixhawk v2.1. This is why the pixhawk s not able to measure the voltage. Now it works fine.

@FaboNo FaboNo closed this as completed Aug 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants