When running a map using ROS for the first time, you are in a position where you need to move your robot around that map. There are some packages already implemented that publish velocity data to the /cmd_vel topic. Probably you already heard about the teleop_twist_keyboard, made by Graylin Trevor Jay and published on ros.org here
The teleop_twist_keyboard works on terminal and reads input from the keyboard. Those inputs are then published to Twist.
Using the teleop_twist_keyboard, this post shows how to create your own ros joystick using a QT GUI. QT is a very famous multiplatform framework used to create modern UIs & applications for multiple screens.
If you know about ROS you probably know about rVIz. This tool is now based in QT framework and can be used as a library to create your own “rViz interface” to manage your roborts, all using QT.
So, it looks like a good idea to start using QT for our ros interfaces.
- ROS (I am using Melodic)
- QT Creator (configured to be called from terminall)
- C++ dependencies
- QT Create
- QT build
To install QT Creator and get it autoconfigured to be used from the terminal, install the following:
sudo apt-get install qtcreator
If it works, you can now call it from terminal using:
To install l C++ dependencies to use QT with ROS, install the following:
sudo apt-get install ros-melodic-qt-create
sudo apt-get install ros-melodic-qt-build
Create a package based in QT
The easiest way to start building a QT Gui with ROS is using the qt_create package. Reference here.
To use this package, go to your ros workspace and run the following using a terminal:
In this case ros_joystick is the name of the package.
This command will create a QT Gui that connects to a ROS master and publish a topic which is printed using a log. The code created can be removed or changed, what we want is just the architecture created.
First thing to do when creating a package this way is to build it. So go to you ros workspace and run:
This way you’ll have now a build folder with your new package, this build folder will be used in QT to reference your package.
To work with it you MUST open QT from terminal (be sure the package has been build). Go to your ROS workspace and call it using this:
From qtcreator, do the following:
Go to your package folder and select the CMakeLists.txt
Select Configure Project
If it fails building, go to PROJECTS section on left panel
Change the build directory, select the location where your package is build (inside your catkin workspace in folder build)
If it still fails, close QT creator and open it again from terminal
Once you have a package created with a ROS-QT architecture, you can apply all modifications you need.
Check my ros_joystick repository here.
This is my project tree:
Take in consideration that changes must be reflected in packages.xml and CMakeLists.txt
The right side of the ros_joystick is useless. It can be used to create or navigate the robot to an specific location.