0
$\begingroup$

I am new to ros2 and have very little experience with it. Looking in to the documentation I have seen how to create a workspace in ros by cloning a github repository of your respective distro from their branch. Is there any other way to create a ros2 workspace with a single line terminal command similar to the one we use for creating a package in ros2. According to my knowledge I hope creating a workspace is necessary in order to create a package and run it. Thank you!

$\endgroup$
5
  • $\begingroup$ Did you already read this tutorial? $\endgroup$
    – Wilhelm
    Commented Dec 27, 2022 at 11:46
  • $\begingroup$ Yes, @Dave I have gone through the ROS humble documentation already. I couldn't find any other possible way other than this to create a ROS workspace. Actually the tutorial suggest cloning a GitHub repository's particular distro's branch. I would like to know if there is a command line one liner code for creating a workspace in ROS? $\endgroup$
    – Jishnu
    Commented Dec 27, 2022 at 17:49
  • 1
    $\begingroup$ Basically a workspace in ROS is just a folder, which can be identified by ROS when sourcing theinstall/setup.bash file. So.. you do not need to download a pkg for creating a workspace, but just create a normal folder as you normally would do and most important create a subdirectory src in it, where you store your packages. Clear? Inside the 'src' folder you can then create package with `ros2 pkg create --build-type ament_cmake <package_name> Is it now clear? $\endgroup$
    – Wilhelm
    Commented Dec 28, 2022 at 10:05
  • $\begingroup$ Yeah, Thank you now it's clear. Actually my thought was that the concept of workspace had to do much more with a ros project rather that being just a folder. That's why I was confused when every time I wanted to create a ros workspace then I have to clone this official repo for ros with any of it's branch. But, now its clear. Thank you! $\endgroup$
    – Jishnu
    Commented Dec 28, 2022 at 10:39
  • $\begingroup$ Then I move my answer above to an official answer. Please accept it, so your question does not appear under unanswered questions, ok? $\endgroup$
    – Wilhelm
    Commented Dec 29, 2022 at 18:12

1 Answer 1

1
$\begingroup$

Basically a workspace in ROS is just a folder, which can be identified by ROS when sourcing the

install/setup.bash

file. So.. you do not need to download a pkg for creating a workspace, but just create a normal folder as you normally would do and most important create a subdirectory src in it, where you store your packages. Clear? Inside the src folder you can then create package with ros2 pkg create --build-type ament_cmake <package_name>

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.