User Tools

Site Tools


getting_started:tutorials:helloworld

This is an old revision of the document!


Getting started with the EEROS robotics framework

Preparation

  1. Setup an development environment as desribed here
  2. Start KDevelop
  3. Create a new C++ project:
    1. Project → New from Template…
    2. Choose Standard/Terminal as project type and type a project name (e.g. test-project).
    3. Create the project by clicking Finish
    4. Follow the instructions to create the build directory with the given default settings. Check that the build folder is within the project folder. Add the following extra arguments: -DADDITIONAL_INCLUDE_DIRS=/home/graf/projects/eeros-framework/includes -DADDITIONAL_LINK_DIRS=/home/graf/projects/eeros-framework/build/src
      Then click OK.
    5. Check the build sequence on the left bottom of Kdevelop. “eeros-framework” must be before the new project (in this example “test-project”).
    6. Build the project with the build button.

Say Hello World with EEROS

  1. Copy the following code into “main.cpp”
    #include <iostream>
    #include <eeros/logger/Logger.hpp>
    #include <eeros/logger/StreamLogWriter.hpp>
     
    int main() {
    	using namespace eeros::logger;
     
    	StreamLogWriter w(std::cout);
    	Logger<LogWriter>::setDefaultWriter(&w);
    	Logger<LogWriter> log;
     
    	log.info() << "Hello, EEROS";
     
    	return 0;
    }
  2. Open CMAkeLists.txt file, delete the text written on it and copy the following:
    cmake_minimum_required(VERSION 2.8)
     
    project(test-project)
     
    include_directories(${ADDITIONAL_INCLUDE_DIRS})
    link_directories(${ADDITIONAL_LINK_DIRS})
     
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
     
    add_executable(test-project main.cpp)
     
    target_link_libraries(test-project eeros)

    (Note 1: “test-project” is the name of the dummy-project created for the example. Put your project name where “test-project” is. Note 2: This file is in the project folder. e.g. /home/user/projects/test-project/)

  3. Build the project by clicking on the “Build” button up, on the left.

Run the Hello World Program

  1. Open a terminal
  2. Navigate to the build folder of your project (e.g. cd /projects/test-project/build/)
  3. Run the program with the command: ./testproject

getting_started/tutorials/helloworld.1443010081.txt.gz · Last modified: 2015/09/23 14:08 (external edit)