/ros-introduction-iap

For MIT IAP class 2016-2017 (organized under SIPB IAP)

Primary LanguagePython

ros-introduction-iap

For MIT IAP class 2016-2017 (organized under SIPB IAP)

Baiscs

install ROS

  1. open a terminal
  2. sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
  3. sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
  4. sudo apt-get update
  5. sudo apt-get install ros-jade-desktop-full it takes around 4.4 minutes
  6. sudo rosdep init
  7. rosdep update
  8. [optional] echo "source /opt/ros/jade/setup.bash" >> ~/.bashrc
  9. [if you've done 8.] source ~/.bashrc [if not] source /opt/ros/jade/setup.bash
  10. sudo apt-get install python-rosinstall

build your workspace

  1. stay with the same terminal
  2. mkdir -p ~/catkin_ws/src
  3. cd ~/catkin_ws/src

compile your workspace (though it is empty by now)

  1. stay with the same terminal
  2. cd ~/catkin_ws/
  3. catkin_make
  4. source devel/setup.bash every time before you work under this workspace

basic commands

  1. stay with the same terminal
  2. rospack find [pkg] e.g. rospack find roscpp
  3. roscd [pkg/subdir] e.g. roscd rospy or roscd rospy/cmake
  4. rosls [pkg/subdir] e.g. rosls rospy or rosls rospy/cmake
  5. rosed [pkg] [filename] editor by default is vim. switch to emacs, for example, with export EDITOR='emacs -nw'
    we'll talk about rosed later

create your package

  1. stay with the same terminal
  2. cd ~/catkin_ws/src
  3. catkin_create_pkg iap_tutorial std_msgs rospy [command package-name dependency-1 dependency-2 ...]
  4. cd iap_tutorial
  5. modify package.xml information

Coding the package

  1. stay with the same terminal, cd cd ~/catkin_ws/src/iap_tutorial
  2. mkdir include put includes here
  3. mkdir launch put launch file here
  4. mkdir msg put messages here
  5. mkdir src put c++ source code here
  6. mkdir scripts put python source code here
  7. mkdir srv put services here
  8. find a proper directory. e.g. cd ~
  9. git clone https://github.com/anchen1011/ros-introduction-iap.git clone this tutorial package. You will see 2 folders inside: sample and exercise. The package inside sample is the complete package for reference, the exercise package is the one we're going to make use to finish this project.
  10. There are 6 files in exercise folder. Then I'm going to introduce how each of them works, and how to further code the package.

Run

  1. start a terminal, roscore
  2. start 2 terminals, do 2-5 for both of them
  3. cd ~/catkin_ws
  4. . devel/setup.bash
  5. catkin_make
  6. catkin_make install
  7. start server with rosrun iap_tutorial add_two_ints_server.py in one of the terminal
  8. call client in the other terminal rosrun iap_tutorial add_two_ints_client.py [x] [y]
    e.g. rosrun iap_tutorial add_two_ints_client.py 4 5