# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bywerks.gitbook.io/bysense/mission-development/state-estimation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
