From 345c31de4060a6c96ccac962d54505a1bfb767af Mon Sep 17 00:00:00 2001
From: CS <christoph.schroeter1@mailbox.tu-dresden.de>
Date: Sun, 15 Aug 2021 00:10:29 +0200
Subject: [PATCH]

---
 include/tron_adapter.h | 7 +++----
 src/tron_adapter.cpp   | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/include/tron_adapter.h b/include/tron_adapter.h
index b353d73..708f89f 100644
--- a/include/tron_adapter.h
+++ b/include/tron_adapter.h
@@ -104,7 +104,7 @@ struct Mapping {
     Channel channel = Channel("", 0, true); // TRON channel
     // Callback used if TRON sends some message
     // output callbacks must be specified when subscribing to topics
-    void(*input_callback)(Mapping& map, int32_t*) = nullptr;
+    boost::function<void(Mapping& map, int32_t*)> input_callback = 0;
 
     // note: since ROS messages can be complex, using byte positions might be cumbersome to use
     // it is easy to implement custom callbacks using ROS message types
@@ -258,7 +258,7 @@ struct TRON_Adapter {
                 pub.publish(ptr);
                 return;
             }
-        throw "did not find publisher for topic";
+        throw "did not find publisher";
     }
 
     /**
@@ -292,8 +292,7 @@ struct TRON_Adapter {
         }
         publish_to_topic<T>(map.topic, shared_ptr);
     }
-
-    
+ 
     /**
      * callback reports to TRON like defined in byte-mappings
      * note: this callback reports to all channels associated with calling topic
diff --git a/src/tron_adapter.cpp b/src/tron_adapter.cpp
index 995eac4..4e1b944 100644
--- a/src/tron_adapter.cpp
+++ b/src/tron_adapter.cpp
@@ -308,7 +308,7 @@ void TRON_Adapter::process_TRONs_msgs(){
 
         for (Mapping& map : mappings)
             if (map.channel.name == chan->name && map.channel.is_input) {
-                if (map.input_callback != nullptr)
+                if (!map.input_callback.empty())
                     map.input_callback(map, vals);  
                 else throw "no callback declared";
             }
-- 
GitLab