diff --git a/arlobot_ros/msg/ArloSafety.msg b/arlobot_ros/msg/ArloSafety.msg index 0863abec..e07aea48 100644 --- a/arlobot_ros/msg/ArloSafety.msg +++ b/arlobot_ros/msg/ArloSafety.msg @@ -1,6 +1,2 @@ bool safe_to_go bool safe_to_operate -bool unplugging -bool ac_power -int16 laptop_battery_percent -bool dangerous_doors_open \ No newline at end of file diff --git a/arlobot_ros/msg/ArloStatus.msg b/arlobot_ros/msg/ArloStatus.msg index 46ae03a5..b76d1337 100644 --- a/arlobot_ros/msg/ArloStatus.msg +++ b/arlobot_ros/msg/ArloStatus.msg @@ -10,7 +10,5 @@ bool left_motor_power bool right_motor_power float32 robot_battery_level bool robot_battery_low -int16 laptop_battery_percent -bool ac_power bool cliff bool floor_obstacle diff --git a/arlobot_ros/propellerbot_node.py b/arlobot_ros/propellerbot_node.py index 8d13846b..9b3c22d6 100755 --- a/arlobot_ros/propellerbot_node.py +++ b/arlobot_ros/propellerbot_node.py @@ -63,7 +63,6 @@ def __init__(self): self._broadcast_static_odometry = False self._leftMotorPower = False self._rightMotorPower = False - self._laptop_battery_percent = 100 # Store last x, y and heading for reuse when we reset # I took off the ~, because that was causing these to reset to default on every restart # even if roscore was still up. @@ -265,10 +264,6 @@ def _safety_shutdown(self, status): self._SafeToOperate = status.safe_to_operate self._safeToGo = status.safe_to_go - self._settings_from_ros["pluggedIn"] = status.ac_power - - self._laptop_battery_percent = status.laptop_battery_percent - # noinspection Duplicates def _propellerOdomDataHandler(self, data): """ diff --git a/node/behaviors/polling.js b/node/behaviors/polling.js index 63ae5708..93064edb 100644 --- a/node/behaviors/polling.js +++ b/node/behaviors/polling.js @@ -9,7 +9,6 @@ const webModelFunctions = require('../webModelFunctions'); const personalData = require('../personalData'); const robotModel = require('../robotModel'); const speechEngine = require('../speechEngine'); -const checkBattery = require('../checkBattery'); const getQRcodes = require('../getQRcodes'); const saveScreenShotForWeb = require('../saveScreenShotForWeb'); const howManySecondsSince = require('../howManySecondsSince'); @@ -45,9 +44,6 @@ async function polling() { // noinspection ES6MissingAwait publishRobotURL.updateRobotURL(); } - if (intervalCount === 0) { - checkBattery(); - } if (intervalCount === intervalTop) { if (!webModel.cameraOn) { saveScreenShotForWeb(); diff --git a/node/behaviors/startROS.js b/node/behaviors/startROS.js index 248be6c2..6f62b5a7 100644 --- a/node/behaviors/startROS.js +++ b/node/behaviors/startROS.js @@ -123,7 +123,6 @@ async function startROS() { webModelFunctions.updateRosTopicItem('gyro_heading', 0.0); webModelFunctions.updateRosTopicItem('left_motor_power', true); webModelFunctions.updateRosTopicItem('right_motor_power', true); - webModelFunctions.updateRosTopicItem('laptopBatteryPercent', 85); webModelFunctions.updateRosTopicItem('robot_battery_level', 12.6); webModelFunctions.updateRosTopicItem('robot_battery_low', false); } diff --git a/node/checkBattery.js b/node/checkBattery.js deleted file mode 100644 index 74b59956..00000000 --- a/node/checkBattery.js +++ /dev/null @@ -1,131 +0,0 @@ -const fs = require('fs'); -const { glob } = require('glob'); -const personalData = require('./personalData'); -const webModel = require('./webModel'); -const webModelFunctions = require('./webModelFunctions'); - -const batteryLevelFileWildcard = '/sys/class/power_supply/BAT*/uevent'; -const pluggedInFileWildcard = '/sys/class/power_supply/AC*/uevent'; - -let pluggedInFile; -let batteryLevelFile; - -async function getFilenames() { - if (!pluggedInFile && !Array.isArray(pluggedInFile)) { - pluggedInFile = await glob(pluggedInFileWildcard); - if (pluggedInFile && pluggedInFile.length > 0) { - pluggedInFile = pluggedInFile[0]; - } - } - - if (!batteryLevelFile && !Array.isArray(batteryLevelFile)) { - batteryLevelFile = await glob(batteryLevelFileWildcard); - if (batteryLevelFile && batteryLevelFile.length > 0) { - batteryLevelFile = batteryLevelFile[0]; - } - } -} - -const checkBattery = async (logIt) => { - await getFilenames(); - let batteryLevelFoundInROS = false; - let pluggedInStatusFoundInROS = false; - if (webModel.ROSisRunning) { - // If ROS is running, use existing ROS Topic input data. - const rosBatteryLevelTopicIndex = webModel.rosTopicItems.findIndex( - (x) => x.rosName === 'laptop_battery_percent', - ); - if ( - rosBatteryLevelTopicIndex > -1 && - Number.isInteger(webModel.rosTopicItems[rosBatteryLevelTopicIndex].status) - ) { - webModelFunctions.update( - 'laptopBatteryPercentage', - webModel.rosTopicItems[rosBatteryLevelTopicIndex].status, - ); - batteryLevelFoundInROS = true; - } - - const rosAcPowerTopicIndex = webModel.rosTopicItems.findIndex( - (x) => x.rosName === 'acPower', - ); - if ( - rosAcPowerTopicIndex > -1 && - (webModel.rosTopicItems[rosAcPowerTopicIndex].status === true || - webModel.rosTopicItems[rosAcPowerTopicIndex].status === false) - ) { - webModelFunctions.update( - 'pluggedIn', - webModel.rosTopicItems[rosAcPowerTopicIndex].status, - ); - pluggedInStatusFoundInROS = true; - } - } - - // If ROS is not running, check Linux files for battery and plugged in state. - if ( - !batteryLevelFoundInROS && - batteryLevelFile && - !Array.isArray(batteryLevelFile) - ) { - fs.readFile(batteryLevelFile, 'utf8', (err, data) => { - if (err) { - console.error('Error getting battery level'); - } else { - webModelFunctions.update( - 'laptopBatteryPercentage', - parseInt( - data - .split('\n') - .find((result) => result.indexOf('POWER_SUPPLY_CAPACITY') > -1) - .split('=')[1], - 10, - ), - ); - } - }); - } - - if (!pluggedInStatusFoundInROS) { - if (pluggedInFile && !Array.isArray(pluggedInFile)) { - fs.readFile(pluggedInFile, 'utf8', (err, data) => { - if (err) { - console.error('Error reading AC status file.'); - } else { - webModelFunctions.update( - 'pluggedIn', - data.split('\n').indexOf('POWER_SUPPLY_ONLINE=1') > -1, - ); - } - }); - } else { - webModelFunctions.update('pluggedIn', 'unknown'); - } - } - - /** @namespace personalData.batteryConsideredFullAt */ - if (Number.isInteger(webModel.laptopBatteryPercentage)) { - if ( - webModel.laptopBatteryPercentage >= personalData.batteryConsideredFullAt - ) { - webModelFunctions.update('laptopFullyCharged', true); - } else { - webModelFunctions.update('laptopFullyCharged', false); - } - } - - if (logIt) { - console.log( - webModel.laptopBatteryPercentage, - webModel.pluggedIn, - webModel.laptopFullyCharged, - ); - } -}; -module.exports = checkBattery; - -if (require.main === module) { - (async function () { - await checkBattery(true); - })(); -} diff --git a/node/speechModel.js b/node/speechModel.js index 2b9a9b0b..848fa937 100644 --- a/node/speechModel.js +++ b/node/speechModel.js @@ -212,28 +212,6 @@ const speechModel = { }, }, }, - laptopFullyCharged: { - repeatInterval: 0, - spacing: 0, - true: { - thingsToSay: { - repeat: true, - charged: { - text: 'Computer battery fully charged!', - weight: 100, - }, - }, - }, - false: { - thingsToSay: { - repeat: true, - unDone: { - text: 'Starting to get tired.', - weight: 100, - }, - }, - }, - }, mostRecentArrival: { repeatInterval: 0, spacing: 0, diff --git a/node/webModel.js b/node/webModel.js index ad4cff05..ae5575b5 100644 --- a/node/webModel.js +++ b/node/webModel.js @@ -26,8 +26,6 @@ module.exports = { checkUsbRelayBank: true, // Always read once on load haltRobot: false, semaphoreFilesRead: false, - laptopFullyCharged: 'unknown', - laptopBatteryPercentage: '???', logStreamerRunning: false, shutdownRequested: false, status: 'Arlo behavior is not running.', @@ -164,14 +162,6 @@ module.exports = { alertOn: false, alertBtnClass: 'btn-danger', }, - { - rosName: 'laptop_battery_percent', - fancyName: 'Laptop Battery %', - status: '', - btnClass: '', - alertOn: false, - alertBtnClass: 'btn-danger', - }, { rosName: 'robot_battery_level', fancyName: 'Robot Battery Volts', diff --git a/node/webModelFunctions.js b/node/webModelFunctions.js index 94953e83..7beb177f 100644 --- a/node/webModelFunctions.js +++ b/node/webModelFunctions.js @@ -83,9 +83,7 @@ const updateRosParameter = (key, value) => { exports.updateRosParameter = updateRosParameter; const updateRosTopicItem = (key, value) => { - if (key === 'robot_battery_level') { - value = value.toFixed(1); - } else if (key === 'heading' || key === 'gyro_heading') { + if (key === 'heading' || key === 'gyro_heading') { value = value.toFixed(3); } const arrayIndex = webModel.rosTopicItems.findIndex((x) => x.rosName === key);