User Tools

Site Tools


getting_started:ros_example

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
getting_started:ros_example [2024/11/07 14:06] – [Working with ROS2] ursgrafgetting_started:ros_example [2024/12/10 08:17] (current) – [Working with ROS2] ursgraf
Line 4: Line 4:
  
 ===== Working with ROS1 ===== ===== Working with ROS1 =====
-The CMake file for the EEROS application using ROS1 has to be expanded as follows: 
-<code> 
-cmake_minimum_required(VERSION 3.10) 
-project(testProject) 
-  
-set(CMAKE_CXX_STANDARD 14) 
- 
-## ROS 
-message(STATUS "looking for package 'ROS'") 
-find_package( roslib REQUIRED ) 
-if (roslib_FOUND) 
-  message( STATUS "-> ROS found") 
-  add_definitions(-DROS_FOUND) 
-  include_directories( "${roslib_INCLUDE_DIRS}" ) 
-  message( STATUS "roslib_INCLUDE_DIRS: " ${roslib_INCLUDE_DIRS} ) 
-  list(APPEND ROS_LIBRARIES "${roslib_LIBRARIES}") 
-  find_package( rosconsole REQUIRED) 
-  list(APPEND ROS_LIBRARIES "${rosconsole_LIBRARIES}") 
-  find_package( roscpp REQUIRED ) 
-  list(APPEND ROS_LIBRARIES "${roscpp_LIBRARIES}") 
-  add_definitions(-DUSE_ROS) 
-else() 
-  message( STATUS "-> ROS NOT found") 
-endif() 
- 
-find_package(EEROS REQUIRED) 
-  
-add_executable(testProject main.cpp) 
-target_link_libraries(testProject PRIVATE EEROS::eeros ${ROS_LIBRARIES}) 
-</code> 
- 
 Your test program might look like Your test program might look like
 <code cpp> <code cpp>
Line 57: Line 26:
 Your test program might look like Your test program might look like
 <code cpp> <code cpp>
-#include <eeros/control/ros2/EerosRosTools.hpp> +#include <eeros/control/ros2/RosTools.hpp>
-#include <rclcpp/rclcpp.hpp>+
 #include <signal.h> #include <signal.h>
      
 int main(int argc, char **argv) { int main(int argc, char **argv) {
   ...   ...
-  auto node = eeros::control::rosTools::initNode("eerosNode"); // initialize the ROS node in your main function and give it a name.+  RosTools::initRos(argc, argv); 
 +  auto node = RosTools::initNode("eerosNode");
   if (node != nullptr) log.info() << "ROS node initialized: " << node->get_name();   if (node != nullptr) log.info() << "ROS node initialized: " << node->get_name();
-  signal(SIGINT, ...); 
   ...   ...
   ControlSystem cs(node, dt);   ControlSystem cs(node, dt);
getting_started/ros_example.1730984794.txt.gz · Last modified: 2024/11/07 14:06 by ursgraf