> For the complete documentation index, see [llms.txt](https://bywerks.gitbook.io/bysense/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bywerks.gitbook.io/bysense/mission-development/state-estimation.md).

# State estimation

## Gravity Vector

the IMU is placed in the middle of bysense. Use following lines to get the gravity vector from bysense.

{% code title="python" lineNumbers="true" %}

```python
#import the SDK module
import bysense_sdk as bysense

# Create a boolean connection variable of the start class
bysense_connection = bysense.start.connect()

# Verify the connection status
if bysense_connection.is_connected():
    print(bysense_connection.lastlog())
    
    #Get the gravity in x, y, z format 
    grav_vector = bysense.core.gravityvector()
    print(grav_vector)
        
else:
    print(bysense_connection.lastlog())
    # Handle connection failure as needed
```

{% endcode %}

{% code title="C++" lineNumbers="true" %}

```cpp
#include <iostream>
#include "bysense_sdk.h"  // Include the header file for the SDK

int main() {
    // Create a connection variable of the start class
    auto bysense_connection = bysense::start::connect();

    // Verify the connection status
    if (bysense_connection.is_connected()) {
        std::cout << bysense_connection.lastlog() << std::endl;

        // Get the gravity vector in x, y, z format
        auto grav_vector = bysense::core::gravityvector();
        std::cout << "Gravity Vector: (" 
                  << grav_vector[0] << ", " 
                  << grav_vector[1] << ", " 
                  << grav_vector[2] << ")" 
                  << std::endl;
    } else {
        std::cout << bysense_connection.lastlog() << std::endl;
        // Handle connection failure as needed
    }

    return 0;
}
```

{% endcode %}
