ROS Handbook and Notes for Ubuntu
Start ROS
Network Setup - Single Machine Configuration
If you just want to run tests on your local machine, set these environment variables:
$ export ROS_HOSTNAME=localhost
$ export ROS_MASTER_URI=http://localhost:11311
Another way to set ROS_HOSTNAME is to use .local domain
$ export ROS_HOSTNAME=ubuntu.local
$ export ROS_MASTER_URI=http://ubuntu.local:11311
Sometimes, system is unable to resolve to .local domain. When you encounter such issue, apart from following diagnostics mentioned above, check whether your avahi service is running.
$ systemctl is-active avahi-daemon.service
If required, you can restart avahi service as follows:
$ systemctl restart avahi-daemon.service
Basic Structure
Create and build a catkin workspace
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make
$ . ~/catkin_ws/devel/setup.bash
#To add the workspace to your ROS environment you need to source the generated setup file
Before continuing source new setup.*sh file:
$ source devel/setup.bash
#或者直接把它加入到环境变量里,这样每次开终端都会加载
$ echo "source devel/setup.bash " >> ~/.bashrc
To make sure your workspace is properly overlayed by the setup script, make sure ROS_PACKAGE_PATH environment variable includes the directory you’re in.
$ echo $ROS_PACKAGE_PATH /home/youruser/catkin_ws/src:/opt/ros/melodic/share
ROS Filesystem
$ rospack find [package_name]
# return the path to package
$ rospack list
# show all packages
$ rospack depends1 beginner_tutorials
# These first-order dependencies can now be reviewed with the rospack tool
$ rospack depends1 rospy
# show dependencyrospy's other dependencies
$ roscd [locationname[/subdir]]
# just llike 'cd' command
$ rosls [locationname[/subdir