.. .. rubric:: Installation Robot

.. .. note::

..    This repository should already be available and built on the G1's Nvidia board if it has been configured by the MYBOTSHOP team.

.. 1. Clone this repository into the G1's Nvidia board.

.. 2. Run the bash install script.

.. 3. Build the repository by executing the following command:

..    .. code-block:: bash

..       colcon build --symlink-install && source install/setup.bash

.. 4. After building, remember to source the `install/setup.bash`. Ensure you add the source command to your workspace in the `.bashrc` file.

.. .. rubric:: Installation External

.. .. note::

..    **Important:** This process is necessary to enable Unitree SDK's DDS topics to appear. Without these steps, only the MYBOTSHOP package ROS2 topics will be visible. You can skip this procedure if you do not need the Unitree topics.

.. .. rubric:: Part 1

.. 1. Navigate to the **unitree_sdk2** folder inside the **thirdparty** directory and execute the installation script:

..    .. code-block:: bash

..       cd thirdparty/unitree_sdk2
..       sudo bash install.sh

.. 2. Build the examples:

..    .. code-block:: bash

..       rm -rf build && mkdir build && cd build && cmake .. && make

.. 3. You can now directly run high-level and low-level examples as explained in the Unitree G1 SDK documentation.

.. .. rubric:: Part 2


.. **Requirements:** ROS2 Foxy on **Ubuntu 20.04**.

.. 1. Install the necessary dependencies:

..    .. code-block:: bash

..       sudo apt install ros-$ROS_DISTRO-rmw-cyclonedds-cpp ros-$ROS_DISTRO-rosidl-generator-dds-idl -y

.. 2. Unsource ROS Foxy in the terminal (i.e., by commenting out the sourcing command in the `.bashrc` file).

.. 3. Build Cyclone DDS:

..    .. code-block:: bash

..       colcon build --packages-select cyclonedds 

.. 4. Install other dependencies by running the provided install script:

..    .. code-block:: bash

..       sudo chmod +x g1_install.bash && ./g1_install.bash

.. 5. Source the environment:

..    .. code-block:: bash

..       source install/setup.bash
..       source /opt/ros/foxy/setup.bash

.. 6. Build the repository:

..    .. code-block:: bash

..       colcon build --symlink-install 

.. **Network Setup**

.. 1. Connect to the **123** network using a static IP (No DHCP, as it disrupts the network).

.. 2. Note down the network interface name (e.g., `eth0`).

.. 3. Edit and source the `g1_bringup/config/setup.bash` file with the corrected network interface. For example:

..    .. code-block:: bash

..       #!/bin/bash
..       echo "Setup Unitree ROS2 environment"
..       source /opt/ros/foxy/setup.bash
..       source $HOME/ros2_ws/install/setup.bash

..       export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
..       export CYCLONEDDS_URI='<CycloneDDS><Domain><General><Interfaces>
..                                  <NetworkInterface name="eth0" priority="default" multicast="default" />
..                               </Interfaces></General></Domain></CycloneDDS>'

.. 4. Add the above to your `.bashrc` file for persistence.

.. **Verification**


.. 1. Check the available ROS2 topics:

..    .. code-block:: bash

..       ros2 topic list

.. 2. Echo a specific topic (e.g., `/lowstate`):

..    .. code-block:: bash

..       ros2 topic echo /lowstate
