Skip to content

sendWYPT

Jason Watkins edited this page Sep 23, 2020 · 5 revisions

NOTE: This command relies on OpenGL. It will not work if using Vulkan in newer versions of X-Plane that support it.

Adds, removes, or clears waypoints. Waypoints are three dimensional points on or above the Earth's surface that are represented visually in the simulator. Each point consists of a latitude and longitude expressed in fractional degrees and an altitude expressed as meters above sea level.

Syntax

Language Signature
C int sendWYPT(XPCSocket sock, WYPT_OP op, float points[], int count)
MATLAB sendWYPT( op, points, socket )
Java void sendWYPT(WaypointOperation op, float[] points)
Python sendWYPT(self, op, points)
Parameters

sock (C): The socket used to send the command.

op: The operation to perform. In C, valid operations are contained in the WYPT_OP enum. In Java, valid operations are contained in the WaypointOperation enum. In MATLAB and Python, numeric values are used. Pass 1 to add waypoints, 2 to remove waypoints, and 3 to clear all waypoints.

points: An array of floating point values representing latitude, longitude, and altitude triples. The length of this array should always be divisible by 3.

count (C): The number of points passed.

socket (MATLAB): An optional reference to a socket opened with openUDP that should be used to send the command.

Return value

C: A negative value if an error occurs, otherwise 0.

Remarks

Waypoints are always sorted in the order they were added. To move a waypoint to an arbitrary point int the sequence requires deleting the waypoint, deleting all waypoints after the desired point in the sequence, and finally re-adding all deleted waypoints in the desired order.

Exceptions

C Error Code Java Exception Python Error Description
-1 - ValueError An invalid operation was specified
  •       |IllegalArgumentException|ValueError  |`points` did not have an even number of triples
    

-2 |IllegalArgumentException|ValueError |Too many points. Must be less than 256 -3 |IOException |OSError |The client is unable to send the command

Examples

C
#include "xplaneConnect.h"
XPCSocket sock = openUDP(49077, IP, PORT);

//Set a single waypoint over South San Francisco bay
float points[] = { 37.524, -122.06899, 2500 };
sendWYPT(sock, xpc_WYPT_Add, points, 1);

closeUDP(sock);
MATLAB
import XPlaneConnect.*;

% Set a single waypoint over South San Francisco bay
points = [ 37.524, -122.06899, 2500 ];
sendWYPT(1, points);
Java
import gov.nasa.xpc.XPlaneConnect;

try(XPlaneConnect xpc = new XPlaneConnect())
{
    // Set a single waypoint over South San Francisco bay
    float points[] = { 37.524, -122.06899, 2500 };
    xpc.sendWYPT(WaypointOperation.Add, points);
}

Python

import xpc

with xpc.XPlaneConnect() as client:
    # Set a single waypoint over South San Francisco bay
    points = [ 37.524, -122.06899, 2500]
    client.sendWYPT(1, points)