Closed GoogleCodeExporter closed 9 years ago
[deleted comment]
While someone is in the gcs_mavlink.pde code, it would also be worthwhile
adding the code to transfer motor current via mavlink. The Arduplane
gcs_mavlink.pde code already has this, so could just copy over the code.
Original comment by AndrewJF...@gmail.com
on 23 Jun 2012 at 1:38
Confirmed the fix. Arducopter and ArdupilotMissionPlanner work fine with the
changes below. I also checked the Arduplane code and gcs_mavlink looks O.K.
(already multiplying by 100), but haven't tested it.
Andrew
Arducopter - gcs_mavlink.pde
Was:
uint16_t battery_remaining = 1000.0 * (float)(g.pack_capacity - current_total1)/(float)g.pack_capacity; //Mavlink scaling 100% = 1000
New:
uint16_t battery_remaining = 100.0 * (float)(g.pack_capacity - current_total1)/(float)g.pack_capacity; //Mavlink scaling 100% = 100
ArdupilotmegaPlanner - CurrentState.cs
Was:
_battery_remaining = value / 1000;
New:
_battery_remaining = value / 100
Original comment by AndrewJF...@gmail.com
on 23 Jun 2012 at 1:39
To implement the changes in arducopter gcs_mavlink.pde to work the same was as
in arduplane the new code is as shown below. Tested in 2.6 and it works fine.
The "load" parameter is not calculated in arducopter, so just left it at zero.:
uint16_t battery_current = -1;
uint8_t battery_remaining = -1;
if (current_total1 != 0 && g.pack_capacity != 0) {
battery_remaining = (100.0 * (g.pack_capacity - current_total1) / g.pack_capacity);
}
if (current_total1 != 0) {
battery_current = current_amps1 * 100;
}
if (g.battery_monitoring == 3) {
/*setting a out-of-range value.
It informs to external devices that
it cannot be calculated properly just by voltage*/
battery_remaining = 150;
}
mavlink_msg_sys_status_send(
chan,
control_sensors_present,
control_sensors_enabled,
control_sensors_health,
0, // Load not yet calculated in Arducopter
battery_voltage1 * 1000, // mV
battery_current, // in 10mA units
battery_remaining, // in %
0, // comm drops %,
0, // comm drops in pkts,
0, 0, 0, 0);
Original comment by AndrewJF...@gmail.com
on 23 Jun 2012 at 2:09
A fix has just been added to the code base by Andreas.
Original comment by AndrewJF...@gmail.com
on 25 Jun 2012 at 1:11
Original comment by jasonshort
on 26 Jun 2012 at 5:51
Original issue reported on code.google.com by
AndrewJF...@gmail.com
on 17 Jun 2012 at 1:00