Skip to content

Add autopilot functionality - #1921

Draft
ktokto313 wants to merge 7 commits into
DonBruce64:masterfrom
ktokto313:autopilot
Draft

ktokto313 wants to merge 7 commits into
DonBruce64:masterfrom
ktokto313:autopilot

Conversation

@ktokto313

Copy link
Copy Markdown
Contributor

No description provided.

};
addComponent(beaconBox);
newComponent = beaconBox;
text = "Hdg";

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all panel items, default text is in all CAPS. Please change to match.

return vehicle.autopilotValueVar.isActive ? 1 : 0;
}
};
text = vehicle.definition.motorized.isAircraft ? "AUTO" : "CRUISE";

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is right? This is the stuff for the autopilot button, this wouldn't be the text for the heading box.

BEACON_BOX,
@JSONDescription("Make this a heading input box, which allows changing the autopilot heading.")
HEADING,
@JSONDescription("Heading autopilot on or st")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to clarify what "st" means.

import minecrafttransportsimulator.mcinterface.InterfaceManager;
import minecrafttransportsimulator.packets.components.APacketEntity;

public class PacketVehicleWaypointSelectRequest extends APacketEntity<EntityVehicleF_Physics> {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This packet and the WaypointSelect packet can be one packet as they contain the same data, and just do different things based on if they are on the client or server. Also, you're double-sending packets back. Returning true on a packet sent to a server on the handle method will send that packet to all clients. So you're sending the request packet back to do nothing with it, then sending the new select packet. Just lump both together and return true and check for server/client for processing.

/**
* Request waypoint selection update from client to server for vehicle
*/
public class PacketVehicleWaypointUpdateRequest extends APacketEntity<EntityVehicleF_Physics> {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as prior waypoint packet set.

public final ComputedVariable autopilotAltitude;
public final ComputedVariable autopilotSpeed;
public final ComputedVariable autopilotVerticalSpeed;
// private PIDController verticalSpeedController = new PIDController(0.001, 0.000005, 0.01);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No debug leftovers please.

aileronTrimVar.adjustBy(0.1, true);
} else if (-orientation.angles.z < aileronTrimVar.currentValue - 0.1 && aileronTrimVar.currentValue > -MAX_AILERON_TRIM) {
aileronTrimVar.adjustBy(-0.1, true);
// if (autopilotNavEnabledVar.isActive) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug leftover.

} else {
verticalSpeedController.clear();
}
// if (selectedBeacon == null) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More leftovers.

}

public void navGPS() {
// double heading = Math.toDegrees(Math.atan2(autopilotPositionZ.currentValue - position.z , autopilotPositionX.currentValue - position.x));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftovers.

} else if (output < -45) {
output = -45;
}
// Output = Math.toDegrees(Math.asin(motion.y / velocity))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftovers.

@DonBruce64

Copy link
Copy Markdown
Owner

@ktokto313 In general, I agree with the changes here. The allowing aircraft to follow waypoints. The flight plan stuff, etc. What gets me is that we're adding virtual waypoints to world data when we have a physical beacon thing that's already designed for such waypoints. I feel that should be upgraded to have the same variables as the existing waypoints. I do get that altitude and such isn't something that is normally defined by beacons, but I feel one could do that here to simply have people plan out routes for general flight this way.

Heading also isn't usually defined by single points, but getting it to follow a track wouldn't be hard. Plus then one could have the plane switch to the next waypoint when it gets within 100 blocks or so of the active one. Allows for automatic flying based on waypoint bits, and if we get glideslope to work could allow for automatic landing.

I do agree with the bones and maths and such, and I want to keep that. Just want to be conscious of adding a bunch of different systems that interact differently when we already have something physical players can use and will probably understand better. Sure it's not technically the same as a flight plan, but your average MC kiddie knows what height means and know how to click blocks and work with GUIs and such.

@ktokto313

Copy link
Copy Markdown
Contributor Author

The flight plan and virtual waypoint was @Deepseasaltyfish plan, I think he wanted to have a system where plane can follow waypoint without getting to the point manually, placing a beacon and setting it up. I haven't give it much thought as it's within the game design area itself. Personally, I would like to have to follow and change VOR beacon manually but it's only my two cent.

The glideslope already works but it's not really an autoland. Throttle autopilot doesn't work with throttle/hotas iirc. That's about the state of this PR right now.

@Deepseasaltyfish

Copy link
Copy Markdown
Contributor

after a few months i have some new ideas, for example we could have custom automatic controller algorithm instead of hard-coded PID controller.
also this PR has stopped for a long time and still was at a early state and still need much work, i think i will have more time the second half of the year

@DonBruce64

Copy link
Copy Markdown
Owner

Marking this PR as draft since it's not ready for merge.

@DonBruce64
DonBruce64 marked this pull request as draft May 15, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants