libcara is a high-performance C++ library for Conjunction Assessment and Risk Analysis. It provides a numerically stable implementation of the Foster algorithm for calculating the Probability of Collision (
- Foster Algorithm: High-precision, numerically stable probability of collision calculations.
- Performance: C++ core for speed-critical computations.
- Python Integration: Seamless API access via
pybind11for easy use in data pipelines.
# Clone the repository
git clone [https://github.com/Jits-Doomen/libcara.git](https://github.com/Jits-Doomen/libcara.git)
cd libcara
# Install the package
pip install .from libcara import libcara_ext
1. Initialize the ConjunctionData structure
cd = libcara_ext.ConjunctionData()
2. Populate data (Example: set vectors and matrices)
cd.r1 = libcara_ext.Vector3(x, y, z)
3. Calculate Probability of Collision
pc = libcara_ext.calculate_foster_pc(cd) print(f"Probability of Collision: {pc:.8e}")
To use the library effectively, you are interacting with three main components through the Python bindings:
-
ConjunctionData: This is your primary data container. Before calling the solver, you must assign values to all required members:-
r1,r2:Vector3objects for the position of both objects at the Time of Closest Approach (TCA). -
v1,v2:Vector3objects for the velocity of both objects at TCA. -
C1_pos,C2_pos:Matrix3x3objects representing the positional covariance matrices. -
hbr: Afloatrepresenting the combined Hard Body Radius (meters).
-
-
libcara_ext: This is the compiled module. All structures (Vector3,Matrix3x3,ConjunctionData) are members of this module. -
calculate_foster_pc: This is the solver. It consumes your fully populatedConjunctionDataobject and returns the$P_c$ as afloat.