Derived from Device and Solid.
GPS {
SFString type "satellite" # {"satellite", "laser"}
SFFloat accuracy 0 # [0, inf)
SFFloat noiseCorrelation 0 # [0, 1]
SFFloat resolution -1 # {-1, [0, inf)}
SFFloat speedNoise 0 # [0, inf)
SFFloat speedResolution -1 # {-1, [0, inf)}
}
The GPS node is used to model a Global Positioning Sensor (GPS) which can obtain information about its absolute position from the controller program.
-
type: This field defines the type of GPS technology used like "satellite" or "laser" (currently ignored). -
accuracy: This field defines the precision of the GPS, that is the standard deviation (expressed in meter) of the gaussian noise added to the position. -
noiseCorrelation: If a more accurate gps noise model than the simple gaussian noise is required, this field can be used to define the noise correlation level. The noise model is then approximated by a gaussian-correlated phenomena, which capture for example the drift phenomena present in GPS. The value should be between 0 and 1 and represents how much the noise from 1 second ago influence the current noise, 0 means no influence (i.e. no correlation) and 1 means that the noise will be constant (noise fully correlated with the noise from one second ago). Internally the correlation factor corresponding to the sensor time step is computed and the current noise is estimated using a Gauss-Markov process as described in this figure.
%figure "Gauss-Markov process"
%end
-
resolution: This field allows to define the resolution of the sensor, the resolution is the smallest change that it is able to measure. Setting this field to -1 (default) means that the sensor has an 'infinite' resolution (it can measure any infinitesimal change). This field accepts any value in the interval (0.0, inf). -
speedNoise: This field defines the standard deviation (expressed in meter) of the gaussian noise added to the speed measurements of the GPS. -
speedResolution: This field defines the resolution of the speed measurements, the resolution is the smallest speed change that the GPS is able to measure. Setting this field to -1 (default) means that the sensor has an 'infinite' resolution (it can measure any infinitesimal change). This field accepts any value in the interval (0.0, inf).
%tab-component "language"
%tab "C"
#include <webots/gps.h>
void wb_gps_enable(WbDeviceTag tag, int sampling_period);
void wb_gps_disable(WbDeviceTag tag);
int wb_gps_get_sampling_period(WbDeviceTag tag);
const double *wb_gps_get_values(WbDeviceTag tag);
double wb_gps_get_speed(WbDeviceTag tag);
const double *wb_gps_get_speed_vector(WbDeviceTag tag);%tab-end
%tab "C++"
#include "<webots/GPS.hpp>"
namespace webots {
class GPS : public Device {
virtual void enable(int samplingPeriod);
virtual void disable();
int getSamplingPeriod() const;
const double *getValues() const;
double getSpeed() const;
const double *getSpeedVector() const;
// ...
}
}%tab-end
%tab "Python"
from controller import GPS
class GPS (Device):
def enable(self, samplingPeriod):
def disable(self):
def getSamplingPeriod(self):
def getValues(self):
def getSpeed(self):
def getSpeedVector(self):
# ...%tab-end
%tab "Java"
import com.cyberbotics.webots.controller.GPS;
public class GPS extends Device {
public void enable(int samplingPeriod);
public void disable();
public int getSamplingPeriod();
public double[] getValues();
public double getSpeed();
public double[] getSpeedVector();
// ...
}%tab-end
%tab "MATLAB"
wb_gps_enable(tag, sampling_period)
wb_gps_disable(tag)
period = wb_gps_get_sampling_period(tag)
x_y_z_array = wb_gps_get_values(tag)
speed = wb_gps_get_speed(tag)%tab-end
%end
enable, disable and read the GPS measurements
The wb_gps_enable function allows the user to enable GPS measurements.
The sampling_period argument specifies the sampling period of the sensor and is expressed in milliseconds.
Note that the first measurement will be available only after the first sampling period elapsed.
The wb_gps_disable function turns the GPS off, saving computation time.
The wb_gps_get_sampling_period function returns the period given into the wb_gps_enable function, or 0 if the device is disabled.
The wb_gps_get_values function returns the current GPS measurement.
The values are returned as a 3D-vector, therefore only the indices 0, 1, and 2 are valid for accessing the vector.
The returned vector indicates the absolute position of the GPS device.
This position can either be expressed in the cartesian coordinate system of Webots or using latitude-longitude-altitude, depending on the value of the gpsCoordinateSystem field of the WorldInfo node.
The gpsReference field of the WorldInfo node can be used to define the reference point of the GPS.
The wb_gps_get_speed function returns the current GPS speed in meters per second.
If there is no physics node on the parent node, the first returned value will be NaN.
The wb_gps_get_speed_vector function returns the current GPS speed vector in meters per second.
If there is no physics node on the parent node, the first returned vector will be NaN.
Note [C, C++]: The returned vector is a pointer to the internal values managed by the GPS node, therefore it is illegal to free this pointer. Furthermore, note that the pointed values are only valid until the next call to the
wb_robot_steporRobot::stepfunctions. If these values are needed for a longer period they must be copied.
Note [Python]: The
getValuesfunction returns the 3D-vector as a list containing three floats.
%tab-component "language"
%tab "C"
#include <webots/gps.h>
typedef enum {
WB_GPS_LOCAL_COORDINATE,
WB_GPS_WGS84_COORDINATE
} WbGpsCoordinateSystem;
WbGpsCoordinateSystem wb_gps_get_coordinate_system(WbDeviceTag tag);%tab-end
%tab "C++"
#include "<webots/GPS.hpp>"
namespace webots {
class GPS : public Device {
typedef enum {LOCAL, WGS84} CoordinateSystem;
const CoordinateSystem getCoordinateSystem() const;
// ...
}
}%tab-end
%tab "Python"
from controller import GPS
class GPS (Device):
LOCAL, WGS84
def getCoordinateSystem(self):
# ...%tab-end
%tab "Java"
import com.cyberbotics.webots.controller.GPS;
public class GPS extends Device {
public final static int LOCAL, WGS84;
public int getCoordinateSystem();
// ...
}%tab-end
%tab "MATLAB"
WB_GPS_LOCAL_COORDINATE, WB_GPS_WGS84_COORDINATE
coordinate_system = wb_gps_get_coordinate_system(tag)%tab-end
%end
get the gps coordinate system
This function allows the user to retrieve the coordinate system type defined by the gpsCoordinateSystem field of the WorldInfo node.
If the value of the gpsCoordinateSystem field is "local" then this function returns WB_GPS_LOCAL_COORDINATE, and otherwise it returns WB_GPS_WGS84_COORDINATE.
%tab-component "language"
%tab "C"
#include <webots/gps.h>
const char * wb_gps_convert_to_degrees_minutes_seconds(double decimal_degrees);%tab-end
%tab "C++"
#include "<webots/GPS.hpp>"
namespace webots {
class GPS : public Device {
static std::string convertToDegreesMinutesSeconds(double decimalDegree);
// ...
}
}%tab-end
%tab "Python"
from controller import GPS
class GPS (Device):
@staticmethod
def convertToDegreesMinutesSeconds(decimalDegree):
# ...%tab-end
%tab "Java"
import com.cyberbotics.webots.controller.GPS;
public class GPS extends Device {
public static String convertToDegreesMinutesSeconds(double decimalDegree);
// ...
}%tab-end
%tab "MATLAB"
coordinate = wb_gps_convert_to_degrees_minutes_seconds(decimal_degrees)%tab-end
%end
convert decimal degrees to degrees minutes seconds
This function converts a decimal degrees coordinate into a string representing the coordinate in the degrees minutes seconds format.
Note: Your system should support UTF-8 otherwise you may get strange characters instead of the degree, minute and second symbols.
Note [C]: The returned string should be deallocated by the user.
