From 281f7c74988d3f2f2a96e23e093cb0e75c7459a8 Mon Sep 17 00:00:00 2001
From: Tommy Persson <tommy.persson@liu.se>
Date: Wed, 15 Jan 2020 23:45:44 +0100
Subject: [PATCH] Work on costs.

---
 src/delutil.cc | 17 +++++++++--------
 src/delutil.h  |  2 +-
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/delutil.cc b/src/delutil.cc
index 1995be8..66da16b 100644
--- a/src/delutil.cc
+++ b/src/delutil.cc
@@ -2,7 +2,7 @@
 
 #include "lrs_srvs_del/PrioritizeUnits.h"
 #include "lrs_srvs_del/PrioritizeUnitsResult.h"
-#include "lrs_srvs_del/GetBid.h"
+#include "lrs_msgs_common/GetBid.h"
 #include "lrs_srvs_del/FIPADelegate.h"
 #include "lrs_srvs_del/FIPACnpStatus.h"
 #include "lrs_srvs_del/FIPASetAcceptProposal.h"
@@ -56,21 +56,22 @@ bool unit_prioritize_result (int request_id, int & n_bids, std::vector<std::stri
 }
 
 
-int get_bid (std::string ns, std::string json) {
-  ROS_INFO ("get_bid: %s - %s", ns.c_str(), json.c_str());
+int get_bid (std::string ns, std::string unit, std::string json) {
+  ROS_INFO ("get_bid: %s - %s - %s", ns.c_str(), unit.c_str(), json.c_str());
 
   int res = -1;
 
   ros::NodeHandle n;
   ostringstream os;
-  os << ns << "/bidder/"  << "get_bid";
+  os << ns << "/"  << "get_bid";
 
-  ros::ServiceClient client = n.serviceClient<lrs_srvs_del::GetBid>(os.str());
+  ros::ServiceClient client = n.serviceClient<lrs_msgs_common::GetBid>(os.str());
 
-  lrs_srvs_del::GetBid srv;
-  srv.request.json = json;
+  lrs_msgs_common::GetBid srv;
+  srv.request.ns = unit;
+  srv.request.json_tst = json;
   if (client.call(srv)) {
-    res = srv.response.cost;
+    res = srv.response.bid;
   } else {
     ROS_ERROR("delutil.cc get_bid: Failed to call get_bid: %s", os.str().c_str());
     res = -1;
diff --git a/src/delutil.h b/src/delutil.h
index d4e930e..50dc37f 100644
--- a/src/delutil.h
+++ b/src/delutil.h
@@ -13,7 +13,7 @@ int unit_prioritize (std::vector<std::string> units, std::string ns, int id);
 
 bool unit_prioritize_result (int request_id, int & n_bids, std::vector<std::string> & units);
 
-int get_bid (std::string ns, std::string tstns, int id);
+int get_bid (std::string ns, std::string unit, std::string json);
 
 std::string delegate(std::string ns, std::string tstns, int tstid, lrs_msgs_del::DelArgs delargs);
 std::string delegate(std::string ns, std::string tstns, int tstid, lrs_msgs_del::DelArgs delargs,
-- 
GitLab