State estimation
Gravity Vector
the IMU is placed in the middle of bysense. Use following lines to get the gravity vector from bysense.
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
C++
#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;
}
Last updated