Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
Getting started with the K79 imaging radar
Description: Guide for setup and initial testing of K79 with ROSTutorial Level: BEGINNER
Next Tutorial: Configuring and updating firmware for K79
Contents
Installing ROS
First, follow official ROS installation guide for your linux distribution - each version of Ubuntu has a recommended version of ROS, choose from the options below. Using ROS on Windows is possible as of this writing, but not recommended or supported; please use a linux (preferably Ubuntu) machine instead. It should be possible to run Ubuntu in a Virtual Machine (VM) from Windows, or dual-boot Ubuntu alongside Windows.
ROS Kinetic Kame |
ROS Melodic Morenia |
ROS Noetic Ninjemys |
Connecting the radar
First, power on and connect the radar according to the following:
- Connect the power plug to the interface on the side of the radar, pushing until it clicks.
- To remove the power plug in the future, pull both the red tab and the plug itself (this requires a moderate amount of force).
- To remove the power plug in the future, pull both the red tab and the plug itself (this requires a moderate amount of force).
- Connect the Ethernet plug to the back of the radar, aligning the red marking on plug and radar and pushing until it clicks.
Supply 12V DC power to the radar. The nominal current draw is roughly 0.3A when connected but not transmitting detections. During operation, the current can be as high as 1.0A depending on number of detection.
Setting up your computer to communicate with the radar
By default, the radar transmits data packets via UDP to IP address 10.0.0.75, however this (and other network parameters) can be reconfigured at a later step in this tutorial. The network interface for communicating with the radar can be set up either graphically with the Gnome network manager GUI or by modifying the system networking files; see below for both approaches.
Network configuration via Gnome GUI
This process varies slightly depending on the version of Ubuntu being used, but the settings remain the same. Choose to add a new wired interface in your network interface settings by navigating to Settings > Network and clicking the + icon next to Wired (Ubuntu 18.04) or by choosing Edit Connections... in the dropdown menu from the network icon in the upper toolbar and clicking the Add button.
Name the connection and choose the Ethernet device to be used from the dropdown list (this will vary between computers, on the TX2 it is eth0. Be careful to choose the correct interface if your machine has more than one Ethernet port):
Then, switch to the IPv4 Settings tab and set connection method to manual (static) with the following properties:
Click Save and close the network manager windows, then connect to the network by choosing it from the list of valid connections. You should now be able to open a terminal and ping 10.0.0.10 and see the following:
Network configuration via interfaces file
For an embedded application, you likely wish to configure different networking interfaces (eg CAN, Ethernet, WiFi) manually at boot via the /etc/network/interfaces file. To do this, edit the file and add the following, replacing eth0 with the name of your Ethernet interface:
auto eth0 iface eth0 inet static address 10.0.0.75 netmask 255.255.255.0 gateway 0.0.0.0
After adding this to /etc/network/interfaces, either reboot the system or reload the interface with
sudo ifdown eth0 && sudo ip addr flush eth0 && sudo ifup eth0
Then confirm that ping 10.0.0.10 works as expected.
Installing the ainstein_radar ROS packages
Once ROS is installed and you've gone through some of the basic usage tutorials, you can clone and build the ainstein_radar package from GitHub:
First, navigate to the source directory of your catkin workspace, typically located at ~/catkin_ws/, with:
cd ~/catkin_ws/src/
Now, clone the package:
git clone https://github.com/AinsteinAI/ainstein_radar.git
Once the package has been cloned to the source directory, back out to the catkin workspace root directory and update your dependencies for the new package:
cd .. rosdep install --from-paths src --ignore-src --rosdistro=melodic
where MELODIC should be changed if you have a different ROS version installed. This may prompt you to agree to install dependencies.
In case you run into rosdep errors, these are the packages which need to be installed with apt as of this writing:
sudo apt install ros-melodic-pcl-ros ros-melodic-can-msgs ros-melodic-tf2-sensor-msgs ros-melodic-socketcan-bridge ros-melodic-jsk-recognition-msgs ros-melodic-vision_msgs
Now, you can build all the packages (including the new one) by first re-sourcing the environment setup script and using the catkin_tools package to build:
source devel/setup.bash catkin build
Open a new terminal and try roscd ainstein_radar and you should be brought to the root of the ainstein_radar metapackage, likely at ~/catkin_ws/src/ainstein_radar/ainstein_radar. You're now ready to use the nodes provided by the Ainstein packages!
Running the ROS node
Once the radar responds to ping commands, you can attempt to run the K79 ROS node. This is most easily done via an accompanying launch file in ainstein_radar_drivers; see below:
Once the node is running, you should be able to see data streaming with rostopic echo as below:
K79 coordinate frame
The coordinate frame of the K79 (and other Ainstein radars) is defined as follows:
- The sensor coordinate frame is x-forward, y-left and z-up, with positive azimuth angle measured around positive z-axis.
- Range is the distance in meters from the radar to the detection along the axis defined by the azimuth angle.
- Speed is measured in meters per second along the axis defined by the azimuth angle, with positive speed integrating to positive range (moving away from the sensor) and vice versa.
See the diagram below for clarification:
By default, radar data is published in the "map" frame for simplicity, however the frame_id node parameter allows changing the data frame in ROS.
Viewing data in RViz
Once the ROS node is running (check rosnode list to be sure), you can open RViz and view the data using the RViz plugins for radar data (built/installed as part of the ainstein_radar package). To open RViz, in a new terminal run:
rosrun rviz rviz
Click the Add button at the bottom of the Displays panel (on the left by default). In the window that opens, select to add a display "By topic" as shown below:
You should now see a new display for the RadarTargetArray message type in the Displays panel on the left, and red markers indicating radar detections (targets) similar to below: