Skip to content

Commit

Permalink
Simplify installation
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal-gorecki committed Apr 5, 2024
1 parent 9e5897c commit 991417d
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 162 deletions.
148 changes: 56 additions & 92 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Available models:
| `rosbot_xl` | Final configuration of rosbot_xl with ability to attach external hardware. |
| `rosbot_xl_base` | Base of rosbot prepared to be included into preexisting configuration. Meant to be compatible with concept of ROS Industrial ability for manipulators to have interchangeable end effectors. |


### `rosbot_xl_gazebo`

Launch files for Ignition Gazebo working with ROS2 control.
Expand All @@ -48,100 +47,90 @@ For detailed instructions refer to the [rosbot_xl_firmware repository](https://g

## Prepare environment

1. **Install `colcon`, `vsc` and `rosdep`**
```
sudo apt-get update
sudo apt-get install -y ros-dev-tools stm32flash
```
1. **Install `ros-dev-tools` and `stm32flash`** (`stm32flash` is not in the ros index and should be installed manually).

2. **Create workspace folder and clone `rosbot_xl_ros` repository:**
```
mkdir -p ros2_ws/src
cd ros2_ws
git clone https://github.com/husarion/rosbot_xl_ros src/
```
```bash
sudo apt-get update
sudo apt-get install -y ros-dev-tools stm32flash
```

### Build and run on hardware
2. **Create workspace folder and clone `rosbot_xl_ros` repository.**

1. **Building**
```
export HUSARION_ROS_BUILD=hardware
```bash
mkdir -p ros2_ws/src
cd ros2_ws
git clone https://github.com/husarion/rosbot_xl_ros src/
```

source /opt/ros/$ROS_DISTRO/setup.bash
3. **Specify build type.**

The repository is used to run the code both on the real robot and in the simulation. Specify `HUSARION_ROS_BUILD_TYPE` the variable according to your needs.

vcs import src < src/rosbot_xl/rosbot_xl_hardware.repos
**Hardware**:

# Remove tests from micro_ros_msgs
sed '/if(BUILD_TESTING)/,/endif()/d' src/micro_ros_msgs/CMakeLists.txt -i
``` bash
export HUSARION_ROS_BUILD_TYPE=hardware
```

rm -r src/rosbot_xl_gazebo
**Simulation**:

```bash
export HUSARION_ROS_BUILD_TYPE=simulation
```

### Build from source

```bash
source /opt/ros/$ROS_DISTRO/setup.bash
vcs import src < src/rosbot_xl/rosbot_xl_$HUSARION_ROS_BUILD.repos
# Copy only diff_drive_controller and imu_sensor_broadcaster, waits for features from ros2-control
cp -r src/ros2_controllers/diff_drive_controller src/
cp -r src/ros2_controllers/imu_sensor_broadcaster src/
rm -rf src/ros2_controllers
# stm32flash is not in the ros index and should be installed manually
sudo apt install stm32flash
rosdep init
rosdep update --rosdistro $ROS_DISTRO
rosdep install -i --from-path src --rosdistro $ROS_DISTRO -y
colcon build
colcon build --symlink-install --packages-up-to rosbot-xl --cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF
```

> [!NOTE]
> Before starting the software on the robot please make sure that you're using the latest firmware and run the `micro-ROS` agent as described in the [Usage on hardware](#usage-on-hardware) step.
2. **Running**

Flash firmware.
```bash
# Get admin permissions to flash firmware
sudo su
source install/setup.bash
ros2 run rosbot_xl_utils flash_firmware
exit
```

```
source install/setup.bash
ros2 launch rosbot_xl_bringup combined.launch.py
```

### Build and run Gazebo simulation
### Running
1. **Building**
```
export HUSARION_ROS_BUILD=simulation
**Hardware**:
source /opt/ros/$ROS_DISTRO/setup.bash
1. Flash firmware.
vcs import src < src/rosbot_xl/rosbot_xl_hardware.repos
vcs import src < src/rosbot_xl/rosbot_xl_simulation.repos
```bash
# Get admin permissions to flash firmware
sudo su
source install/setup.bash
ros2 run rosbot_xl_utils flash_firmware
exit
```
# Remove tests from micro_ros_msgs
sed '/if(BUILD_TESTING)/,/endif()/d' src/micro_ros_msgs/CMakeLists.txt -i
2. Launch robot
# Copy only diff_drive_controller and imu_sensor_broadcaster, waits for features from ros2-control
cp -r src/ros2_controllers/diff_drive_controller src/
cp -r src/ros2_controllers/imu_sensor_broadcaster src/
rm -rf src/ros2_controllers
```bash
source install/setup.bash
ros2 launch rosbot_xl_bringup combined.launch.py
```
rosdep init
rosdep update --rosdistro $ROS_DISTRO
rosdep install -i --from-path src --rosdistro $ROS_DISTRO -y
colcon build
```
**Simulation**:
2. **Running**
```
```bash
source install/setup.bash
ros2 launch rosbot_xl_gazebo simulation.launch.py
```
## Testing package
## Developer info
### pre-commit
[pre-commit configuration](.pre-commit-config.yaml) prepares plenty of tests helping for developing and contributing. Usage:
```bash
Expand All @@ -151,7 +140,7 @@ pip install pre-commit
# initialize pre-commit workspace
pre-commit install
# manually run tests
# manually run pre-commit hooks
pre-commit run -a
# update revision
Expand All @@ -161,49 +150,24 @@ pre-commit autoupdate
After initialization [pre-commit configuration](.pre-commit-config.yaml) will applied on every commit.
### Industrial CI
```
colcon test
```

> [!NOTE]
> Command `colcon test` does not build the code. Remember to build your code after changes.
If tests finish with errors print logs:
```
colcon test-result --verbose
```

### Format python code with [Black](https://github.com/psf/black)
```
cd src/
black rosbot*
```

## Testing package

### Industrial CI
```
```bash
colcon test
```
> [!NOTE]
> Command `colcon test` does not build the code. Remember to build your code after changes.
If tests finish with errors print logs:
```
colcon test-result --verbose
```
### Format python code with [Black](https://github.com/psf/black)
```
cd src/
black rosbot*
```bash
colcon test-result --verbose
```
## Demos
For further usage examples check out our other repositories:
* [`rosbot-xl-docker`](https://github.com/husarion/rosbot-xl-docker) - Dockerfiles for building hardware and simulation images
* [`rosbot-xl-gamepad`](https://github.com/husarion/rosbot-xl-gamepad) - simple teleoperation using a gamepad
* [`rosbot-xl-mapping`](https://github.com/husarion/rosbot-xl-mapping) - creating a map of the environment using slam_toolbox
Expand Down
79 changes: 51 additions & 28 deletions ROS_API.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,70 @@
# ROS API

Detailed information about content of rosbot_xl package for ROS2.

## rosbot_xl_bringup

Use `bringup.launch.py` from `rosbot_xl_bringup` to start all base functionalities for ROSbot XL. It consists of the following parts:
- `scan_to_scan_filter_chain` from `laser_filters`, it subscribes to `/scan` topic and removes all points that are within the robot's footprint (defined by config `laser_filter.yaml` in `rosbot_xl_bringup` package). Filtered laser scan is then published on `/scan_filtered` topic

**Subscribes**
- `/scan` (_sensor_msgs/LaserScan_)
### External Nodes

#### scan_to_scan_filter_chain

`scan_to_scan_filter_chain` from `laser_filters`, it subscribes to `/scan` topic and removes all points that are within the robot's footprint (defined by config `laser_filter.yaml` in `rosbot_xl_bringup` package). Filtered laser scan is then published on `/scan_filtered` topic

**Publishes**
- `/scan_filtered` (_sensor_msgs/LaserScan_)
##### Subscribes

- `ekf_node` from `robot_localization`, it is used to fuse wheel odometry and IMU data. Parameters are defined in `ekf.yaml` in `rosbot_xl_bringup/config`. It subscribes to `/rosbot_xl_base_controller/odom` and `/imu_broadcaster/imu` published by ros2 controllers and publishes fused odometry on `/odometry/filtered` topic
- `/scan` (_sensor_msgs/LaserScan_)

**Subscribes**
- `/rosbot_xl_base_controller/odom` (_nav_msgs/Odometry_)
- `/imu_broadcaster/imu` (_sensor_msgs/Imu_)
##### Publishes

**Publishes**
- `/tf` (_tf2_msgs/TFMessage_) - `base_link`->`odom` transform
- `/odometry/filtered` (_nav_msgs/Odometry_)
- `/scan_filtered` (_sensor_msgs/LaserScan_)

#### ekf_node

- `controller.launch.py` from `rosbot_xl_controller`, it loads robot model defined in `rosbot_xl_description` as well as ros2 control [rosbot_hardware_interfaces](https://github.com/husarion/rosbot_hardware_interfaces). It also starts controllers:
* `joint_state_broadcaster`
* `rosbot_xl_base_controller` - depending on the value of `mecanum` argument it can be `DiffDriveController` or `MecanumDriveController`
* `imu_broadcaster`
`ekf_node` from `robot_localization`, it is used to fuse wheel odometry and IMU data. Parameters are defined in `ekf.yaml` in `rosbot_xl_bringup/config`. It subscribes to `/rosbot_xl_base_controller/odom` and `/imu_broadcaster/imu` published by ros2 controllers and publishes fused odometry on `/odometry/filtered` topic

**Subscribes**
- `/cmd_vel` (_geometry_msgs/Twist_)
- `/_motors_responses` (_sensor_msgs/JointState_)
- `/_imu/data_raw` (_sensor_msgs/Imu_)
##### Subscribes

**Publishes**
- `/tf` (_tf2_msgs/TFMessage_)
- `/tf_static` (_tf2_msgs/TFMessage_)
- `/_motors_cmd` (_std_msgs/Float32MultiArray_)
- `/rosbot_xl_base_controller/odom` (_nav_msgs/Odometry_)
- `/imu_broadcaster/imu` (_sensor_msgs/Imu_)
- `/rosbot_xl_base_controller/odom` (_nav_msgs/Odometry_)
- `/imu_broadcaster/imu` (_sensor_msgs/Imu_)

##### Publishes

- `/tf` (_tf2_msgs/TFMessage_) - `base_link`->`odom` transform
- `/odometry/filtered` (_nav_msgs/Odometry_)

#### micro_ros_agent
Use `micro_ros_agent` to communicate with Digital Board, it provides the following interface:

**Subscribes**
#### Subscribes

- `/_motors_cmd` (_std_msgs/Float32MultiArray_)

#### Publishes

**Publishes**
- `/_motors_responses` (_sensor_msgs/JointState_)
- `/_imu/data_raw` (_sensor_msgs/Imu_)
- `/battery_state` (_sensor_msgs/BatteryState_)

## rosbot_xl_controller

`controller.launch.py` from `rosbot_xl_controller`, it loads robot model defined in `rosbot_xl_description` as well as ros2 control [rosbot_hardware_interfaces](https://github.com/husarion/rosbot_hardware_interfaces). It also starts controllers:

- `joint_state_broadcaster`
- `rosbot_xl_base_controller` - depending on the value of `mecanum` argument it can be `DiffDriveController` or `MecanumDriveController`
- `imu_broadcaster`

#### Subscribes

- `/cmd_vel` (_geometry_msgs/Twist_)
- `/_motors_responses` (_sensor_msgs/JointState_)
- `/_imu/data_raw` (_sensor_msgs/Imu_)

#### Publishes

- `/tf` (_tf2_msgs/TFMessage_)
- `/tf_static` (_tf2_msgs/TFMessage_)
- `/_motors_cmd` (_std_msgs/Float32MultiArray_)
- `/rosbot_xl_base_controller/odom` (_nav_msgs/Odometry_)
- `/imu_broadcaster/imu` (_sensor_msgs/Imu_)
4 changes: 2 additions & 2 deletions rosbot_xl/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
<buildtool_depend>ament_cmake</buildtool_depend>

<depend>rosbot_xl_bringup</depend>
<depend>rosbot_xl_description</depend>
<depend>rosbot_xl_controller</depend>

<depend>rosbot_xl_description</depend>
<depend condition="$HUSARION_ROS_BUILD == simulation">rosbot_xl_gazebo</depend>
<depend condition="$HUSARION_ROS_BUILD == hardware">rosbot_xl_utils</depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down
14 changes: 13 additions & 1 deletion rosbot_xl/rosbot_xl_simulation.repos
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
repositories:
husarion/husarion_office_gz:
husarion_controllers:
type: git
url: https://github.com/husarion/husarion_controllers
version: main
husarion_office_gz:
type: git
url: https://github.com/husarion/husarion_office_gz
version: main
ros_components_description:
type: git
url: https://github.com/husarion/ros_components_description.git
version: ros2
ros2_controllers:
type: git
url: https://github.com/delihus/ros2_controllers
version: humble
4 changes: 2 additions & 2 deletions rosbot_xl_bringup/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

<exec_depend>laser_filters</exec_depend>
<exec_depend>robot_localization</exec_depend>
<exec_depend>micro_ros_agent</exec_depend>
<exec_depend condition="$HUSARION_ROS_BUILD == hardware">micro_ros_agent</exec_depend>

<!-- Microros agent build dependency-->
<build_depend>git</build_depend>
<build_depend condition="$HUSARION_ROS_BUILD == hardware">git</build_depend>

<test_depend>rclpy</test_depend>
<test_depend>python3-pytest</test_depend>
Expand Down
2 changes: 1 addition & 1 deletion rosbot_xl_controller/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<exec_depend>rosbot_xl_description</exec_depend>
<exec_depend>ros_components_description</exec_depend>
<exec_depend>rosbot_hardware_interfaces</exec_depend>
<exec_depend condition="$HUSARION_ROS_BUILD == hardware">rosbot_hardware_interfaces</exec_depend>
<exec_depend>mecanum_drive_controller</exec_depend>

<exec_depend>xacro</exec_depend>
Expand Down
Loading

0 comments on commit 991417d

Please sign in to comment.