Mastering Multi-Axis Robotics: A Step-by-Step Guide
In this project, we will configure the AMD Kria™ KR260 Robotics Starter Kit to control a Trossen Robotics ReactorX 150 robot arm. This complex robot arm uses ROBOTIS DYNAMIXEL servos, which contain not only motors but also microcontrollers and networking capability.
Image credit: Trossenrobotics
This article was first published on
resources.mouser.comThis article was written by Adam Taylor for Mouser Electronics
Introduction
In this project, we will configure the AMD Kria™ KR260 Robotics Starter Kit to control a Trossen Robotics ReactorX 150 robot arm. This complex robot arm uses ROBOTIS DYNAMIXEL servos, which contain not only motors but also microcontrollers and networking capability. While this enables the complex motor drives needed for robotics applications, it also means that each servo has several different drive and control mechanisms. Typically, when working with servos and robotics applications of this complexity, significant processing is required to plan and address the robotic movement.
To interact with and control such robots, engineers often use the Robot Operating System (ROS), which runs on Linux. The most used version of ROS is ROS 2, which updated the ROS frameworks and tools to work with a wider variety of environments, provide support for real-time environments, and use significantly updated APIs. ROS 2 provides developers with functionalities such as hardware drivers, robot models, datatypes, and support for perception and simultaneous localization and mapping (SLAM). ROS 2 also provides a series of tools that aid in the development or operation of systems such as RViz, which provides a 3D visualization, and Gazebo, a simulator.
ROS 2 is built around a graph architecture; within this architecture, processing takes place in nodes that can receive and post data about the node, such as sensor, control, planning, actuator positioning, or current state. Nodes are connected on the ROS graph by topics, which are communication pipelines to which nodes can publish data and receive information. Along with nodes and topics, a node may also advertise services. The services have a single result, such as capturing a frame of video, sampling a sensor, or opening an actuator.
Bill of Materials
- AMD Kria™ KR260 Robotics Starter Kit
- Monitor with DisplayPort™ compatibility
- USB keyboard and mouse
- ROBOTIS ReactorX In150 robotic arm
Resources
- Ubuntu Linux distribution image for the AMD Kria™ KR260 Robotics Starter Kit (Ubuntu)
- Getting Started with the AMD Kria KR260 Robotics Starter Kit (AMD)
- VcXsrv Windows X Server Files
Software Setup
In this project, we will install the Trossen Robotics packages and ROS 2 on the AMD Kria™ KR260 Robotics Starter Kit, which will enable you to control the robot arm.
Installing Ubuntu
Start by downloading and installing the Ubuntu Linux distribution image for the AMD Kria™ KR260 kit, available in the Resources section. Once the image is available, flash the image to an SD card following the instructions provided by AMD in Getting Started with Kria KR260 Robotics Starter Kit in the Resources section.
Once you have successfully booted the AMD Kria KR260 kit, you will need to update the Ubuntu installation to ensure we can install ROS 2 correctly.
- Install resolvconf.
sudo apt update
sudo apt install resolvconf
- With resolvconf installed, ensure it is running.
sudo systemctl status resolvconf.service
- Once you have confirmed the service is running, add your preferred DNS server. In this example, we use Googles DNS.
echo "nameserver 8.8.8.8" | sudo tee -a /etc/resolvconf/resolv.conf.d/head
echo "nameserver 8.8.4.4" | sudo tee -a /etc/resolvconf/resolv.conf.d/head
- Because we made changes, we need to restart the services.
sudo systemctl restart resolvconf.service
sudo systemctl restart systemd-resolved.service
- Prevent Ubuntu on the KR260 from going to sleep.
sudo gsettings set org.gnome.desktop.session idle-delay 0
sudo systemctl mask suspend.target
Installing ROS 2
To install ROS 2 and the packages to control the Trossen Robotics X Series arm, we will modify the instructions slightly to those used for the Raspberry Pi, which, like the AMD Kria™ KR260 kit, uses the Arm64 (aarch64) instruction set architecture.
The latest version of ROS 2 supported by Trossen’s libraries is ROS 2 Humble. Use the following commands to install ROS 2 and the Trossen libraries:
cd ~
sudo apt install curl
curl 'https://raw.githubusercontent.com/Interbotix/interbotix_ros_manipulators/main/interbotix_ros_xsarms/install/rpi4/xsarm_rpi4_install.sh' > xsarm_rpi4_install.sh
sed -i 's/sudo apt-get update && sudo apt -y upgrade/sudo apt-get update/g' xsarm_rpi4_install.sh
chmod +x xsarm_rpi4_install.sh
./xsarm_rpi4_install.sh -d humble -j rx150
Demo Application
With ROS 2 installed on the AMD Kria™ KR260 kit, we will run one of the provided demo applications. Open two terminal windows on the KR260.
- In the first terminal window, enter the following command:
ros2 launch interbotix_xsarm_control xsarm_control.launch.py robot_model:=rx150
- In the second terminal, enter the following command:
python3 /home/ubuntu/interbotix_ws/src/interbotix_ros_manipulators/interbotix_ros_xsarms/interbotix_xsarm_control/demos/python_ros2_api/bartender.py
This will run an application that demonstrates the control of the robot arm.
Demo Breakdown
By examining the code in this application, we can see how we can control the arm using the Python programming language. First, we need to import the InterbotixManipulatorXS arm package from the InterbotiX libraries we installed. To do this, enter the following command: from interbotix_xs_modules.arm import InterbotixManipulatorXS
With these packages installed, we can start creating applications that manipulate the arm using a Python application.
Looking at the example code, we can see the first thing we do is initialize it with the parameters of the robot, the model, type, and its end effector.
With the robot (shown as bot
in the code) defined, the application first checks the robot has the correct number of joints for the demo. Once it has been confirmed as being suitable for the demo, the robot is controlled by using several Python commands that set the pose, or single positions, as required. The gripper can also be opened and closed using Python calls.
bot = InterbotixManipulatorXS("rx150", "arm", "gripper")
if (bot.arm.group_info.num_joints < 5):
print('This demo requires the robot to have at least 5 joints!')
sys.exit()
bot.arm.set_ee_pose_components(x=0.3, z=0.2)
bot.arm.set_single_joint_position("waist", np.pi/2.0)
bot.gripper.open()
bot.arm.set_ee_cartesian_trajectory(x=0.1, z=-0.16)
bot.gripper.close()
Finally, the demo ends by safely positioning the robot to its home position.
bot.arm.go_to_home_pose()
bot.arm.go_to_sleep_pose()
Knowing this, we can start creating own custom applications, as shown in this video. But first, we need to be able to remotely develop applications on the AMD Kria™ KR260 board.
Remote Development
To develop our remote application, we will use Visual Studio Code on the development machine. The Python application we create using Visual Studio Code on our development machine will be in the file system of the AMD Kria™ KR260 kit. This also has the benefit of requiring no connected display, keyboard, or mouse, as we can access everything from the development environment.
We also want to be able to remotely view the visualization of the robot arm as we develop our application (in simulation mode or actual execution).
To enable remote development and visualization, we must establish SSH connection and enable X11 forwarding.
- Use Windows Powershell to install OpenSSH using the following commands.
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
# Start the sshd service
Start-Service sshd
# OPTIONAL but recommended:/code>
Set-Service -Name sshd -StartupType 'Automatic'
# Confirm the Firewall rule is configured. It should be created automatically by setup. Run the following to verify
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..."
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
} else {
Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
}
- With OpenSSH installed, create a key using the following command.
ssh-keygen
By default, the system will save the keys to C:\Users\<user>/.ssh/id_rsa.
- Exchange keys using the following command.
type $env:USERPROFILE\.ssh\id_rsa.pub | ssh ubuntu@<board_ip> "cat >> .ssh/authorized_keys"
To establish a SSH connection from Visual Studio Code, we must first install the remote SSH option from the extensions (Figure 1).
Once this is installed, we can connect to the AMD Kria KR260 board (Figure 2), which will allow us to develop our applications remotely in the KR260 file system.
To be able to use X11 forwarding, we must first install cXsrv Windows X Server (available in the Resources section) on our development machine. Run X Server and configure it. For screenshots fo this setup see here.
Connect to the display by running the following command in a command window on the development machine:
set DISPLAY=127.0.0.1:0.0
We can then initiate an SSH connection with the AMD Kria KR260 board and start developing our robot application.
ssh -Y <user>@<board_ip>
As this runs, the robot arm will move and you will see a visualization of this movement on X Server (Figure 7).
Wrap Up
Robotics can be complicated. In this project, we have seen that the AMD Kria™ KR260 kit can enable rapid development of robotic solutions using ROS 2. The KR260 provides the ability to accelerate features within the programmable logic element or to integrate further system control elements such as time-sensitive networking within the programmable logic.
AMD, and the AMD Arrow logo, Kria, and combinations thereof are trademarks of Advanced Micro Devices, Inc. Other product names used herein are for identification purposes and may be trademarks of their respective owners.