# Extension

[Following the documentation here](https://github.com/rshu-bd/spot_ros2/tree/rshu-bd/spot_core_extension/spot_coreio_extension)

## [Build The Extension<svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg>](https://github.com/rshu-bd/spot_ros2/tree/rshu-bd/spot_core_extension/spot_coreio_extension#build-the-extension)

This directory contains a script create\_extension.sh that can be used to create an l4t-based Spot Extension for this example. This will create a file spot\_detect\_and\_follow.spx, which can be uploaded to the CORE I/O. The extension requires that the payload be authorized on the robot admin console to run.

If building on a host system architecture that is not `ARM64` based run the following before continuing.

```bash
sudo apt-get install qemu binfmt-support qemu-user-static
```

<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" id="bkmrk-"><div class="zeroclipboard-container"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg>  
</div></div>Installing and running qemu will allow us to build ARM binaries on an x86 machine without needing a cross compiler, see [Build Docker Images Documentation](https://dev.bostondynamics.com/docs/payload/docker_containers#build-docker-images) for more details.

This directory contains a script `create_extension.sh` that can be used to build a `ARM64` docker image and package all the files into an Extension. From the `ros2_driver` directory run the script

```bash
./create_extension.sh
```

<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" id="bkmrk--1"><div class="zeroclipboard-container"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg>  
</div></div>This will create the `spot_ros2_driver.spx` extension file that you can upload to the CORE I/O or Scout platform. The script was tested on Ubuntu 22.04 with x86 architecture.

---

Before you install and run the `spot_ros2_driver.spx` you need to configure the port range used by a connection in the CORE I/O to be within the allowable port range.

### [Limit the ports used by a connection in the CORE I/O<svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg>](https://github.com/rshu-bd/spot_ros2/tree/rshu-bd/spot_core_extension/spot_coreio_extension#limit-the-ports-used-by-a-connection-in-the-core-io)

SSH into the CORE I/O from the robot’s WiFi

```bash
ssh -p 20022 spot@192.168.80.3
```

<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" id="bkmrk--3"><div class="zeroclipboard-container"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg>  
</div></div>Make a copy of the default port range <span style="background-color: rgb(224, 62, 45);">(<span style="color: rgb(255, 255, 255);">not currently working with our CORE io</span>)</span>

```bash
cat /proc/sys/net/ipv4/ip_local_port_range > /proc/sys/net/ipv4/ip_local_port_range.bak
```

<div class="zeroclipboard-container" id="bkmrk-the-default-configur"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg><span style="text-decoration: underline;">The default configuration of the ip\_local\_port\_range</span></div>```bash
32768  60999
```

<div class="zeroclipboard-container" id="bkmrk--4"></div>Limit the ports a networking connection can use to those reachable through the CORE I/O's firewall

```bash
echo "21000 22000" | sudo tee /proc/sys/net/ipv4/ip_local_port_range
```

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" id="bkmrk--5"><div class="zeroclipboard-container"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg>  
</div></div>This will force all connections from the CORE I/O to be on the port range 21000 - 22000.