diff --git a/etc/cmake/Findsick_scan_base.cmake b/etc/cmake/Findsick_scan_base.cmake index 8f4ebccdbc44634c9be63ee66179bc05b9a99fbd..a4723e39e1bf3497db55992d018863bd81801334 100644 --- a/etc/cmake/Findsick_scan_base.cmake +++ b/etc/cmake/Findsick_scan_base.cmake @@ -22,7 +22,9 @@ set(HEADER_SEARCH_PATHS /usr/include/ ) - #find_library(sick_scan_base_LIBRARY Names sick_scan_base2 PATHS /usr/lib PATH_SUFFIXES lib ) +find_library(sick_scan_base_LIBRARIES NAMES libsick_scan_generic.so PATHS ${sick_scan_base_DIR}/build NO_DEFAULT_PATH) +message(STATUS "sick_scan_base_LIBRARIES:${sick_scan_base_LIBRARIES}") + find_path(sick_scan_base_INCLUDE_DIR_0 NAMES sick_scan/sick_scan_common_tcp.h PATHS ${HEADER_SEARCH_PATHS} NO_DEFAULT_PATH) find_path(sick_scan_base_INCLUDE_DIR_1 NAMES sick_generic_laser.h PATHS ${HEADER_SEARCH_PATHS} NO_DEFAULT_PATH) find_path(sick_scan_base_INCLUDE_DIR_2 NAMES tinystr.h PATHS ${HEADER_SEARCH_PATHS} NO_DEFAULT_PATH) @@ -35,12 +37,9 @@ if(sick_scan_base_INCLUDE_DIR_0 AND sick_scan_base_INCLUDE_DIR_1 AND sick_scan_b endif() message(STATUS "sick_scan_base_INCLUDE_DIRS:${sick_scan_base_INCLUDE_DIRS}") -find_library(sick_scan_base_LIBRARIES NAMES libsick_scan_generic.so PATHS ${sick_scan_base_DIR}/build NO_DEFAULT_PATH) -message(STATUS "sick_scan_base_LIBRARIES:${sick_scan_base_LIBRARIES}") - -find_package_handle_standard_args(sick_scan_base DEFAULT_MSG sick_scan_base_INCLUDE_DIRS) +find_package_handle_standard_args(sick_scan_base DEFAULT_MSG sick_scan_base_INCLUDE_DIRS sick_scan_base_LIBRARIES) -mark_as_advanced(sick_scan_base_INCLUDE_DIRS) +mark_as_advanced(sick_scan_base_INCLUDE_DIRS sick_scan_base_LIBRARIES) diff --git a/scenarios/SickLaserUnit/SickLaserUnit.scx b/scenarios/SickLaserUnit/SickLaserUnit.scx new file mode 100644 index 0000000000000000000000000000000000000000..398cd914600aeaf8faf8147dc2feb83b989d70e0 --- /dev/null +++ b/scenarios/SickLaserUnit/SickLaserUnit.scx @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<scenario name="SickLaserUnit" creation="2021-06-25.04:20:13 PM" globalConfigName="./config/global.cfg" package="RobotAPI" deploymentType="local" nodeName="NodeMain"> + <application name="SickLaserUnit" instance="" package="RobotAPI" nodeName="" enabled="true" iceAutoRestart="false"/> +</scenario> + diff --git a/scenarios/SickLaserUnit/config/SickLaserUnit.cfg b/scenarios/SickLaserUnit/config/SickLaserUnit.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1a54fe66a787a3e000d81f934a6ec0b011e1e0f5 --- /dev/null +++ b/scenarios/SickLaserUnit/config/SickLaserUnit.cfg @@ -0,0 +1,293 @@ +# ================================================================== +# SickLaserUnit properties +# ================================================================== + +# ArmarX.AdditionalPackages: List of additional ArmarX packages which should be in the list of default packages. If you have custom packages, which should be found by the gui or other apps, specify them here. Comma separated List. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.AdditionalPackages = Default value not mapped. + + +# ArmarX.ApplicationName: Application name +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ApplicationName = "" + + +# ArmarX.CachePath: Path for cache files. If relative path AND env. variable ARMARX_USER_CONFIG_DIR is set, the cache path will be made relative to ARMARX_USER_CONFIG_DIR. Otherwise if relative it will be relative to the default ArmarX config dir (${HOME}/.armarx) +# Attributes: +# - Default: mongo/.cache +# - Case sensitivity: yes +# - Required: no +# ArmarX.CachePath = mongo/.cache + + +# ArmarX.Config: Comma-separated list of configuration files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.Config = "" + + +# ArmarX.DataPath: Semicolon-separated search list for data files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.DataPath = "" + + +# ArmarX.DefaultPackages: List of ArmarX packages which are accessible by default. Comma separated List. If you want to add your own packages and use all default ArmarX packages, use the property 'AdditionalPackages'. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.DefaultPackages = Default value not mapped. + + +# ArmarX.DependenciesConfig: Path to the (usually generated) config file containing all data paths of all dependent projects. This property usually does not need to be edited. +# Attributes: +# - Default: ./config/dependencies.cfg +# - Case sensitivity: yes +# - Required: no +# ArmarX.DependenciesConfig = ./config/dependencies.cfg + + +# ArmarX.DisableLogging: Turn logging off in whole application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.DisableLogging = false + + +# ArmarX.EnableProfiling: Enable profiling of CPU load produced by this application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.EnableProfiling = false + + +# ArmarX.LoadLibraries: Libraries to load at start up of the application. Must be enabled by the Application with enableLibLoading(). Format: PackageName:LibraryName;... or /absolute/path/to/library;... +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoadLibraries = "" + + +# ArmarX.LoggingGroup: The logging group is transmitted with every ArmarX log message over Ice in order to group the message in the GUI. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoggingGroup = "" + + +# ArmarX.RedirectStdout: Redirect std::cout and std::cerr to ArmarXLog +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RedirectStdout = true + + +# ArmarX.RemoteHandlesDeletionTimeout: The timeout (in ms) before a remote handle deletes the managed object after the use count reached 0. This time can be used by a client to increment the count again (may be required when transmitting remote handles) +# Attributes: +# - Default: 3000 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RemoteHandlesDeletionTimeout = 3000 + + +# ArmarX.SecondsStartupDelay: The startup will be delayed by this number of seconds (useful for debugging) +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.SecondsStartupDelay = 0 + + +# ArmarX.SickLaserUnit.EnableProfiling: enable profiler which is used for logging performance events +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.SickLaserUnit.EnableProfiling = false + + +# ArmarX.SickLaserUnit.MinimumLoggingLevel: Local logging level only for this component +# Attributes: +# - Default: Undefined +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.SickLaserUnit.MinimumLoggingLevel = Undefined + + +# ArmarX.SickLaserUnit.ObjectName: Name of IceGrid well-known object +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.SickLaserUnit.ObjectName = "" + + +# ArmarX.SickLaserUnit.deviceNumber: number of the LaserScanner Device +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.SickLaserUnit.deviceNumber = 0 + + +# ArmarX.SickLaserUnit.emulateSensor: overwrite the default Settings and don't connect to Scanner +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.SickLaserUnit.emulateSensor = false + + +# ArmarX.SickLaserUnit.hostname: Hostname of the LaserScanner +# Attributes: +# - Default: 192.168.8.133 +# - Case sensitivity: yes +# - Required: no +ArmarX.SickLaserUnit.hostname = 192.168.8.133 + + +# ArmarX.SickLaserUnit.newIpAddress: New IP address for the LaserScanner +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.SickLaserUnit.newIpAddress = "" + + +# ArmarX.SickLaserUnit.port: port to use on the LaserScanner +# Attributes: +# - Default: 2112 +# - Case sensitivity: yes +# - Required: no +ArmarX.SickLaserUnit.port = 2112 + + +# ArmarX.SickLaserUnit.protocol: Either use ASCII or Binary protocol +# Attributes: +# - Default: Binary +# - Case sensitivity: yes +# - Required: no +# - Possible values: {ASCII, Binary} +ArmarX.SickLaserUnit.protocol = ASCII + + +# ArmarX.SickLaserUnit.rangeMax: maximum Range of the Scanner +# Attributes: +# - Case sensitivity: yes +# - Required: yes +ArmarX.SickLaserUnit.rangeMax = 1.00 + + +# ArmarX.SickLaserUnit.rangeMin: minimum Range of the Scanner +# Attributes: +# - Case sensitivity: yes +# - Required: yes +ArmarX.SickLaserUnit.rangeMin = 0.01 + + +# ArmarX.SickLaserUnit.scannerType: Name of the LaserScanner +# Attributes: +# - Case sensitivity: yes +# - Required: yes +ArmarX.SickLaserUnit.scannerType = sick_tim_5xx + + +# ArmarX.SickLaserUnit.sopasProtocolType: Automatically set to true if the Scanner does not support ASCII communication +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.SickLaserUnit.sopasProtocolType = false + + +# ArmarX.SickLaserUnit.subscribeDatagram: subscribe to Datagram in communication or not +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.SickLaserUnit.subscribeDatagram = false + + +# ArmarX.SickLaserUnit.timeIncrement: timeIncrement?? +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.SickLaserUnit.timeIncrement = 0 + + +# ArmarX.SickLaserUnit.timelimit: timelimit for communication +# Attributes: +# - Default: 5 +# - Case sensitivity: yes +# - Required: no +ArmarX.SickLaserUnit.timelimit = 5 + + +# ArmarX.StartDebuggerOnCrash: If this application crashes (segmentation fault) qtcreator will attach to this process and start the debugger. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.StartDebuggerOnCrash = false + + +# ArmarX.ThreadPoolSize: Size of the ArmarX ThreadPool that is always running. +# Attributes: +# - Default: 1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ThreadPoolSize = 1 + + +# ArmarX.TopicSuffix: Suffix appended to all topic names for outgoing topics. This is mainly used to direct all topics to another name for TopicReplaying purposes. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.TopicSuffix = "" + + +# ArmarX.UseTimeServer: Enable using a global Timeserver (e.g. from ArmarXSimulator) +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.UseTimeServer = false + + +# ArmarX.Verbosity: Global logging level for whole application +# Attributes: +# - Default: Info +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.Verbosity = Info + + diff --git a/scenarios/SickLaserUnit/config/global.cfg b/scenarios/SickLaserUnit/config/global.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ede51536f872c9c144104e26b4754f6a0ca7b076 --- /dev/null +++ b/scenarios/SickLaserUnit/config/global.cfg @@ -0,0 +1,4 @@ +# ================================================================== +# Global Config from Scenario SickLaserUnit +# ================================================================== + diff --git a/source/RobotAPI/drivers/SickLaserUnit/CMakeLists.txt b/source/RobotAPI/drivers/SickLaserUnit/CMakeLists.txt index 92c9e15b479e5e89513c045b2d250c0611342eda..d123908c6c5ec12fcf54b5e18e5d09a7829a9aad 100644 --- a/source/RobotAPI/drivers/SickLaserUnit/CMakeLists.txt +++ b/source/RobotAPI/drivers/SickLaserUnit/CMakeLists.txt @@ -1,3 +1,5 @@ +cmake_minimum_required(VERSION 3.10) + set(LIB_NAME SickLaserUnit) armarx_component_set_name("${LIB_NAME}") @@ -13,6 +15,10 @@ armarx_set_target("Library: ${LIB_NAME}") #) +find_package(sick_scan_base) +armarx_build_if(sick_scan_base_FOUND "sick_scan_base not available") + + # Add the component armarx_add_component( COMPONENT_LIBS @@ -31,6 +37,8 @@ armarx_add_component( # This component ## SickLaserUnitInterfaces # If you defined a component ice interface above. + ${sick_scan_base_LIBRARIES} + SOURCES SickLaserUnit.cpp @@ -40,8 +48,10 @@ armarx_add_component( # Add dependencies -#find_package(MyLib QUIET) -#armarx_build_if(MyLib_FOUND "MyLib not available") +if(sick_scan_base_FOUND) + target_include_directories(${LIB_NAME} SYSTEM PUBLIC ${sick_scan_base_INCLUDE_DIRS}) + target_compile_definitions(${LIB_NAME} PUBLIC "-Dlinux") +endif() # All target_include_directories must be guarded by if(Xyz_FOUND) # For multiple libraries write: if(X_FOUND AND Y_FOUND) ... @@ -61,7 +71,7 @@ armarx_add_component( # Add unit tests add_subdirectory(test) -add_subdirectory(include/sick_scan_base) +#add_subdirectory(thirdparty/sick_scan_base) # Generate the application armarx_generate_and_add_component_executable( diff --git a/source/RobotAPI/drivers/SickLaserUnit/SickLaserUnit.cpp b/source/RobotAPI/drivers/SickLaserUnit/SickLaserUnit.cpp index 184e7f23d8be76f9b86800bbca3ad13cb1938e64..248e57adb471c97d028eec2b9872384753ac5331 100644 --- a/source/RobotAPI/drivers/SickLaserUnit/SickLaserUnit.cpp +++ b/source/RobotAPI/drivers/SickLaserUnit/SickLaserUnit.cpp @@ -21,6 +21,7 @@ */ #include "SickLaserUnit.h" +#include <exception> // Include headers you only need in function definitions in the .cpp. @@ -59,6 +60,7 @@ namespace armarx case RunState::scannerRun: if (result == sick_scan::ExitSuccess) // OK -> loop again { + ARMARX_INFO_S << "looping"; result = scanner->loopOnce(); } else @@ -144,6 +146,7 @@ namespace armarx //Scanner parameters def->required(properties.scannerType, "scannerType", "Name of the LaserScanner"); def->optional(properties.deviceNumber, "deviceNumber", "number of the LaserScanner Device"); + def->optional(properties.angleOffset, "angelOffset", "offset to the scanning angle"); def->required(properties.rangeMin, "rangeMin", "minimum Range of the Scanner"); def->required(properties.rangeMax, "rangeMax", "maximum Range of the Scanner"); def->optional(properties.timeIncrement, "timeIncrement", "timeIncrement??"); @@ -169,18 +172,33 @@ namespace armarx scanDevice.useTcp = true; scanDevice.ip = properties.hostname; } + scanDevice.port = properties.port; + scanDevice.angleOffset = properties.angleOffset; + scanDevice.timelimit = properties.timelimit; + scanDevice.subscribeDatagram = properties.subscribeDatagram; if (properties.newIpAddress != "") { scanDevice.changeIP = true; scanDevice.newIpAddress = properties.newIpAddress; } scanDevice.scannerType = properties.scannerType; + scanDevice.deviceNumber = properties.deviceNumber; + scanDevice.rangeMin = properties.rangeMin; + scanDevice.rangeMax = properties.rangeMax; + scanDevice.timeIncrement = properties.timeIncrement; //scanner Parameters - scanDevice.parser = new sick_scan::SickGenericParser(scanDevice.scannerType); - scanDevice.parser->set_range_min(properties.rangeMin); - scanDevice.parser->set_range_max(properties.rangeMax); - scanDevice.parser->set_time_increment(properties.timeIncrement); - + try + { + scanDevice.parser = new sick_scan::SickGenericParser(scanDevice.scannerType); + scanDevice.parser->set_range_min(properties.rangeMin); + scanDevice.parser->set_range_max(properties.rangeMax); + scanDevice.parser->set_time_increment(properties.timeIncrement); + } + catch (std::exception const& e) + { + ARMARX_ERROR_S << "Could not create parser. Wrong Scanner name."; + return; + } if (properties.emulSensor) { ARMARX_INFO_S << "Found paraemter emulSensor overwriting default settings. Emulation: True"; @@ -211,6 +229,7 @@ namespace armarx ARMARX_WARNING_S << "Unknown protocol type. Defaulting to Binary protocol."; scanDevice.protocol = ScanProtocol::Binary; } + if (scanDevice.protocol == ScanProtocol::ASCII) { scanDevice.parser->getCurrentParamPtr()->setUseBinaryProtocol(false); @@ -221,6 +240,7 @@ namespace armarx scanDevice.parser->getCurrentParamPtr()->setUseBinaryProtocol(true); scanDevice.colaDialectId = 'B'; } + ARMARX_INFO_S << "SickLaserUnit fertig initialisiert."; } void SickLaserUnit::onConnectComponent() diff --git a/source/RobotAPI/drivers/SickLaserUnit/SickLaserUnit.h b/source/RobotAPI/drivers/SickLaserUnit/SickLaserUnit.h index 4c447b11ec04a2be4db9d1d142264aff30c9d9c2..b701853211edae147443a2f52af870454e66a47f 100644 --- a/source/RobotAPI/drivers/SickLaserUnit/SickLaserUnit.h +++ b/source/RobotAPI/drivers/SickLaserUnit/SickLaserUnit.h @@ -61,7 +61,7 @@ namespace armarx struct SickLaserScanDevice { //scanner parameters - std::string scannerType; + std::string scannerType = "sick_tim_5xx"; int deviceNumber = 0; double rangeMin; double rangeMax; @@ -70,7 +70,7 @@ namespace armarx std::string ip; std::string newIpAddress = ""; std::string port; - float angleOffset = 0.0f; + double angleOffset = 0.0; int timelimit = 5; bool subscribeDatagram = false; ScanProtocol protocol = ScanProtocol::ASCII; @@ -157,16 +157,17 @@ namespace armarx struct Properties { //communication parameters - std::string hostname = "192.168.8.129"; + std::string hostname = "192.168.8.133"; std::string newIpAddress = ""; std::string port = "2112"; int timelimit = 5; bool subscribeDatagram = false; - ScanProtocol protocol = ScanProtocol::Binary; + ScanProtocol protocol = ScanProtocol::ASCII; bool sopasProtocolType = false; //scanner parameters - std::string scannerType; + std::string scannerType = "sick_tim_5xx"; int deviceNumber = 0; + double angleOffset = 0.0; double rangeMin; double rangeMax; double timeIncrement;