Module: util/Commands

Manages sending the picpilot commands. Writes to the data relay connection to send commands. Validates data before sending it out using the Validator module.

Author:
  • Serge Babayan
Source:
See:

Requires

  • module:util/Validator
  • module:SimulationManager
  • module:util/Logger
  • module:Network
  • module:config/picpilot-config

Methods


<inner> activateWriteMode()

Actives write mode for the groundstation, allowing the groundstation to send commands that affect the autopilot

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> appendWaypoint(lat, lon, alt, radius, probe_drop)

Appends a waypoint to the autopilots flight plan

Parameters:
Name Type Description
lat string | Number

Latitude of waypoint

lon string | Number

Longitude of waypoint

alt string | Number

Altitude of waypoint

radius string | Number

Radius, in m, of the waypoint

probe_drop boolean

Whether the waypoint is a probe drop location

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> armPlane()

Arms the plane

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> checkConnection()

Checks whether there is an active data relay connection

Source:
Returns:

Connection status

Type
boolean

<inner> clearWaypoints()

Clears all the waypoints for the path manager

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> disarmPlane()

Disarms the plane

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> dropProbe(number)

Drop a probe

Parameters:
Name Type Description
number string | Number

The probe number of which to drop

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> followPath(status)

Tell the aircraft to follow the flight plan

Parameters:
Name Type Description
status boolean

Whether the plane should follow the flight plan

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> insertWaypoint(index, lat, lon, alt, radius)

Inserts a waypoint at a specified index to the autopilot's flight plan

Parameters:
Name Type Description
index int

The index of the waypoint

lat string | Number

Latitude of waypoint

lon string | Number

Longitude of waypoint

alt string | Number

Altitude of waypoint

radius string | Number

Radius, in m, of the waypoint

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> insertWaypoint(index, lat, lon, alt, radius, probe_drop)

Inserts a waypoint at a specified index to the autopilot's flight plan

Parameters:
Name Type Description
index int

The index of the waypoint

lat string | Number

Latitude of waypoint

lon string | Number

Longitude of waypoint

alt string | Number

Altitude of waypoint

radius string | Number

Radius, in m, of the waypoint

probe_drop boolean

Whether the waypoint is a probe drop location

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> killPlane()

Kills the plane

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> removeWaypoint(index)

Removes a waypoint from the autopilot's flight plan

Parameters:
Name Type Description
index String | Number

The id of the waypoint

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> resetProbe(number)

Reset a probe

Parameters:
Name Type Description
number string | Number

The probe number of which to drop

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> sendAltitude(altitude)

Sends a altitude value to the autopilot

Parameters:
Name Type Description
altitude string | Number

The altitude in m

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> sendAutoLevel(level)

Sends an autonomous level to the picpilot. Check the datalink docs for more info

Parameters:
Name Type Description
level string | Number

The autonomous level as a decimal value

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> sendCommand(command, value)

Sends a regular command to the data relay

Parameters:
Name Type Description
command string

The command name

value string | Number

The value of the command. This can be lots of different parameters

Source:
Returns:

Whether the command was successfully sent. Will return false if there is no connection and the simulator isn't active

Type
boolean
Example
Commands.sendCommand('awesomeCommand', 'value1', 'value2', 'value3');
//will send this through the data relay
//awesomeCommand:value1, value2, value3

<inner> sendFlap(flap)

Sends a flap value to the autopilot

Parameters:
Name Type Description
flap string | Number

The flap percentage (0 is no flaps, 100% is full flaps)

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> sendHeading(heading)

Sends a heading value to the autopilot

Parameters:
Name Type Description
heading string | Number

The heading in degrees (0-360)

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> sendHeartbeat()

Send a heartbeat to the plane

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> sendKDGain(type, gain)

Sends a kd gain value to the autopilot

Parameters:
Name Type Description
type string

One of: flap, altitude, throttle, heading, roll, pitch, yaw

gain string | Number

The gain value

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> sendKIGain(type, gain)

Sends a ki gain value to the autopilot

Parameters:
Name Type Description
type string

One of: flap, altitude, throttle, heading, roll, pitch, yaw

gain string | Number

The gain value

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> sendKPGain(type, gain)

Sends a kp gain value to the autopilot

Parameters:
Name Type Description
type string

One of: flap, altitude, throttle, heading, roll, pitch, yaw

gain string | Number

The gain value

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> sendOrbitGain(gain)

Sends a orbital gain value to the autopilot

Parameters:
Name Type Description
gain string | Number

The gain value

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> sendPathGain(gain)

Sends a path gain value to the autopilot

Parameters:
Name Type Description
gain string | Number

The gain value

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> sendPitch(pitch)

Sends a pitch value to the autopilot

Parameters:
Name Type Description
pitch string | Number

The pitch in degrees

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> sendProtectedCommand(command)

Sends a protected command (a command requiring a password appended after the command)

Parameters:
Name Type Description
command string
Source:
Returns:

Whether the command was successfully sent. Will return false if there is no connection and the simulator isn't active

Type
boolean

<inner> sendRawCommand(command)

Sends a raw command (no formatting) to the data relay

Parameters:
Name Type Description
command string

The command string

Source:
Returns:

Whether the command was successfully sent. Will return false if there is no connection and the simulator isn't active

Type
boolean

<inner> sendRoll(roll)

Sends a roll value to the autopilot

Parameters:
Name Type Description
roll string | Number

The roll in degrees

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> sendThrottle(throttle)

Sends a throttle value to the autopilot

Parameters:
Name Type Description
throttle string | Number

The percentage value of the throttle

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> setTargetWaypoint(number)

Sets the target waypoint for the autopilot's path manager

Parameters:
Name Type Description
number String | Number

The id of the waypoint

Source:
Returns:

Whether the command sent successfully

Type
boolean

<inner> unkillPlane()

Unkills the plane

Source:
Returns:

Whether the command sent successfully

Type
boolean