For MIT IAP class 2016-2017 (organized under SIPB IAP)
- open a terminal
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
sudo apt-get update
sudo apt-get install ros-jade-desktop-full
it takes around 4.4 minutessudo rosdep init
rosdep update
- [optional]
echo "source /opt/ros/jade/setup.bash" >> ~/.bashrc
- [if you've done 8.]
source ~/.bashrc
[if not]source /opt/ros/jade/setup.bash
sudo apt-get install python-rosinstall
- stay with the same terminal
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
- stay with the same terminal
cd ~/catkin_ws/
catkin_make
source devel/setup.bash
every time before you work under this workspace
- stay with the same terminal
rospack find [pkg]
e.g.rospack find roscpp
roscd [pkg/subdir]
e.g.roscd rospy
orroscd rospy/cmake
rosls [pkg/subdir]
e.g.rosls rospy
orrosls rospy/cmake
rosed [pkg] [filename]
editor by default is vim. switch to emacs, for example, withexport EDITOR='emacs -nw'
we'll talk about rosed later
- stay with the same terminal
cd ~/catkin_ws/src
catkin_create_pkg iap_tutorial std_msgs rospy
[command package-name dependency-1 dependency-2 ...]cd iap_tutorial
- modify package.xml information
- stay with the same terminal, cd
cd ~/catkin_ws/src/iap_tutorial
mkdir include
put includes heremkdir launch
put launch file heremkdir msg
put messages heremkdir src
put c++ source code heremkdir scripts
put python source code heremkdir srv
put services here- find a proper directory. e.g.
cd ~
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.- 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.
- start a terminal,
roscore
- start 2 terminals, do 2-5 for both of them
cd ~/catkin_ws
. devel/setup.bash
catkin_make
catkin_make install
- start server with
rosrun iap_tutorial add_two_ints_server.py
in one of the terminal - 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