Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:CARLA simulator Carla OdrSpiral

From Leeroopedia
Knowledge Sources
Domains Road Geometry, OpenDRIVE
Last Updated 2026-02-15 05:00 GMT

Overview

odrSpiral.cpp computes Euler spiral (clothoid) geometry for OpenDRIVE road applications, using Fresnel integral approximations from the CEPHES mathematical library.

Description

This file (~247 lines) by VIRES GmbH (Apache 2.0 license) implements the odrSpiral function for computing standard spiral curves starting with curvature 0. The implementation uses Fresnel integrals computed via Chebyshev polynomial approximations (polevl and p1evl helper functions) from the CEPHES library. The fresnel function computes the Fresnel S and C integrals for a given parameter, handling three ranges: small x (polynomial approximation), medium x (auxiliary function approximation), and large x (asymptotic limit of 0.5). The main odrSpiral function transforms the Fresnel integrals into x,y coordinates and tangent direction in the spiral's local coordinate system.

Usage

This function is used by the CARLA OpenDRIVE road parser to compute the geometry of clothoid/Euler spiral road segments, which are a standard geometry type in OpenDRIVE road network descriptions.

Code Reference

Source Location

  • Repository: CARLA
  • File: LibCarla/source/third-party/odrSpiral/odrSpiral.cpp

Signature

/**
 * Compute the actual "standard" spiral, starting with curvature 0
 * @param s      run-length along spiral [m]
 * @param cDot   first derivative of curvature [1/m2]
 * @param x      resulting x-coordinate in spiral's local coordinate system [m]
 * @param y      resulting y-coordinate in spiral's local coordinate system [m]
 * @param t      tangent direction at s [rad]
 */
void odrSpiral(double s, double cDot, double *x, double *y, double *t);

// Internal: Fresnel integral computation
static void fresnel(double xxa, double *ssa, double *cca);

Import

// Declare externally:
extern void odrSpiral(double s, double cDot, double *x, double *y, double *t);

I/O Contract

Parameter Type Direction Description
s double In Run-length along the spiral in meters
cDot double In First derivative of curvature (1/m^2)
x double * Out Resulting x-coordinate in local spiral coordinate system
y double * Out Resulting y-coordinate in local spiral coordinate system
t double * Out Tangent direction at position s in radians

Usage Examples

double x, y, t;
double s = 10.0;      // 10 meters along the spiral
double cDot = 0.001;  // curvature derivative

odrSpiral(s, cDot, &x, &y, &t);
// x, y now contain the position in spiral-local coordinates
// t contains the tangent direction in radians

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment