Moving The P3DX In Gazebo
Prerequisites: Ubuntu, Gazebo, and ROS
Our tutorials were made using Ubuntu 12.04 LTS. In order to move the P3-DX in Gazebo you will have to install Gazebo, you can do that here. In order to move the P3-DX in Gazebo, you must first install ROS. In our tutorial we used ROS Hydro. You can install ROS Hydro from here.
Obtaining the P3-DX model
Git clone P3-DX model from https://github.com/SD-Robot-Vision/PioneerModel.git
$ git clone https://github.com/SD-Robot-Vision/PioneerModel.git
Install the P3-DX model in your catkin_ws by following the steps in the README of the git repository.
Get code for moving the P3-DX
The code you will use to move the P3-DX is in a ROS package on Github. First clone the package from Github into your catkin_ws.
$ git clone https://github.com/SD-Robot-Vision/p3dx_mover.git
Now use catkin_make after cd-ing into your catkin_ws.
$ roscd $ cd .. $ catkin_make
Controlling the P3-DX via keyboard input
The following section will cover controlling the P3-DX using the source you have cloned from Github. In the p3dx_mover package you set up in your catkin_ws, there is a program to move the P3-DX in Gazebo using popen(), and a program to move the P3-DX in Gazebo using a ROS publisher. Using the ROS publisher is the preferred method. The popen() method makes use of publishing messages through the command-line to the topic controlling the velocity of the P3-DX, the program works but only takes inputs after a delay.
Controlling the P3-DX through a program that uses the ROS publisher
Here we will go over how to control the P3-DX using the preferred program. In order to control the P3-DX, first run roscore:
Next launch the world containing the P3-DX model by first cd-ing into the ua_ros_p3dx package in your catkin_ws, and then executing:
$ roslaunch p3dx_gazebo/launch/gazebo.launch
Finally, to control the P3-DX, execute:
$ rosrun p3dx_mover mover.py
Now you can control the P3-DX in the Gazebo simulation with your arrow keys (Note that the character values obtained from pressing keys on your keyboard vary with your operating system. The program runs properly with Ubuntu 12.04 LTS, but the getch.py file must be changed if different character values are received for pressing the arrow keys with your OS). Press 'q' to quit the program when you are done. Then use 'Ctrl-C' to get out of roscore and Gazebo in the respective terminals.
Controlling the P3-DX through a program that uses popen()
INCLUDE A DEMO VIDEO