Vs code plugin on linux to compile to core2

Hi @all,

I’m struggeling since hours to compile my files using the husarion vs code plugin.

I’ve created a new project using Ctrl+Shift+P and enter Create husarion project.

After that I’ve added these lines to my own CMakeLists.txt which I added to the folder after generating:
include(${HFRAMEWORK_PATH}/hFramework.cmake)
enable_module(hCloudClient)
enable_module(hSensors)
enable_module(hModules)
enable_module(hROS)

If I’m running the ninja command: I’m getting right at this include the error that: include could not find load file: /hFramework.cmake

How am I able to adjust the ninja config to fit to my own project folder structure? Basically I would like to access the rosbot motors inside my own cpp file. How can I achieve this?

Thanks a lot for your help

Hello sobieski,

You need to set path to hFramework.cmake file.
When configuring ninja, add parameter:

-DHFRAMEWORK_PATH=/home/USERNAME/.vscode/extensions/husarion.husarion-1.5.14/sdk

The hFramework need also parameters for selected board:

-DPORT=stm32 -DBOARD_VERSION=1.0.0 -DBOARD_TYPE=core2

Regards,
Łukasz

In which file do I need to add these parameters? rules.ninja?

Thanks in advance

File rules.ninja is generated by cmake automatically when you create project.
Pressing Ctrl + Shift + P and “Create Husarion project” is equivalent to executing:

cmake . -GNinja -DCMAKE_MAKE_PROGRAM=ninja -DPORT=stm32 -DBOARD_VERSION=1.0.0 -DBOARD_TYPE=core2 -DHFRAMEWORK_PATH=/home/USERNAME/.vscode/extensions/husarion.husarion-1.5.14/sdk

You will need to adjust above command to your project or post here more details regarding your project.

Regards,
Łukasz

What else information do you need? If I’m running the above command in the empty folder, I’m ending up without any ninja files in this folder.

I assumed that you will run it in directory containing your CMakeLists.txt and .cpp files, then you should get rules.ninja.

Could you share your CMakeLists.txt and .cpp that you are trying to build?

Regards,
Łukasz

I won’t be able to share this. As soon as I’m running: cmake . -GNinja -DCMAKE_MAKE_PROGRAM=ninja -DPORT=stm32 -DBOARD_VERSION=1.0.0 -DBOARD_TYPE=core2 -DHFRAMEWORK_PATH=/home/USERNAME/.vscode/extensions/husarion.husarion-1.5.14/sdk
I’m getting following error. Any clues how to solve this one?

u    sername@username-ThinkPad-T530:~/catkin_ws/src/project$ cmake . -GNinja -DCMAKE_MAKE_PROGRAM=ninja -DPORT=stm32 -DBOARD_VERSION=1.0.0 -DBOARD_TYPE=core2 -DHFRAMEWORK_PATH=/home/username/.vscode/extensions/husarion.husarion-1.5.14/sdk
    -- The C compiler identification is GNU 5.4.0
    -- The CXX compiler identification is GNU 5.4.0
    -- Check for working C compiler using: Ninja
    -- Check for working C compiler using: Ninja -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler using: Ninja
    -- Check for working CXX compiler using: Ninja -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- building project
    -- project dir=project-specific/husarion
    -- Using CATKIN_DEVEL_PREFIX: /home/username/catkin_ws/src/project/devel
    -- Using CMAKE_PREFIX_PATH: /opt/ros/kinetic
    -- This workspace overlays: /opt/ros/kinetic
    -- Found PythonInterp: /usr/bin/python (found version "2.7.12")
    -- Using PYTHON_EXECUTABLE: /usr/bin/python
    -- Using Debian Python package layout
    -- Using empy: /usr/bin/empy
    -- Using CATKIN_ENABLE_TESTING: ON
    -- Call enable_testing()
    -- Using CATKIN_TEST_RESULTS_DIR: /home/username/catkin_ws/src/project/test_results
    -- Found gtest: gtests will be built
    -- Using Python nosetests: /usr/bin/nosetests-2.7
    -- catkin 0.7.14
    -- build husarion
    -- The ASM compiler identification is GNU
    -- Found assembler: /usr/bin/arm-none-eabi-gcc
    CMake Error at /home/username/.vscode/extensions/husarion.husarion-1.5.14/sdk/hFrameworkPort.cmake:35 (enable_language):
      The CMAKE_C_COMPILER:

        arm-none-eabi-gcc

      is not a full path and was not found in the PATH.

      Tell CMake where to find the compiler by setting either the environment
      variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
      the compiler, or to the compiler name if it is in the PATH.
    Call Stack (most recent call first):
      /home/username/.vscode/extensions/husarion.husarion-1.5.14/sdk/ports/stm32/options.cmake:10 (disable_compiler_detection)
      /home/username/.vscode/extensions/husarion.husarion-1.5.14/sdk/hFrameworkPort.cmake:115 (include)
      /home/username/.vscode/extensions/husarion.husarion-1.5.14/sdk/hFramework.cmake:12 (include)
      project-specific/husarion/CMakeLists.txt:21 (include)


    CMake Error at /home/username/.vscode/extensions/husarion.husarion-1.5.14/sdk/hFrameworkPort.cmake:35 (enable_language):
      The CMAKE_CXX_COMPILER:

        arm-none-eabi-g++

      is not a full path and was not found in the PATH.

      Tell CMake where to find the compiler by setting either the environment
      variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
      to the compiler, or to the compiler name if it is in the PATH.
    Call Stack (most recent call first):
      /home/username/.vscode/extensions/husarion.husarion-1.5.14/sdk/ports/stm32/options.cmake:10 (disable_compiler_detection)
      /home/username/.vscode/extensions/husarion.husarion-1.5.14/sdk/hFrameworkPort.cmake:115 (include)
      /home/username/.vscode/extensions/husarion.husarion-1.5.14/sdk/hFramework.cmake:12 (include)
      project-specific/husarion/CMakeLists.txt:21 (include)


    -- Configuring incomplete, errors occurred!
    See also "/home/username/catkin_ws/src/project/CMakeFiles/CMakeOutput.log".
    See also "/home/username/catkin_ws/src/project/CMakeFiles/CMakeError.log".
    You have changed variables that require your cache to be deleted.
    Configure will be re-run and you may have to reset some variables.
    The following variables have changed:
    CMAKE_C_COMPILER= /usr/bin/cc
    CMAKE_CXX_COMPILER= /usr/bin/c++

    -- Generating done
    -- Build files have been written to: /home/username/catkin_ws/src/project

Of course I changed my name to username. So don’t worry. The tutorial (https://husarion.com/tutorials/other-tutorials/offline-development-tools/#offline-development-tools-current-functionality) I’ve already done and installed everything successfully.

What happens when you execute arm-none-eabi-gcc? You should get output like this:

$ arm-none-eabi-gcc
gcc: fatal error: no input files
compilation terminated.

Well. I’m getting the same output. Any other clue?

You are trying to build a hFramework project inside a ROS workspace.

The hFramework is for STM32 microcontrollers and require it’s own toolchain. Packages using it cannot be build alongside ROS packages.

Move your project to separate directory (not in the catkin_ws) and build it again.

Also please note that you can not use:

find_package(catkin REQUIRED COMPONENTS
   roscpp
)

or:

catkin_package(
)

inside projects based on hFramework.

Regards,
Łukasz