Posts

Showing posts with the label Programming hints

Mini Conda Setup

Miniconda is a free minimal installer for conda. It is a small bootstrap version of Anaconda that includes only conda, Python, the packages they both depend on, and a small number of other useful packages (like pip, zlib, and a few others).   Installation Following the installation tutorial in Quick Command Line Install : sudo mkdir -p /opt/miniconda3 sudo wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /opt /miniconda3/miniconda.sh sudo bash /opt /miniconda3/miniconda.sh -b -u -p /opt /miniconda3 sudo rm -rf /opt /miniconda3/miniconda.sh These previous 4 commands work even if you are installing miniconda3 inside a docker container (via distrobox), since it installs it in /opt directory.  Remember: distrobox has its own /opt directory, separated from /opt directory of the machine. Lastly: sudo /opt/miniconda3/bin/conda init bash and conda config --set auto_activate_base false  Command Lines  conda create --name {name_o...

Using ViSP in ROS environment - required packages

To use ViSP libraries in ROS noetic (Ubuntu 20.04.3 LTS), do the following: $ sudo apt-get install ros-noetic-visp ros-noetic-vision-visp $ cd ~/catkin_ws/src $ git clone https://github.com/lagadic/visp_ros.git     $ cd ~/catkin_ws $ catkin_make -DCMAKE_BUILD_TYPE=Release --pkg visp_ros     If you run into some issue, see this . The required packages (mentioned on the previous steps) are vision_visp , visp and visp_ros .

Including C++ headers in another package

 To import and include header files from a different package than the one where you're working on, it is just required to do these two things:  Open the CMakeLists.txt (of the working package (destination), not the one where the header is defined), and add, on the find_package command, the name of the package where the header is defined:   ... find_package ( catkin REQUIRED COMPONENTS roscpp my_roscpp_library ) ...    Open the package.xml (of the working package (destination), not the one where the header is defined) and add a new line with a <depend> tag:   < depend > my_roscpp_library </ depend >     After these two steps, you should be able to compile your project. If you're using a catkin workspace, just run the catkin_make command . For more information, read this .

Git push using GitHub token (cmd line)

Image
First, you need to create a GitHub token with the following scopes:     Copy and save the toke, cause you won't be able to see it again! Once you have the token, you can push your code, after the commit command, using the following: $ git push https://<GITHUB_ACCESS_TOKEN>@github.com/<GITHUB_USERNAME>/<REPOSITORY_NAME>.git Note that you can only use the PAT (personal access tokens) for HTTPS git operations. You can see if your repository is using HTTPS or SSH by running the command: $ git remote -v If you see something like this: > origin git@github.com: USERNAME/REPOSITORY .git (fetch) > origin git@github.com: USERNAME/REPOSITORY .git (push) It means that your git repo is using SSH, and you need to run $ git remote set-url origin https://github.com/ USERNAME / REPOSITORY .git To change the git repo to HTTPS: $ git remote -v # Verify new remote URL > origin https://github.com/ USERNAME/REPOSITORY .git (fetch) > origin https://github.com/ USER...

Compile, Build and Run C++

Image
You need to have a dir with your .cpp files and the CMakeLists.txt file . Here you can see an example of these types of directories: Then, in this same directory, you need to create a build folder, then compile (using the CMakeLists.txt file information), then building the executable file and then launch the (just created) executable file: $ mkdir -p build $ cd build $ cmake .. -DCMAKE_BUILD_TYPE=Release $ make name_of_file $ ./name_of_file You just need this to run the recently created file. Every time you change the .cpp original file, you should run the last 3 command lines in order to test that changes when running the program. The build folder should contain the following: