Difference between revisions of "Moving The P3DX In Gazebo"

From Lofaro Lab Wiki
Jump to: navigation, search
(Obtaining the P3-DX model)
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
The following tutorial will help users drive the Pioneer 3-DX in Gazebo using ROS. Click [https://www.youtube.com/embed/2EzWewyqMfc here] to see a demo video showing the end result of this tutorial.
 +
 +
[[File:P3dxsmall.png]]
 +
 +
 +
 
== Prerequisites: Ubuntu, Gazebo, and ROS ==
 
== Prerequisites: Ubuntu, Gazebo, and ROS ==
 
Our tutorials were made using Ubuntu 12.04 LTS.
 
Our tutorials were made using Ubuntu 12.04 LTS.
Line 6: Line 12:
 
== Obtaining the P3-DX model ==
 
== Obtaining the P3-DX model ==
 
Git clone P3-DX model from https://github.com/SD-Robot-Vision/PioneerModel.git
 
Git clone P3-DX model from https://github.com/SD-Robot-Vision/PioneerModel.git
   <nowiki>git clone https://github.com/SD-Robot-Vision/PioneerModel.git</nowiki>
+
   <nowiki>$ git clone https://github.com/SD-Robot-Vision/PioneerModel.git</nowiki>
  
 
Install the P3-DX model in your catkin_ws by following the steps in the README of the git repository.
 
Install the P3-DX model in your catkin_ws by following the steps in the README of the git repository.
Line 12: Line 18:
 
== Get code for moving the P3-DX ==
 
== Get code for moving the P3-DX ==
  
'''Via publishing to Twist()'''
+
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.
TBC
+
 
 +
  <nowiki>$ git clone https://github.com/SD-Robot-Vision/p3dx_mover.git</nowiki>
 +
 
 +
Now use catkin_make after cd-ing into your catkin_ws.
 +
 
 +
  <nowiki>$ roscd</nowiki>
 +
  <nowiki>$ cd ..</nowiki>
 +
  <nowiki>$ catkin_make</nowiki>
 +
 
 +
== 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:
 +
 
 +
  <nowiki> $ roscore </nowiki>
 +
 
 +
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:
 +
 
 +
  <nowiki> $ roslaunch p3dx_gazebo/launch/gazebo.launch </nowiki>
 +
 
 +
Finally, to control the P3-DX, execute:
 +
 
 +
  <nowiki> $ rosrun p3dx_mover mover.py </nowiki>
 +
 
 +
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() '''
 +
 
 +
Here we will go over how to control the P3-DX using the popen() program. In order to control the P3-DX, first run roscore:
 +
 
 +
  <nowiki> $ roscore </nowiki>
 +
 
 +
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:
 +
 
 +
  <nowiki> $ roslaunch p3dx_gazebo/launch/gazebo.launch </nowiki>
 +
 
 +
Finally, to control the P3-DX, execute:
 +
 
 +
  <nowiki> $ rosrun p3dx_mover popenMover.py </nowiki>
 +
 
 +
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.
  
'''Via popen()'''
+
While the popen() program is capable of moving the P3-DX, you may notice that you cannot send one command after the other as quickly as you are able to with the preferred program that uses the rospy publisher. The popen() program works by utilizing the "rostopic pub" command. This is meant to be used on the command-line. You can learn more about it [http://wiki.ros.org/rostopic#rostopic_pub here].
TBC
+

Latest revision as of 19:56, 1 February 2015

The following tutorial will help users drive the Pioneer 3-DX in Gazebo using ROS. Click here to see a demo video showing the end result of this tutorial.

P3dxsmall.png


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:

   $ 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()

Here we will go over how to control the P3-DX using the popen() program. In order to control the P3-DX, first run roscore:

   $ 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 popenMover.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.

While the popen() program is capable of moving the P3-DX, you may notice that you cannot send one command after the other as quickly as you are able to with the preferred program that uses the rospy publisher. The popen() program works by utilizing the "rostopic pub" command. This is meant to be used on the command-line. You can learn more about it here.