Software apps and online services
The world of robotics is great for the application Heterogeneous SoC which combine programmable and processor systems. One of the most popular Robot Operating Systems is ROS 2
For those unfamiliar with ROS 2, the first thing to explain is that, although it is called the Robotic Operating System, it’s not an operating system. It’s actually a framework of libraries and utilities that enable the creation of scalable robotic solutions that alleviate the need to always start from scratch. There are three key elements at the core of ROS:
- A framework to create distributed robotic applications that communicate between sub-elements of the design (e.g., sensors, motor drive etc.). These sub-elements are called nodes.
- Tools that help develop the application (e.g., simulation, 3D visualization, graphing, and plotting).
- Support for third-party plug ins to add functionality for applications.
I came across the Kria Robotics Stack (KRS) on the Xilinx GitHub Page. KRS is a subset of the Robotic Operating System (ROS 2) which enables developers to leverage the acceleration provided by programmable logic. This is an interesting area for developers of robotic solutions because the acceleration can provide a significant boost to performance without a significant increase in power and costs.
It’s the third-party plug ins that enable KRS to augment ROS 2. These provide a series of extensions to the build system and meta build tools and enable support for acceleration. Xilinx defines its extensions as having three pillars:
- Extension of the ROS 2 build system (ament) to support the creation of acceleration kernels.
- Extension of the ROS 2 meta build system (colcon) to integrate and manage the acceleration flows into the ROS 2 CLI.
- Provision of a firmware layer to provide necessary support for compilation of the kernels.
As illustrated in the diagram below, the KRS components support acceleration of navigation, manipulation, perception, and actuation stacks. As you would expect, at the heart of the KRS is Vitis with its ability to accelerate applications from processing system to programmable logic.
In this project we are going to build the KRS for the TurtleBot3 waffle. The first stage in the development is to create a development machine which we can install ROS 2 and KRS and all the necessary packages for the TurtleBot3Virtual Machine
To get started I created a Virtual Machine which was running Ubuntu 20.04 Focal Fossa. On to this machine I installed
We can install the Xilinx KRS by using the commands below in a terminal window.
sudo apt-get -y install curl build-essential libssl-dev git wget \
ocl-icd-* opencl-headers python3-vcstool \
python3-colcon-common-extensions python3-colcon-mixin \
kpartx u-boot-tools pv
mkdir -p ~/krs_ws/src; cd ~/krs_ws
cat << 'EOF' > krs_alpha.repos
vcs import src --recursive < krs_alpha.repos
source /tools/Xilinx/Vitis/2020.2/settings64.sh # source Xilinx tools
source /opt/ros/foxy/setup.bash # Sources system ROS 2 installation.
# Note: The path above is valid if one installs ROS 2 from a pre-built
# package. If one builds ROS 2 from the source the directory might
# vary (e.g. ~/ros2_foxy/ros2-linux).
export PATH="/usr/bin":$PATH # FIXME: adjust path for CMake 3.5+
colcon build --merge-install # about 2 mins
The Turtlebot2 communicates over Serial Ports, therefore once KRS is installed we need to create a new petalinux project using the KV260 BSP and update the kernel to support both TTYACM and TTYUSB. TTYACM uses the Linux Serial Modem Driver while and TTYUSB uses the USB to Serial port driver. We can do this in the kernel under drivers / USB Support
Ensure both USB Modem and USB Generic Serial Driver are enabled
Rebuild the kernel and copy it to the KRS Workspace, Acceleration/Firmaware/KV260/Kernel directory
This means when we build the SD Card image for the TurtleBot3 Waffle we use a kernel which supports its Serial communications.TurtleBot3 ROS 2 Build
The next step is to take add in the necessary ROS 2 packages for the TurtleBot3 to the KRS we can do this using the commands
Once we have the repos we can import the source
vcs import src < turtlebot3.repos
As we are not running simulations we delete the TurtleBot Simulations as it may cause build errors
We are now ready to build the image and finally SD Card. Issue the command below plus include all of the TurtleBot3 packages.
colcon build --build-base=build-kv260 --install-base=install-kv260 --merge-install --mixin kv260 --packages-select ament_vitis vadd_publisher turtlebot3_bringup turtlebot3_node turtlebot3_teleop turtlebot3_navigation2 turtlebot3_description turtlebot3_cartographer turtlebot3_msgs dynamixel_sdk hls_lfcd_lds_driver turtlebot3 turtlebot3_example
Once the build has completed we are able to create the SD Card image using the following commands
colcon accelerate select kv260
colcon accelerate linux vanilla --install-dir install-kv260-new
The SD Card Image will be available under workspace/acceleration/firmware/select directory
Install this on a SD Card.Hardware
The next step is to retrofit the KV260 onto to the Waffle this can be done with a little rearrangement of the Open CR Board and connections for the USB LIDAR and Motors.
For this project I am going to keep the project tethered over ethernet as I am still working on the WIFI side of things.
As the KV260 will operate from the batter voltage I updated the battery cable to connect to also have a plug to connect to the KV260. I did this by purchasing a additional cable which had one socket and two plugs and remoting one of the plugs and replacing it with one which would fit the KV260.
A little solder is then required.
Once this is build we are ready to go, and can re assemble the robot, remember when we plug in the battery the system will boot and start working.Operating the Robot
To operate the robot initially we will use teleop to command it, to get started with this we will need the two terminal windows connected to the Kria over Ethernet
In the first terminal we are going to bring up the Robot using the commands
sudo chmod a+rw /dev/ttyACM0
RMW_IMPLEMENTATION=rmw_cyclonedds_cpp ros2 launch turtlebot3_bringup robot.launch.py
Following these commands you will see the TutrleBot Start up
In the second window we can enter the commands
ros2 run turtlebot3_teleop teleop_keyboard
This will give us a number of keys which can be used to drive the TurtleBot3 around the office.
When I did this in my office it worked pretty well
Now we have the KV260 TurtleBot3 up and running the next step is to start looking at what we can accelerate using the Kria Robotics Stack.