> For the complete documentation index, see [llms.txt](https://robocre8.gitbook.io/robocre8/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://robocre8.gitbook.io/robocre8/tutorials/how-to-use-the-epmc-with-ros2.md).

# How To Use the EPMC With ROS2

Learn how to test and integrate the Easy IMU (EIMU) in your ROS2 project

<figure><img src="https://1813945869-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvaPba1OWKgmXxFGX8DOE%2Fuploads%2FbYZD1SFGAcaxan9zh2lT%2Fepmc_web_pic_ros.png?alt=media&amp;token=fe0c2713-b8a5-4f2c-ba83-cdb0c109c993" alt=""><figcaption></figcaption></figure>

### Before Using The EPMC in ROS2

* Firstly, ensure you have your **Geared DC motors** connected to the **EPMC Module** and the motor **PID gains** already set up. If not, follow the instructions here \[[link to the post](/robocre8/tutorials/how-to-setup-dc-motor-pid-speed-control-with-the-epmc.md)]
* Also, before you start, it is worth knowing that you can use it with a PC, Raspberry Pi, or any microcomputer running Ubuntu OS and ROS2. You can also use docker (if you can).
* You should also have some experience with ROS2 as a beginner or intermediate user.\
  (e.g. Installing ROS2, setting up ros workspace, building packages with colcon, rosdep, ros topics, rviz, ros transforms, e.t.c)

<figure><img src="https://1813945869-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvaPba1OWKgmXxFGX8DOE%2Fuploads%2Fn2XX8xv6VFiZIpE58cEx%2Fepmc_ros2_connect.png?alt=media&amp;token=3906f88e-d1dd-4298-98cb-46fa05cc9976" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1813945869-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvaPba1OWKgmXxFGX8DOE%2Fuploads%2Fd9U0TGyscaPHxEl6pndf%2Fepmc_connection_full_4wheel.png?alt=media&amp;token=ed4d3011-5f6c-4799-b276-a19c2ef8e49b" alt=""><figcaption></figcaption></figure>

### Using The EPMC in ROS2

* First clone and install the epmc harware plugin package -  [**epmc\_ros\_hw\_plugin**](https://github.com/robocre8/epmc_ros_hw_plugin)**.**&#x20;
* Next clone and install the demo\_bot package -  [**demo\_bot**](https://github.com/robocre8/demo_bot)**.** The demo\_bot package is a test robot for testing the EPMC plugin package. I contains example on how to implement the EPMC ROS2 control on a differential drive robot. (It requires that the epmc hardware interface plugin be installed on your computer)

{% hint style="info" %}
**NOTE:** you can use in place of the demo\_bot your preferred robot where you have already implemented the EPMC ROS2 control.\
You can also make use of the demo\_bot to build your preferred 2 or 4 wheeled differential drive robot.
{% endhint %}

***

Basically, after cloning, installing necessary dependencies, compiling, and installing both packages using `colcon build --symlink-install` , you can quickly follow the steps below to test the EPMC.

* You need to first connect the EPMC Module to your PC (or microcomputer)
* Check the USB port the EPMC Module is connected to and give the port necessary permissions.
* Go to the `epmc_ros2_control.xacro` file found in the **demo\_bot/demo\_bot\_description/urdf/** folder
* change the `port` param file to the USB port found in the second step above\
  **`<param name="port"> {discovered port value} </param>`**&#x20;
* Then ensure the `motorA_wheel_name`  and the `motorB_wheel_name` params properly indicates which port you connected your left and right motor wheel.
* Change the **command interface** velocity **min** and **max** parameter, to that of you Motor (i.e **\*W\_MAX** value during setup)

{% hint style="info" %}
**NOTE:** at this point, you don't need to re-compile and build with colcon if you've built previosly using the **--symlink-install**
{% endhint %}

* open a new terminal (and source your workspace) and launch the **demo\_bot\_base**\
  `ros2 launch demo_bot_base robot.launch.py`&#x20;
* open another terminal (and source your workspace) and launch the **demo\_bot\_rviz** view file\
  `ros2 launch demo_bot_rviz robot.launch.py`&#x20;
* You can drive using the **ros teleop package** or the [**arrow\_key\_teleop\_drive**](https://github.com/samuko-things/arrow_key_teleop_drive) package

<figure><img src="https://1813945869-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvaPba1OWKgmXxFGX8DOE%2Fuploads%2FSfOWTKJfDZLKfBCFdMO7%2Fepmc_ros2_test.gif?alt=media&amp;token=13651ae9-b027-402a-8a3a-ab4c781a1f40" alt=""><figcaption></figcaption></figure>

***

Finally, please chekout and go through the [**mobo\_bot**](https://github.com/robocre8/mobo_bot) package to see proper sample of how combine the **EIMU** with the **EPMC** and ekf sensor-fusion in a mobile robot.
