# Start

## Initial Connection

To start using the bysense SDK, follow these steps to initialize the connection to your quadruped robot:

<pre class="language-python" data-title="python" data-overflow="wrap" data-line-numbers><code class="lang-python">#import the SDK module
import bysense_sdk as bysense

# Create a boolean connection variable of the start class
<strong>bysense_connection = bysense.start.connect()
</strong>
# Verify the connection status
if bysense_connection.is_connected():
    print(bysense_connection.lastlog())
else:
    print(bysense_connection.lastlog())
    # Handle connection failure as needed
</code></pre>

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

```cpp
#include "bysense_sdk.hpp"  // Include the SDK's main header file

int main() {
    // Create an instance of the 'start' class (assuming 'start' is a class in the SDK)
    bysense::start myStartInstance;

    // Call the 'connect' method and store the result in a connection variable
    auto bysense_connection = myStartInstance.connect();

    // Verify the connection status by calling the 'is_connected' method
    if (bysense_connection.is_connected()) {
        std::cout bysense_connection.lastlog() std::endl;
    } else {
        std::cout bysense_connection.lastlog() std::endl;
        // Handle connection failure as needed
    }

    return 0;
}
```

{% endcode %}

With those lines of code you will connect to bysense and will get its connection status as feedback.

If you struggle with the connection after few seconds of turning the robot on. It might be that the robot is still in booting sequence which can take up to one minute. Also make sure bysense is connected to your router or the ethernet cable is connected properly.

## E-Stop

There will be moments where a E Stop especially during development is required. Therefore we provide a command based version and a UI based version. In all scenarios the joint torque is set to zero. To shut down the power would required a new starting protocol procedure.&#x20;

### E-Stop - UI

{% hint style="danger" %}
we recommend to use have a E-Stop in reachable area&#x20;
{% endhint %}

Idea with the UI based E stop is to have a single button on your keyboard dedicated for this exceptional situation to protect not only the hardware but also others.&#x20;

{% 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()

if bysense_connection.is_connected():
    #open UI in a seperate process to be able to use it
    bysense.start.estop_UI()

else:
    print("Failed to connect.")
    # Handle connection failure as needed
```

{% endcode %}

Here the UI will appear with a button. Once this button has been pressed you E-Stop is active and all joints will be turned off. The power is not cut off.

### E-Stop - Command based

If you plan to use an external device as E stop or some other device like a remote control, you can use following lines of code to direct activate the estop.&#x20;

{% 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()


if bysense_connection.is_connected():
    #open UI in a seperate process to be able to use it
    bysense_stop = bysense.stop.estop()

else:
    print("Failed to connect.")
    # Handle connection failure as needed
```

{% endcode %}

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

```cpp
//import the SDK module
#include "bysense_sdk.hpp"

int main() {
    // Create an instance of the 'core' class
    bysense::core myCoreInstance;

    // Call the 'estop' method on the 'core' instance
    myCoreInstance.estop();

    return 0;
}
```

{% endcode %}

we have build the estop function right into the core class of bysense. The python code does access the core class.

## Activate & Deactivate Joints

You can only activate the joints once a E-Stop button is in place. If you try just to activate the joints you will get a error message. With the activate joints you are able to use the joints for your application. Once your program is finished you can deactivate the joints as in the example below:

{% 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()


if bysense_connection.is_connected():
    #open UI in a seperate process to be able to use it
    bysense.start.estop_UI()
    
    #once estop is avaible the joints can be activated
    bysense_active_joints = bysense.start.activate_joints()
    
    #placeholder for some activity
    
    #once estop is avaible the joints can be activated
    bysense_deactive_joints = bysense.start.deactive_joints()
    

else:
    print("Failed to connect.")
    # Handle connection failure as needed
```

{% 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/start.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.
