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

Use GLOBAL_POSITION_INT instead of VFR_HUD to set altitude and speeds… #489

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.MAVLink.ardupilotmega.msg_mount_configure;
import com.MAVLink.ardupilotmega.msg_mount_status;
import com.MAVLink.ardupilotmega.msg_radio;
import com.MAVLink.common.msg_global_position_int;
import com.MAVLink.common.msg_named_value_int;
import com.MAVLink.common.msg_raw_imu;
import com.MAVLink.common.msg_rc_channels_raw;
Expand Down Expand Up @@ -416,10 +417,6 @@ public void onMavLinkMessageReceived(MAVLinkMessage message) {
processStatusText(msg_statustext);
break;

case msg_vfr_hud.MAVLINK_MSG_ID_VFR_HUD:
processVfrHud((msg_vfr_hud) message);
break;

case msg_raw_imu.MAVLINK_MSG_ID_RAW_IMU:
msg_raw_imu msg_imu = (msg_raw_imu) message;
mag.newData(msg_imu);
Expand Down Expand Up @@ -511,11 +508,25 @@ private void checkControlSensorsHealth(msg_sys_status sysStatus) {
}
}

protected void processVfrHud(msg_vfr_hud vfrHud) {
if (vfrHud == null)
/**
* Used to update the vehicle location, and altitude.
* @param gpi
*/
@Override
protected void processGlobalPositionInt(msg_global_position_int gpi) {
if(gpi == null)
return;

setAltitudeGroundAndAirSpeeds(vfrHud.alt, vfrHud.groundspeed, vfrHud.airspeed, vfrHud.climb);
super.processGlobalPositionInt(gpi);

final double relativeAlt = gpi.relative_alt / 1000.0;

final double groundSpeedX = gpi.vx / 100.0;
final double groundSpeedY = gpi.vy / 100.0;
final double groundSpeed = Math.sqrt(Math.pow(groundSpeedX, 2) + Math.pow(groundSpeedY, 2));

final double climbRate = gpi.vz / 100.0;
setAltitudeGroundAndAirSpeeds(relativeAlt, groundSpeed, groundSpeed, climbRate);
}

protected void processMountStatus(msg_mount_status mountStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,6 @@ public FirmwareType getFirmwareType() {
return FirmwareType.ARDU_PLANE;
}

@Override
protected void processVfrHud(msg_vfr_hud vfrHud){
//Nothing to do. Plane used GLOBAL_POSITION_INT to set altitude and speeds unlike copter
}

/**
* Used to update the vehicle location, and altitude.
* @param gpi
*/
@Override
protected void processGlobalPositionInt(msg_global_position_int gpi){
if(gpi == null)
return;

super.processGlobalPositionInt(gpi);

final double relativeAlt = gpi.relative_alt / 1000.0;

final double groundSpeedX = gpi.vx / 100.0;
final double groundSpeedY = gpi.vy / 100.0;
final double groundSpeed = Math.sqrt(Math.pow(groundSpeedX, 2) + Math.pow(groundSpeedY, 2));

final double climbRate = gpi.vz / 100.0;
setAltitudeGroundAndAirSpeeds(relativeAlt, groundSpeed, groundSpeed, climbRate);
}

@Override
protected boolean isFeatureSupported(String featureId){
switch(featureId){
Expand Down