From efa4e56800c2d444b02f2e7a8078d81949d59eee Mon Sep 17 00:00:00 2001 From: Kevin Dang Date: Sat, 1 Feb 2020 15:30:13 +0100 Subject: [PATCH 01/21] moved laptop battery manager to hero_bringup and adjust files --- CMakeLists.txt | 18 ++++++++- package.xml | 4 ++ src/battery_manager_laptop.cpp | 69 ++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 src/battery_manager_laptop.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d77907a5..4db0b4c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,24 @@ cmake_minimum_required(VERSION 3.0.2) project(hero_bringup) -find_package(catkin REQUIRED) +find_package(catkin REQUIRED COMPONENTS + sensor_msgs +) catkin_add_env_hooks(99.hero_functions SHELLS bash DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/env-hooks) catkin_python_setup() -catkin_package() +catkin_package( + CATKIN_DEPENDS sensor_msgs +) + +########### +## Build ## +########### + +add_executable(battery_manager_laptop src/battery_manager_laptop.cpp) +add_dependencies(battery_manager_laptop ${catkin_EXPORTED_TARGETS}) +target_link_libraries(battery_manager_laptop + ${catkin_LIBRARIES} +) diff --git a/package.xml b/package.xml index 5de6bce5..07599ab0 100644 --- a/package.xml +++ b/package.xml @@ -14,6 +14,10 @@ catkin + sensor_msgs/ + + sensor_msgs + gazebo_msgs geometry_msgs hero_bridge diff --git a/src/battery_manager_laptop.cpp b/src/battery_manager_laptop.cpp new file mode 100644 index 00000000..6c3a0fb5 --- /dev/null +++ b/src/battery_manager_laptop.cpp @@ -0,0 +1,69 @@ +#include +#include +#include + + +ros::Publisher speech_pub; +ros::Subscriber percentage_sub; + +double capacity; +double charge; +uint8 percentage; + + +void batteryCallback(const sensor_msgs::BatteryState::ConstPtr& msg) +{ + if (msg.location == "hero2") + { + capacity = msg.capacity; + charge = msg.charge; + percentage = (charge/capacity)*100; + } +} + + +int main(int argc, char **argv) +{ + ros::init(arc, argv, "Battery_manager_laptop"); + ros::NodeHandle gn; + + uint8 middle = 50; + uint8 low = 20; + uint8 empty = 10; + std::string message = ""; + + battery_sub = gn.subscribe("battery", 1, batteryCallback); + speech_pub = gn.advertise("text_to_speech/input", 10); + + ros::Rate loop_rate(1.0) + + while(gn.ok()) + { + // check battery status + if (percentage < empty) + { + message = "The laptop battery is empty, I need power now!"; + } + else if (percentage < low) + { + message = "The laptop battery is almost empty, give me power."; + } + else if (percentage < middle) + { + message = "The laptop battery is halfway empty, charge me if possible."; + } + + // publish voice message + if (old_message != message && message != "") + { + std_msgs::String speech_msg; + speech_msg.data = message; + speech_pub.publish(speech_msg); + old_message = message; + } + + loop_rate.sleep(); + } + return 0; +} + From 607435af8acfe1cd35d1d4ae609a58138329e3a8 Mon Sep 17 00:00:00 2001 From: Kevin Dang Date: Tue, 4 Feb 2020 21:53:32 +0100 Subject: [PATCH 02/21] fixed CMakeslist and package --- CMakeLists.txt | 6 +++--- package.xml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4db0b4c9..7eb7267d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,13 +5,13 @@ find_package(catkin REQUIRED COMPONENTS sensor_msgs ) +include_directories(${catkin_INCLUDE_DIRS}) + catkin_add_env_hooks(99.hero_functions SHELLS bash DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/env-hooks) catkin_python_setup() -catkin_package( - CATKIN_DEPENDS sensor_msgs -) +catkin_package() ########### ## Build ## diff --git a/package.xml b/package.xml index 07599ab0..9c5a738e 100644 --- a/package.xml +++ b/package.xml @@ -14,9 +14,9 @@ catkin - sensor_msgs/ + sensor_msgs - sensor_msgs + sensor_msgs gazebo_msgs geometry_msgs From 90ad387882184ca0a042b3b5ee8f0560d30f3549 Mon Sep 17 00:00:00 2001 From: Kevin Dang Date: Tue, 4 Feb 2020 21:55:10 +0100 Subject: [PATCH 03/21] add services for laptop battery manager --- scripts/hero1-battery-manager-laptop.service | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 scripts/hero1-battery-manager-laptop.service diff --git a/scripts/hero1-battery-manager-laptop.service b/scripts/hero1-battery-manager-laptop.service new file mode 100644 index 00000000..254556cf --- /dev/null +++ b/scripts/hero1-battery-manager-laptop.service @@ -0,0 +1,15 @@ +[Unit] +Description=running battery_manager_laptop +After=hero1-roscore.service +Requires=hero1-roscore.service + +[Install] +WantedBy=multi-user.target + +[Service] +User=administrator +Restart=on-failure +ExecStart=/bin/bash -c 'source /home/administrator/.tue/setup.bash && \ + rosrun hero_bringup battery_manager_laptop \ + __name:=hero1_battery_manager_laptop \ + __ns:=/hero' From 575d24d616c07f8898f9983b23647d5f30119485 Mon Sep 17 00:00:00 2001 From: Kevin Dang Date: Tue, 11 Feb 2020 19:10:31 +0100 Subject: [PATCH 04/21] add dependency and fix code --- CMakeLists.txt | 1 + package.xml | 2 ++ src/battery_manager_laptop.cpp | 26 ++++++++++++-------------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7eb7267d..3e47dfc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.0.2) project(hero_bringup) find_package(catkin REQUIRED COMPONENTS + roscpp sensor_msgs ) diff --git a/package.xml b/package.xml index 9c5a738e..dedab251 100644 --- a/package.xml +++ b/package.xml @@ -14,8 +14,10 @@ catkin + roscpp sensor_msgs + roscpp sensor_msgs gazebo_msgs diff --git a/src/battery_manager_laptop.cpp b/src/battery_manager_laptop.cpp index 6c3a0fb5..93eec9d4 100644 --- a/src/battery_manager_laptop.cpp +++ b/src/battery_manager_laptop.cpp @@ -3,20 +3,17 @@ #include -ros::Publisher speech_pub; -ros::Subscriber percentage_sub; - double capacity; double charge; -uint8 percentage; +int percentage; void batteryCallback(const sensor_msgs::BatteryState::ConstPtr& msg) { - if (msg.location == "hero2") + if (msg->location == "hero2") { - capacity = msg.capacity; - charge = msg.charge; + capacity = msg->capacity; + charge = msg->charge; percentage = (charge/capacity)*100; } } @@ -24,18 +21,19 @@ void batteryCallback(const sensor_msgs::BatteryState::ConstPtr& msg) int main(int argc, char **argv) { - ros::init(arc, argv, "Battery_manager_laptop"); + ros::init(argc, argv, "Battery_manager_laptop"); ros::NodeHandle gn; - uint8 middle = 50; - uint8 low = 20; - uint8 empty = 10; + int middle = 50; + int low = 20; + int empty = 10; std::string message = ""; + std::string old_message = ""; - battery_sub = gn.subscribe("battery", 1, batteryCallback); - speech_pub = gn.advertise("text_to_speech/input", 10); + ros::Subscriber battery_sub = gn.subscribe("battery", 1, batteryCallback); + ros::Publisher speech_pub = gn.advertise("text_to_speech/input", 10); - ros::Rate loop_rate(1.0) + ros::Rate loop_rate(1.0); while(gn.ok()) { From 9283fd7845fe43da09c7688b3ce92403e0e586d2 Mon Sep 17 00:00:00 2001 From: Kevin Dang Date: Tue, 11 Feb 2020 21:49:15 +0100 Subject: [PATCH 05/21] fix add spin --- src/battery_manager_laptop.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battery_manager_laptop.cpp b/src/battery_manager_laptop.cpp index 93eec9d4..cf662ad8 100644 --- a/src/battery_manager_laptop.cpp +++ b/src/battery_manager_laptop.cpp @@ -7,7 +7,6 @@ double capacity; double charge; int percentage; - void batteryCallback(const sensor_msgs::BatteryState::ConstPtr& msg) { if (msg->location == "hero2") @@ -37,6 +36,7 @@ int main(int argc, char **argv) while(gn.ok()) { + ros::spinOnce(); // check battery status if (percentage < empty) { From c68176c5c2e64afbfb01dc8ef13e6e1eea37e5d4 Mon Sep 17 00:00:00 2001 From: Kevin Dang Date: Tue, 11 Feb 2020 22:26:06 +0100 Subject: [PATCH 06/21] change message --- src/battery_manager_laptop.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/battery_manager_laptop.cpp b/src/battery_manager_laptop.cpp index cf662ad8..c993b84b 100644 --- a/src/battery_manager_laptop.cpp +++ b/src/battery_manager_laptop.cpp @@ -2,13 +2,13 @@ #include #include - -double capacity; -double charge; int percentage; void batteryCallback(const sensor_msgs::BatteryState::ConstPtr& msg) { + double capacity; + double charge; + if (msg->location == "hero2") { capacity = msg->capacity; @@ -17,7 +17,6 @@ void batteryCallback(const sensor_msgs::BatteryState::ConstPtr& msg) } } - int main(int argc, char **argv) { ros::init(argc, argv, "Battery_manager_laptop"); @@ -48,7 +47,7 @@ int main(int argc, char **argv) } else if (percentage < middle) { - message = "The laptop battery is halfway empty, charge me if possible."; + message = "The laptop battery is below half empty, charge me if possible."; } // publish voice message From 7cd9725cea4fec3c7893ff8b4fbe6560ee7d7e9a Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 11 Feb 2020 22:39:46 +0100 Subject: [PATCH 07/21] (package.xml) cleanup --- package.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package.xml b/package.xml index dedab251..416f6f16 100644 --- a/package.xml +++ b/package.xml @@ -17,9 +17,6 @@ roscpp sensor_msgs - roscpp - sensor_msgs - gazebo_msgs geometry_msgs hero_bridge @@ -29,6 +26,8 @@ python-yaml python3-yaml robot_launch_files + roscpp rospy + sensor_msgs From 43234eb4db4b5977c9efed94ffaa589d0a5b7b49 Mon Sep 17 00:00:00 2001 From: Kevin Dang Date: Tue, 18 Feb 2020 20:44:52 +0100 Subject: [PATCH 08/21] moved statements to callback --- src/battery_manager_laptop.cpp | 56 ++++++++++++++++------------------ 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/src/battery_manager_laptop.cpp b/src/battery_manager_laptop.cpp index c993b84b..8f283232 100644 --- a/src/battery_manager_laptop.cpp +++ b/src/battery_manager_laptop.cpp @@ -2,52 +2,35 @@ #include #include -int percentage; +std::string old_message = ""; void batteryCallback(const sensor_msgs::BatteryState::ConstPtr& msg) { - double capacity; - double charge; - - if (msg->location == "hero2") - { - capacity = msg->capacity; - charge = msg->charge; - percentage = (charge/capacity)*100; - } -} - -int main(int argc, char **argv) -{ - ros::init(argc, argv, "Battery_manager_laptop"); - ros::NodeHandle gn; - int middle = 50; int low = 20; int empty = 10; std::string message = ""; - std::string old_message = ""; - - ros::Subscriber battery_sub = gn.subscribe("battery", 1, batteryCallback); - ros::Publisher speech_pub = gn.advertise("text_to_speech/input", 10); + std::string location = ""; + int percentage; - ros::Rate loop_rate(1.0); - - while(gn.ok()) + if (msg->location == "hero2") { - ros::spinOnce(); + percentage = msg->percentage; + location = msg->location + ROS_INFO(percentage) + // check battery status if (percentage < empty) { - message = "The laptop battery is empty, I need power now!"; + message = "The battery on " + location + " is at " std::to_string(percentage) + "percent. Charge me now!"; } else if (percentage < low) { - message = "The laptop battery is almost empty, give me power."; + message = "The battery on " + location + " is at " std::to_string(percentage) + "percent. Charge me as soon as possible"; } else if (percentage < middle) { - message = "The laptop battery is below half empty, charge me if possible."; + message = "The battery on " + location + " is at " std::to_string(percentage) + "percent. Keep an eye on the battery"; } // publish voice message @@ -58,8 +41,23 @@ int main(int argc, char **argv) speech_pub.publish(speech_msg); old_message = message; } + } +} + +int main(int argc, char **argv) +{ + ros::init(argc, argv, "Battery_manager_laptop"); + ros::NodeHandle gn; - loop_rate.sleep(); + ros::Publisher speech_pub = gn.advertise("text_to_speech/input", 10); + ros::Subscriber battery_sub = gn.subscribe("battery", 1, batteryCallback); + + ros::Rate loop_rate(1.0); + + while(gn.ok()) + { + ros::spinOnce(); + loop_rate.sleep(); } return 0; } From da891781783cd9dd6f7d5598e4bee8ec7a97dac3 Mon Sep 17 00:00:00 2001 From: Kevin Dang Date: Tue, 18 Feb 2020 21:41:35 +0100 Subject: [PATCH 09/21] fixed variable and text --- src/battery_manager_laptop.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/battery_manager_laptop.cpp b/src/battery_manager_laptop.cpp index 8f283232..606de25f 100644 --- a/src/battery_manager_laptop.cpp +++ b/src/battery_manager_laptop.cpp @@ -2,7 +2,9 @@ #include #include + std::string old_message = ""; +ros::Publisher speech_pub; void batteryCallback(const sensor_msgs::BatteryState::ConstPtr& msg) { @@ -15,22 +17,22 @@ void batteryCallback(const sensor_msgs::BatteryState::ConstPtr& msg) if (msg->location == "hero2") { - percentage = msg->percentage; - location = msg->location - ROS_INFO(percentage) + percentage = (msg->percentage)*100; + location = msg->location; + ROS_INFO("percentage: %i", percentage); // check battery status if (percentage < empty) { - message = "The battery on " + location + " is at " std::to_string(percentage) + "percent. Charge me now!"; + message = "The battery on " + location + " is below 10 percent. Charge me now!"; } else if (percentage < low) { - message = "The battery on " + location + " is at " std::to_string(percentage) + "percent. Charge me as soon as possible"; + message = "The battery on " + location + " is below 20 percent. Charge me as soon as possible"; } else if (percentage < middle) { - message = "The battery on " + location + " is at " std::to_string(percentage) + "percent. Keep an eye on the battery"; + message = "The battery on " + location + " is below 50 percent. Keep an eye on the battery"; } // publish voice message @@ -49,8 +51,8 @@ int main(int argc, char **argv) ros::init(argc, argv, "Battery_manager_laptop"); ros::NodeHandle gn; - ros::Publisher speech_pub = gn.advertise("text_to_speech/input", 10); ros::Subscriber battery_sub = gn.subscribe("battery", 1, batteryCallback); + speech_pub = gn.advertise("text_to_speech/input", 10); ros::Rate loop_rate(1.0); From 52e08adf6e3aebac72d01e7a9cf0419377f6edce Mon Sep 17 00:00:00 2001 From: Kevin Dang Date: Tue, 18 Feb 2020 22:17:01 +0100 Subject: [PATCH 10/21] Test to speak battery percentage --- src/battery_manager_laptop.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/battery_manager_laptop.cpp b/src/battery_manager_laptop.cpp index 606de25f..40807962 100644 --- a/src/battery_manager_laptop.cpp +++ b/src/battery_manager_laptop.cpp @@ -1,6 +1,8 @@ #include #include #include +#include +#include std::string old_message = ""; @@ -8,12 +10,14 @@ ros::Publisher speech_pub; void batteryCallback(const sensor_msgs::BatteryState::ConstPtr& msg) { + int percentage; int middle = 50; int low = 20; int empty = 10; std::string message = ""; std::string location = ""; - int percentage; + std::ostringstream string_message; + if (msg->location == "hero2") { @@ -24,16 +28,23 @@ void batteryCallback(const sensor_msgs::BatteryState::ConstPtr& msg) // check battery status if (percentage < empty) { - message = "The battery on " + location + " is below 10 percent. Charge me now!"; + string_message << "The battery on" << location << " is at" << percentage << " percent. Charge me now!"; } else if (percentage < low) { - message = "The battery on " + location + " is below 20 percent. Charge me as soon as possible"; + string_message << "The battery on" << location << " is at" << percentage << " percent. Don't forget to charge me"; } else if (percentage < middle) { - message = "The battery on " + location + " is below 50 percent. Keep an eye on the battery"; + string_message << "The battery on" << location << " is at" << percentage << " percent. Keep an I on the batteries"; } + else if (percentage < 60) + { + string_message << "battery percentage is " << percentage; + } + + message = string_message.str(); + // publish voice message if (old_message != message && message != "") From f075f387507c001b0ac3cd81f5fd382c152cceff Mon Sep 17 00:00:00 2001 From: Kevin Dang Date: Tue, 3 Mar 2020 20:24:49 +0100 Subject: [PATCH 11/21] Put the paramaters to the rosparam server --- launch/hero_bringup.launch | 2 ++ parameters/hardware/battery.yaml | 3 +++ src/battery_manager_laptop.cpp | 16 ++++++---------- 3 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 parameters/hardware/battery.yaml diff --git a/launch/hero_bringup.launch b/launch/hero_bringup.launch index f011819c..86837ba0 100644 --- a/launch/hero_bringup.launch +++ b/launch/hero_bringup.launch @@ -59,6 +59,8 @@ + + diff --git a/parameters/hardware/battery.yaml b/parameters/hardware/battery.yaml new file mode 100644 index 00000000..e5db96f7 --- /dev/null +++ b/parameters/hardware/battery.yaml @@ -0,0 +1,3 @@ +battery_empty: 10 +battery_low: 20 +battery_middle: 50 diff --git a/src/battery_manager_laptop.cpp b/src/battery_manager_laptop.cpp index 40807962..ee15eb00 100644 --- a/src/battery_manager_laptop.cpp +++ b/src/battery_manager_laptop.cpp @@ -11,19 +11,20 @@ ros::Publisher speech_pub; void batteryCallback(const sensor_msgs::BatteryState::ConstPtr& msg) { int percentage; - int middle = 50; - int low = 20; - int empty = 10; + int middle; + int low; + int empty; + ros::param::get("/battery_middle", middle); + ros::param::get("/battery_low", low); + ros::param::get("/battery_empty", empty); std::string message = ""; std::string location = ""; std::ostringstream string_message; - if (msg->location == "hero2") { percentage = (msg->percentage)*100; location = msg->location; - ROS_INFO("percentage: %i", percentage); // check battery status if (percentage < empty) @@ -38,14 +39,9 @@ void batteryCallback(const sensor_msgs::BatteryState::ConstPtr& msg) { string_message << "The battery on" << location << " is at" << percentage << " percent. Keep an I on the batteries"; } - else if (percentage < 60) - { - string_message << "battery percentage is " << percentage; - } message = string_message.str(); - // publish voice message if (old_message != message && message != "") { From c345a974fe7e502646933fb666ca307797134719 Mon Sep 17 00:00:00 2001 From: Kevin Dang Date: Tue, 3 Mar 2020 20:36:52 +0100 Subject: [PATCH 12/21] made battery location a parameter --- parameters/hardware/battery.yaml | 1 + src/battery_manager_laptop.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/parameters/hardware/battery.yaml b/parameters/hardware/battery.yaml index e5db96f7..5da72e9b 100644 --- a/parameters/hardware/battery.yaml +++ b/parameters/hardware/battery.yaml @@ -1,3 +1,4 @@ +robot_location: "hero2" battery_empty: 10 battery_low: 20 battery_middle: 50 diff --git a/src/battery_manager_laptop.cpp b/src/battery_manager_laptop.cpp index ee15eb00..d7005ea6 100644 --- a/src/battery_manager_laptop.cpp +++ b/src/battery_manager_laptop.cpp @@ -14,14 +14,16 @@ void batteryCallback(const sensor_msgs::BatteryState::ConstPtr& msg) int middle; int low; int empty; - ros::param::get("/battery_middle", middle); - ros::param::get("/battery_low", low); - ros::param::get("/battery_empty", empty); std::string message = ""; std::string location = ""; + std::string robot_location = ""; std::ostringstream string_message; + ros::param::get("/battery_middle", middle); + ros::param::get("/battery_low", low); + ros::param::get("/battery_empty", empty); + ros::param::get("/robot_location", robot_location); - if (msg->location == "hero2") + if (msg->location == robot_location) { percentage = (msg->percentage)*100; location = msg->location; From cf1544aedbb6ddcb42ad78a9f279676cb90b4ffc Mon Sep 17 00:00:00 2001 From: Kevin Dang Date: Tue, 3 Mar 2020 21:47:09 +0100 Subject: [PATCH 13/21] Put everything in launch file --- launch/battery_manager_laptop.launch | 10 ++++++++++ launch/hero_bringup.launch | 3 --- scripts/hero1-battery-manager-laptop.service | 4 +--- src/battery_manager_laptop.cpp | 18 +++++++++--------- 4 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 launch/battery_manager_laptop.launch diff --git a/launch/battery_manager_laptop.launch b/launch/battery_manager_laptop.launch new file mode 100644 index 00000000..b377388e --- /dev/null +++ b/launch/battery_manager_laptop.launch @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/launch/hero_bringup.launch b/launch/hero_bringup.launch index 86837ba0..8823149a 100644 --- a/launch/hero_bringup.launch +++ b/launch/hero_bringup.launch @@ -59,9 +59,6 @@ - - - diff --git a/scripts/hero1-battery-manager-laptop.service b/scripts/hero1-battery-manager-laptop.service index 254556cf..a62211f8 100644 --- a/scripts/hero1-battery-manager-laptop.service +++ b/scripts/hero1-battery-manager-laptop.service @@ -10,6 +10,4 @@ WantedBy=multi-user.target User=administrator Restart=on-failure ExecStart=/bin/bash -c 'source /home/administrator/.tue/setup.bash && \ - rosrun hero_bringup battery_manager_laptop \ - __name:=hero1_battery_manager_laptop \ - __ns:=/hero' + roslaunch hero_bringup battery_manager_laptop diff --git a/src/battery_manager_laptop.cpp b/src/battery_manager_laptop.cpp index d7005ea6..ba273ff0 100644 --- a/src/battery_manager_laptop.cpp +++ b/src/battery_manager_laptop.cpp @@ -4,24 +4,19 @@ #include #include - +int middle; +int low; +int empty; +std::string robot_location = ""; std::string old_message = ""; ros::Publisher speech_pub; void batteryCallback(const sensor_msgs::BatteryState::ConstPtr& msg) { int percentage; - int middle; - int low; - int empty; std::string message = ""; std::string location = ""; - std::string robot_location = ""; std::ostringstream string_message; - ros::param::get("/battery_middle", middle); - ros::param::get("/battery_low", low); - ros::param::get("/battery_empty", empty); - ros::param::get("/robot_location", robot_location); if (msg->location == robot_location) { @@ -60,6 +55,11 @@ int main(int argc, char **argv) ros::init(argc, argv, "Battery_manager_laptop"); ros::NodeHandle gn; + ros::param::get("/battery_middle", middle); + ros::param::get("/battery_low", low); + ros::param::get("/battery_empty", empty); + ros::param::get("/robot_location", robot_location); + ros::Subscriber battery_sub = gn.subscribe("battery", 1, batteryCallback); speech_pub = gn.advertise("text_to_speech/input", 10); From dadbe8d58a2c68695fb509eea84d535151502fc9 Mon Sep 17 00:00:00 2001 From: Kevin Dang Date: Tue, 3 Mar 2020 22:22:38 +0100 Subject: [PATCH 14/21] Rename files for clarity --- launch/battery_manager_laptop.launch | 2 +- .../hardware/{battery.yaml => battery_manager_laptop.yaml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename parameters/hardware/{battery.yaml => battery_manager_laptop.yaml} (100%) diff --git a/launch/battery_manager_laptop.launch b/launch/battery_manager_laptop.launch index b377388e..3bac63d6 100644 --- a/launch/battery_manager_laptop.launch +++ b/launch/battery_manager_laptop.launch @@ -4,7 +4,7 @@ - + diff --git a/parameters/hardware/battery.yaml b/parameters/hardware/battery_manager_laptop.yaml similarity index 100% rename from parameters/hardware/battery.yaml rename to parameters/hardware/battery_manager_laptop.yaml From 9b7142a712503f1eaab6f8b43a9affe9a4fea22b Mon Sep 17 00:00:00 2001 From: Kevin Dang Date: Tue, 3 Mar 2020 22:37:23 +0100 Subject: [PATCH 15/21] Rename2 --- launch/battery_manager_laptop.launch | 4 ++-- ...battery_manager_laptop.yaml => battery_manager_hero2.yaml} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename parameters/hardware/{battery_manager_laptop.yaml => battery_manager_hero2.yaml} (100%) diff --git a/launch/battery_manager_laptop.launch b/launch/battery_manager_laptop.launch index 3bac63d6..7ea31019 100644 --- a/launch/battery_manager_laptop.launch +++ b/launch/battery_manager_laptop.launch @@ -4,7 +4,7 @@ - - + + diff --git a/parameters/hardware/battery_manager_laptop.yaml b/parameters/hardware/battery_manager_hero2.yaml similarity index 100% rename from parameters/hardware/battery_manager_laptop.yaml rename to parameters/hardware/battery_manager_hero2.yaml From 5ff7025f7dd265b53b781accb82a67a7c22da242 Mon Sep 17 00:00:00 2001 From: Peter van Dooren Date: Sat, 7 Mar 2020 10:55:54 +0100 Subject: [PATCH 16/21] moved service to hero2 folders --- .../hero2-battery-manager-laptop.service} | 2 +- .../hero2/hero2-battery-manager-laptop.service | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) rename scripts/{hero1-battery-manager-laptop.service => services/hero2-demo/hero2-battery-manager-laptop.service} (94%) create mode 100644 scripts/services/hero2/hero2-battery-manager-laptop.service diff --git a/scripts/hero1-battery-manager-laptop.service b/scripts/services/hero2-demo/hero2-battery-manager-laptop.service similarity index 94% rename from scripts/hero1-battery-manager-laptop.service rename to scripts/services/hero2-demo/hero2-battery-manager-laptop.service index a62211f8..9530342f 100644 --- a/scripts/hero1-battery-manager-laptop.service +++ b/scripts/services/hero2-demo/hero2-battery-manager-laptop.service @@ -7,7 +7,7 @@ Requires=hero1-roscore.service WantedBy=multi-user.target [Service] -User=administrator +User=demo Restart=on-failure ExecStart=/bin/bash -c 'source /home/administrator/.tue/setup.bash && \ roslaunch hero_bringup battery_manager_laptop diff --git a/scripts/services/hero2/hero2-battery-manager-laptop.service b/scripts/services/hero2/hero2-battery-manager-laptop.service new file mode 100644 index 00000000..8bc066af --- /dev/null +++ b/scripts/services/hero2/hero2-battery-manager-laptop.service @@ -0,0 +1,13 @@ +[Unit] +Description=running battery_manager_laptop +After=hero1-roscore.service +Requires=hero1-roscore.service + +[Install] +WantedBy=multi-user.target + +[Service] +User=amigo +Restart=on-failure +ExecStart=/bin/bash -c 'source /home/administrator/.tue/setup.bash && \ + roslaunch hero_bringup battery_manager_laptop From d736dc9e4dad9d3ab1520b5e0c121b0ff2d51436 Mon Sep 17 00:00:00 2001 From: Peter van Dooren Date: Sat, 7 Mar 2020 11:18:24 +0100 Subject: [PATCH 17/21] fixed demo names in service --- .../hero2-demo/hero2-battery-manager-laptop.service | 6 +++--- scripts/services/hero2/hero2-battery-manager-laptop.service | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/services/hero2-demo/hero2-battery-manager-laptop.service b/scripts/services/hero2-demo/hero2-battery-manager-laptop.service index 9530342f..e2a96f61 100644 --- a/scripts/services/hero2-demo/hero2-battery-manager-laptop.service +++ b/scripts/services/hero2-demo/hero2-battery-manager-laptop.service @@ -1,7 +1,7 @@ [Unit] Description=running battery_manager_laptop -After=hero1-roscore.service -Requires=hero1-roscore.service +After=hero2-roscore.service +Requires=hero2-roscore.service [Install] WantedBy=multi-user.target @@ -9,5 +9,5 @@ WantedBy=multi-user.target [Service] User=demo Restart=on-failure -ExecStart=/bin/bash -c 'source /home/administrator/.tue/setup.bash && \ +ExecStart=/bin/bash -c 'source /home/demo/.tue/setup.bash && \ roslaunch hero_bringup battery_manager_laptop diff --git a/scripts/services/hero2/hero2-battery-manager-laptop.service b/scripts/services/hero2/hero2-battery-manager-laptop.service index 8bc066af..c2c3da56 100644 --- a/scripts/services/hero2/hero2-battery-manager-laptop.service +++ b/scripts/services/hero2/hero2-battery-manager-laptop.service @@ -1,7 +1,7 @@ [Unit] Description=running battery_manager_laptop -After=hero1-roscore.service -Requires=hero1-roscore.service +After=hero2-roscore.service +Requires=hero2-roscore.service [Install] WantedBy=multi-user.target @@ -9,5 +9,5 @@ WantedBy=multi-user.target [Service] User=amigo Restart=on-failure -ExecStart=/bin/bash -c 'source /home/administrator/.tue/setup.bash && \ +ExecStart=/bin/bash -c 'source /home/amigo/.tue/setup.bash && \ roslaunch hero_bringup battery_manager_laptop From a23ea8aa5f8b0a3e4a98226daf056e3cc0e31a08 Mon Sep 17 00:00:00 2001 From: Peter van Dooren Date: Sat, 7 Mar 2020 12:38:08 +0100 Subject: [PATCH 18/21] no roscore service on hero2 --- .../services/hero2-demo/hero2-battery-manager-laptop.service | 2 -- scripts/services/hero2/hero2-battery-manager-laptop.service | 2 -- 2 files changed, 4 deletions(-) diff --git a/scripts/services/hero2-demo/hero2-battery-manager-laptop.service b/scripts/services/hero2-demo/hero2-battery-manager-laptop.service index e2a96f61..8d23b9f2 100644 --- a/scripts/services/hero2-demo/hero2-battery-manager-laptop.service +++ b/scripts/services/hero2-demo/hero2-battery-manager-laptop.service @@ -1,7 +1,5 @@ [Unit] Description=running battery_manager_laptop -After=hero2-roscore.service -Requires=hero2-roscore.service [Install] WantedBy=multi-user.target diff --git a/scripts/services/hero2/hero2-battery-manager-laptop.service b/scripts/services/hero2/hero2-battery-manager-laptop.service index c2c3da56..97390587 100644 --- a/scripts/services/hero2/hero2-battery-manager-laptop.service +++ b/scripts/services/hero2/hero2-battery-manager-laptop.service @@ -1,7 +1,5 @@ [Unit] Description=running battery_manager_laptop -After=hero2-roscore.service -Requires=hero2-roscore.service [Install] WantedBy=multi-user.target From b40cc8e2791d8ffa1926bfb188a6a9c1fa6f1a89 Mon Sep 17 00:00:00 2001 From: Peter van Dooren Date: Sat, 7 Mar 2020 16:15:57 +0100 Subject: [PATCH 19/21] fixed quotations and file extention --- .../services/hero2-demo/hero2-battery-manager-laptop.service | 2 +- scripts/services/hero2/hero2-battery-manager-laptop.service | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/services/hero2-demo/hero2-battery-manager-laptop.service b/scripts/services/hero2-demo/hero2-battery-manager-laptop.service index 8d23b9f2..c4282773 100644 --- a/scripts/services/hero2-demo/hero2-battery-manager-laptop.service +++ b/scripts/services/hero2-demo/hero2-battery-manager-laptop.service @@ -8,4 +8,4 @@ WantedBy=multi-user.target User=demo Restart=on-failure ExecStart=/bin/bash -c 'source /home/demo/.tue/setup.bash && \ - roslaunch hero_bringup battery_manager_laptop + roslaunch hero_bringup battery_manager_laptop.launch' diff --git a/scripts/services/hero2/hero2-battery-manager-laptop.service b/scripts/services/hero2/hero2-battery-manager-laptop.service index 97390587..0b2fa6b0 100644 --- a/scripts/services/hero2/hero2-battery-manager-laptop.service +++ b/scripts/services/hero2/hero2-battery-manager-laptop.service @@ -8,4 +8,4 @@ WantedBy=multi-user.target User=amigo Restart=on-failure ExecStart=/bin/bash -c 'source /home/amigo/.tue/setup.bash && \ - roslaunch hero_bringup battery_manager_laptop + roslaunch hero_bringup battery_manager_laptop.launch' From 2742b9b84541534778097b26af6d20e43acb18cd Mon Sep 17 00:00:00 2001 From: Peter van Dooren Date: Sat, 7 Mar 2020 16:39:01 +0100 Subject: [PATCH 20/21] renamed laptop to hero2 --- ...ttery_manager_laptop.launch => battery_manager_hero2.launch} | 0 .../services/hero2-demo/hero2-battery-manager-laptop.service | 2 +- scripts/services/hero2/hero2-battery-manager-laptop.service | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename launch/{battery_manager_laptop.launch => battery_manager_hero2.launch} (100%) diff --git a/launch/battery_manager_laptop.launch b/launch/battery_manager_hero2.launch similarity index 100% rename from launch/battery_manager_laptop.launch rename to launch/battery_manager_hero2.launch diff --git a/scripts/services/hero2-demo/hero2-battery-manager-laptop.service b/scripts/services/hero2-demo/hero2-battery-manager-laptop.service index c4282773..4d550ee5 100644 --- a/scripts/services/hero2-demo/hero2-battery-manager-laptop.service +++ b/scripts/services/hero2-demo/hero2-battery-manager-laptop.service @@ -8,4 +8,4 @@ WantedBy=multi-user.target User=demo Restart=on-failure ExecStart=/bin/bash -c 'source /home/demo/.tue/setup.bash && \ - roslaunch hero_bringup battery_manager_laptop.launch' + roslaunch hero_bringup battery_manager_hero2.launch' diff --git a/scripts/services/hero2/hero2-battery-manager-laptop.service b/scripts/services/hero2/hero2-battery-manager-laptop.service index 0b2fa6b0..3df5e31b 100644 --- a/scripts/services/hero2/hero2-battery-manager-laptop.service +++ b/scripts/services/hero2/hero2-battery-manager-laptop.service @@ -8,4 +8,4 @@ WantedBy=multi-user.target User=amigo Restart=on-failure ExecStart=/bin/bash -c 'source /home/amigo/.tue/setup.bash && \ - roslaunch hero_bringup battery_manager_laptop.launch' + roslaunch hero_bringup battery_manager_hero2.launch' From d807f5fbf05fd8517ba819ba14ac4d14fa3b002b Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 10 Mar 2020 22:04:43 +0100 Subject: [PATCH 21/21] rename battery service files --- ...-manager-laptop.service => hero2-demo-battery-manager.service} | 0 ...ttery-manager-laptop.service => hero2-battery-manager.service} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename scripts/services/hero2-demo/{hero2-battery-manager-laptop.service => hero2-demo-battery-manager.service} (100%) rename scripts/services/hero2/{hero2-battery-manager-laptop.service => hero2-battery-manager.service} (100%) diff --git a/scripts/services/hero2-demo/hero2-battery-manager-laptop.service b/scripts/services/hero2-demo/hero2-demo-battery-manager.service similarity index 100% rename from scripts/services/hero2-demo/hero2-battery-manager-laptop.service rename to scripts/services/hero2-demo/hero2-demo-battery-manager.service diff --git a/scripts/services/hero2/hero2-battery-manager-laptop.service b/scripts/services/hero2/hero2-battery-manager.service similarity index 100% rename from scripts/services/hero2/hero2-battery-manager-laptop.service rename to scripts/services/hero2/hero2-battery-manager.service