# wstool

## wstool: ROS Workspace Tool&#x20;

```bash
# install wstool
sudo apt-get install python-wstool

# create a workspace
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin init
#catkin config --merge-devel
#echo 'source ~/catkin_ws/devel/setup.bash' >> ~/.bashrc

# approach one: in src level
cd ~/catkin_ws/src
git clone <ros_package>.git
wstool init
#wstool init . <ros_package>/ssh.rosinstall
wstool merge <ros_package>/ssh.rosinstall
wstool update

# approach two: in workspace level
cd ~/catkin_ws
wstool init src   # will create an empty .rosinstall file 
#wstool init src PATH_TO_ROSINSTALL_FILE.rosinstall  # initialize with a .rosinstall file
wstool merge -t src PATH_TO_ROSINSTALL_FILE.rosinstall
wstool update -t src   # -t specify targer folder

# example: use rosinstall_generator
cd ~/catkin_ws
wstool init src
rosinstall_generator --rosdistro kinetic mavlink | tee /tmp/mavros.rosinstall
rosinstall_generator --upstream mavros | tee -a /tmp/mavros.rosinstall # -a: append
wstool merge -t src /tmp/mavros.rosinstall
wstool update -t src -j4
rosdep install --from-paths src --ignore-src -y

# compile code and refresh workspace
catkin build
source ~/catkin_ws/devel/setup.bash
```

#### references

* [wstool ROS Wiki](http://wiki.ros.org/wstool)
* [rosinstall\_generator ROS Wiki](http://wiki.ros.org/rosinstall_generator)
* [mavros source installation](https://github.com/mavlink/mavros/tree/master/mavros#source-installation)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.hanzheteng.com/development/ros/wstool.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
