
All ROS2 drivers for the B2W developed by MYBOTSHOP operate with the environment variable **ROS_DOMAIN_ID=10**.
The drivers start automatically on boot using robot_upstart services.

.. note::
   Please ensure the emergency stop is released before powering on the robot.
   The B2 services will start automatically after boot (approximately 1-2 minutes).

Check Driver Status
-------------------

.. code-block:: bash

   sudo systemctl status b2-hardware
   sudo systemctl status b2-webserver

List all B2 services:

.. code-block:: bash

   systemctl list-units --type=service | grep b2

Available Services
------------------

.. list-table::
   :header-rows: 1
   :widths: 30 40 15

   * - Service Name
     - Launch File
     - Auto-Start
   * - b2-hardware
     - hardware.launch.py
     - Yes
   * - b2-statepublisher
     - state_publisher.launch.py
     - Yes
   * - b2-domain-bridge
     - bridge.launch.py
     - Yes
   * - b2-front-video
     - front_video.launch.py
     - Yes
   * - b2-rear-video
     - rear_video.launch.py
     - Yes
   * - b2-twistmux
     - twistmux.launch.py
     - Yes
   * - b2-webserver
     - webserver.launch.py
     - Yes
   * - b2w-description
     - b2w_description.launch.py
     - Yes
   * - b2-livox-mid360
     - livox_mid360.launch.py
     - Yes
   * - b2-pan-tilt
     - dynamixel.launch.py
     - Yes

Service Management
------------------

.. code-block:: bash

   # Start/stop/restart service
   sudo systemctl start b2-<service_name>
   sudo systemctl stop b2-<service_name>
   sudo systemctl restart b2-hardware

   # Enable/disable service at boot
   sudo systemctl enable b2-<service_name>
   sudo systemctl disable b2-<service_name>

   # Reload systemd after config changes
   sudo systemctl daemon-reload

View Service Logs
-----------------

.. code-block:: bash

   # View recent logs for a service
   journalctl -u b2-hardware -n 50

   # Follow logs in real-time
   journalctl -u b2-webserver -f

   # View logs since last boot
   journalctl -u b2-hardware -b

Installing Services
-------------------

Run the startup installer to configure all systemd services:

.. code-block:: bash

   ros2 run b2_bringup startup_installer.py

This installs services using robot_upstart with:

- ROS Domain ID: 10
- RMW Implementation: CycloneDDS
- Workspace setup: ``/opt/mybotshop/src/mybotshop/b2_bringup/config/setup.bash``

Environment Variables
---------------------

.. list-table::
   :header-rows: 1
   :widths: 20 20 40

   * - Variable
     - Default
     - Description
   * - B2_NS
     - b2_unit_001
     - Robot namespace
   * - ROS_DOMAIN_ID
     - 10
     - ROS 2 Domain ID
   * - B2_DESC
     - 1
     - Enable B2 description
   * - B2_Z1
     - 0
     - Enable Z1 arm in URDF

.. note::
   Replace ``b2_unit_001`` with your robot's namespace.
