Skip to content
This repository was archived by the owner on Jul 22, 2021. It is now read-only.

Commit 8019060

Browse files
Yadunundaaronchongthyouliangtanmrushyendramxgrey
authored
Develop/dispatcher demo (#217)
* Initial commit Signed-off-by: Yadunund <[email protected]> * Added unit tests for PowerSystem * Completed implementation of SystemTraits Signed-off-by: Yadunund Vijay <[email protected]> * Fixed test Signed-off-by: Yadunund Vijay <[email protected]> * Refactored MechanicalSystem * Added EstimateBattery Signed-off-by: Yadunund Vijay <[email protected]> * Moved soc implementation to SimpleBatteryEstimator * Debugging soc * Debuggin messages * More debugging * Initial signs of working discharge model * Added more tests * Fixed tests * Removed message printouts * Replaced KE with energy for acceleration * Added documentation and linted * Added CleaningTaskPlanner * Added CleaningTaskPlanner.cpp and corrected unit test * Added CleaningTaskPlanner Signed-off-by: Yadunund Vijay <[email protected]> * Added virtual destructor Signed-off-by: Yadunund Vijay <[email protected]> * Debugging Signed-off-by: Yadunund Vijay <[email protected]> * Fixed test for CleaningTaskPlanner Signed-off-by: Yadunund Vijay <[email protected]> * More tests Signed-off-by: Yadunund Vijay <[email protected]> * Restructured CMakeLists and fixed warnings * Refactored * Setting up rmf_tasks package Signed-off-by: Aaron Chong <[email protected]> * Basic setup * AGV state defined and implemented * Request abstract API and derived API for delivery Signed-off-by: Aaron Chong <[email protected]> * Delivery request estimation implemented * ChargeBattery request implemented * Using finish_duration instead of finish_time * Switching back to using Time instead of Duration for finish_time Signed-off-by: Aaron Chong <[email protected]> * Migration to using this library is done * Increased sim_step to 0.5 * Cleaned up unused source files and cmake commands * Initial commit Signed-off-by: Yadunund Vijay <[email protected]> * Started implementation * Completed migration and added toy ptoblem as unit test Signed-off-by: Yadunund Vijay <[email protected]> * Moved threshold_soc into StateConfig class * Fixed UB in pop_unassigned * Fixed UB in Candidates::make() * Updated expand_candidate and implemented correct_assingments() to add missing charging tasks * Fixed UB in greedy_solve() * estimate_finish() of Delivery checks if robot can return to its charger after reaching dropoff waypoint * Added Clean request * Cleanup * Using rmf_traffic::agv::Plan::Start for holding waypoint and time information (#188) * Using rmf_traffic::agv::Plan::Start for holding waypoint and time information Signed-off-by: Aaron Chong <[email protected]> * Added tests for State and StateConfig exceptions Signed-off-by: Aaron Chong <[email protected]> * Using passed relative_start_time instead of getting current time using chrono Signed-off-by: Aaron Chong <[email protected]> * Changing name from plan_start to location Signed-off-by: Aaron Chong <[email protected]> * Removed unused efficiency from PowerSystem and added estimate_voltage() method to BatterySystem * Switched to new BatterySystem API * Renamed rmf_tasks to rmf_task * Update schedule with docking itinerary (#190) * Update schedule with docking itinerary * Use optional of reference wrapper (#191) Signed-off-by: Aaron Chong <[email protected]> * Set docking itinerary every 1s Co-authored-by: Aaron Chong <[email protected]> * Replaced task_id with request in Assignment * Renamed earliest_start_time to deployment_time in assignment. Modified expand_candidate. * TaskPlanner::Configuration no longer takes in a charging request. The factory is used to construct a charging request. * update msgs for dispatcher (#193) * Fixed dynamic cast * Using magnitude of w and alpha in compute_change_in_charge() * Fix lifetime of variant_duration variable (#197) Fixes redeclaration of variant_duration inside if-block scope. * Added new Clean task, changed TaskProfile and SubmitTask to use explicit message definitions (#200) * Added new Clean task, changed TaskProfile and SubmitTask to use enum for type and explicit message definitions * Reverted to use TaskType, modified value type to uint32 * add eval enum to submit task srv (#201) * Develop/task planner integration (#199) * Added set_queue and requests methods to TaskManager * Added make_clean to convert from request to task * Commented out Delivery and Loop request subs in Adapter * Commented out Delivery and Loop related code in FleetUpdateHandle * Updated Adapter::add_fleet() * Undid changes to add_fleet which broke API/ABI. Added set_task_planner_params() to FleetUpdateHandle * Added accept_task_request to FleetUpdateHandle * Added BidNotice callback * Updated bidding topic names and started processing clean task request * Added dock related messages to rmf_fleet_msgs. Finished processing clean request. * Moved BidNotice callback into FleetUpdateHandle.cpp * RobotContext constructor taskes in State and StateConfig which are used for task planning * Added is_charger() and set_charger() methods to Waypoint API * add_robot uses get_nearest_charger() * parse_graph parses is_charger option * Added state_config() to RobotContext * Added dispatch_request_cb() * Updated set_queue() and make_clean() functions. Switching to using ConstRequestPtr everywhere * Broke Task constructor API * Added timer to TaskManager * Locking mutex when modifying task queue * Dispatcher pipeline works! * Cleaned up printouts * Update finish time after robot has completed task * Get latest state of robots before running task planner. TODO: Update battery soc * Fixed bug in compute_change_of_charge() * Using magnitude of w and alpha in compute_change_in_charge() * Added update_battery_soc() to RobotUpdateHandle which updates the current_battery_soc in RobotContext. Initial states for task planning use this updated battery_soc * Added ChargeBattery task factory * Added skeleton for WaitForCharge * Fix lifetime of variant_duration variable (#197) Fixes redeclaration of variant_duration inside if-block scope. * Fixed return value of battery_system() in ChargeBattery * Catch exception for invalid cleaning trajectories * Populate finish_time in BidProposal * Added observable and publisher for current_battery_soc * Updated begin() for WaitForCharge phase * Fixed completion logic in WaitForCharge * Fixed typo * Updated fleet adapter launch params. Populate task id in TaskProfile in Status msg * Become stubborn while docking * Added recharge_threshold parameter to fleet adapter launch * Fix missing return value in current_battery_soc() * Populate robot_name in BidProposal msg * TaskManager queues charging tasks * Modify start in set_queue() * Added second GoToPlace phase for Clean task * Added TODO to account for travel from end of cleaning trajectory to end_waypoint * Populate robot name in TaskSummary msg * Populate TaskSummary * Changed TaskType enum names and updated FleetUpdateHandle to work with new TaskProfile msg Co-authored-by: Rushyendra Maganty <[email protected]> Co-authored-by: Michael X. Grey <[email protected]> * ChargeBattery task creates WaitForCharge phase with 0.99 max threshold. Fixed valid() check in PowerSystem * Added equality constraint in PowerSystem::valid() * Add unit test to detect implicit charging task at the start of Assignments (#208) * Add unit test to detect implicit charging task in the beginning Test checks for discrepancy in state of charge to see if charging has been taken into account without being explicitly added to Assignments. * Fix false negative in unit test case for implicit charging task Checks if task is a charging task before returning an error. * Deal with implicit charging before first assignment (#209) * Reduce heuristic overestimation and ignore charging task costs in TaskPlanner (#207) * Improved heuristic to reduce overestimation Takes into account earliest start time when computing the cost of a task, more closely mimicing g(n). * Add field to Assignment determining whether to include in final cost Enables charging tasks to be ignored from final calculation. Adds miscellaneous comments explaining h(n) calculation. * Remove additional include_in_cost field from Assignment Use dynamic_pointer_cast to identify charging requests instead. * Add testcase illustrating difference in costs with new g(n) and h(n) * Include smallest variant cost in h(n) computation Include the smallest possible variant cost among the unasigned tasks for each candidate when computing the heuristic cost. * Loop and Delivery integration with dispatcher framework (#211) * Added creation of delivery request * Modified make and extended API for Delivery request * Added items() and dropoff_start() to Delivery request * Deleted old Delivery task implementation * Loop request skeleton * Implemented Loop request * Parse loop request in FleetUpdateHandle * Integrated Loop requests * Cleanup make_loop * Updated tests after merging in heuristic changes for task planner * Change id field of Request to string and modify TaskPlanner to use internal ids instead (#203) * Change request id field from size_t to string Modifies task planner, tests and requests code to use string based id instead of size_t. * Replace map with autogenerated IDs upon task insertion into Node Creates wrappers for Assignments, containing an internal_id field. This field is generated by the Node when inserting a new task. * Updated FleetUpdateHandle and Tasks to use string request id * Cache estimated values to speed up TaskPlanner (#212) * Squashed commit of the following: commit b69a5de Merge: 6206e41 005e88b Author: mrushyendra <[email protected]> Date: Tue Nov 10 13:24:30 2020 +0800 Merge branch 'feature/task_planner' into refactor_id_w_map commit 005e88b Author: Rushyendra Maganty <[email protected]> Date: Tue Nov 10 12:08:34 2020 +0800 Reduce heuristic overestimation and ignore charging task costs in TaskPlanner (#207) * Improved heuristic to reduce overestimation Takes into account earliest start time when computing the cost of a task, more closely mimicing g(n). * Add field to Assignment determining whether to include in final cost Enables charging tasks to be ignored from final calculation. Adds miscellaneous comments explaining h(n) calculation. * Remove additional include_in_cost field from Assignment Use dynamic_pointer_cast to identify charging requests instead. * Add testcase illustrating difference in costs with new g(n) and h(n) * Include smallest variant cost in h(n) computation Include the smallest possible variant cost among the unasigned tasks for each candidate when computing the heuristic cost. commit 6206e41 Author: mrushyendra <[email protected]> Date: Tue Nov 3 18:20:24 2020 +0800 Replace map with autogenerated IDs upon task insertion into Node Creates wrappers for Assignments, containing an internal_id field. This field is generated by the Node when inserting a new task. commit d00b3f3 Author: mrushyendra <[email protected]> Date: Tue Nov 3 10:06:46 2020 +0800 Change request id field from size_t to string Modifies task planner, tests and requests code to use string based id instead of size_t. * Cache request estimate values in TaskPlanner Create new EstimateCache class and memoize the duration and charge consumed when travelling betwen any 2 waypoints on the graph. * Recreate TaskPlanner in tests for more accurate run time measurements Also adds other stylistic changes including renaming of CacheElem to CacheElement. * few liners to populate start and estimated finish time (#216) * Cleaned up commented code * Made ChargeBattery ids unique * add fleetname to task summary * Debug/task planner candidates (#218) * Added test for planning an impossible to complete task * TaskPlanner returns empty assignments if request is impossible to complete * Updated API documentation in FleetUpdateHandle * TaskPlanner returns an std::variant (#221) * TaskPlanner solve methods return variant * Cleanup * Updated fleet adapter implementation * Fixed typo * Fixed logging * Fixed logging * Changed logging level to Error for task planner failure messages * Automatic retreat for battery recharging (#222) * TaskManager initiates a ChargeBattery request when robot is idle and battery will fall below threshold * Adjusted retreat threshold * Take into account battery drain while idling in TaskPlanner estimates (#223) * Take into account charge depletion due to waiting to begin task * Add charge depletion for Loop and Clean tasks. Rename Delivery::Implementation Also modifies ChargeBattery requests to return a value even if charge is already at 100%, if a robot is not currently at a charger. * Remove leading underscores from ChargeBattery::Implementation * Removed commented code from Adapter.cpp * Powersystem does not require string name * Added documentation for MechanicalSystem * Removed BatteryProfile. Switched to make() pattern in rmf_battery * Addressed suggestions for rmf_battery * Added account_for_batery_drain() * Added unstable API extension to RobotUpdateHandle * Log error message when battery percentage in RobotState is out of range * Removed TODO in Task and iostream header * Renamed state() to current_task_end_state() in Robotcontext * TaskManager queue.clear() is protected by mutex * Protected read instances of queue with mutex * Added warning when robot has insufficient charge to automatically retreat to charger * Removed clear_queue() and moved begin_next_task into private * Added TODO to redesign TaskManager * Bumped printouts for missing fields to ERROR and other corrections to FleetUpdateHandle * retreat_to_charger() estimates battery drain over all trajectories in the plan * Battery drain is computed over all trajectories in a generated plan * Iterate over all trajectories in plan when computing invariant battery drain * Rename inertia to moment_of_inertia * Added const type specifier and comments for test expectations in rmf_battery * Use RCLCPP_DEBUG for printing assignments and fix const correctness of current_task_end_state() * Added TODO to fix request_delivery and request_loop functions in MockAdapter * Update rmf_fleet_adapter/src/rmf_fleet_adapter/agv/FleetUpdateHandle.cpp Co-authored-by: Grey <[email protected]> * Update rmf_fleet_adapter/src/rmf_fleet_adapter/agv/FleetUpdateHandle.cpp Co-authored-by: Grey <[email protected]> * Update rmf_fleet_adapter/src/rmf_fleet_adapter/agv/FleetUpdateHandle.cpp Co-authored-by: Grey <[email protected]> * Update rmf_task/include/rmf_task/agv/TaskPlanner.hpp Co-authored-by: Grey <[email protected]> * Update rmf_task_msgs/srv/GetTask.srv Co-authored-by: Grey <[email protected]> * Update rmf_task_msgs/srv/CancelTask.srv Co-authored-by: Grey <[email protected]> * Fixed CMakeLists.txt and header guards for rmf_task * Added setters for other parameters in TaskPlanner Configuration * Removed FilterType from public API. Planner uses Hash type always. * Updated note on friction_coefficient * Added documentation for requests and fixed comments * Renamed GetTask to GetTaskList * Renamed GetTask to GetTaskList * Added set_charger_waypoint() to RobotUpdateHandle * Hashing in EstimateCache uses sum not xor * Renamed StateConfig to Constraints * Reworked PairHash * Corrected shift in PairHash * Return task_planning_constraints by const ref * Updated Changelogs * Feature/task dispatcher (#228) * prototyping a minimal dispatcher with new task_msgs * add new exec * skeleton for bidder and nomination * further complete bidder and dispatcher * create simple test exec with bidding pipeline * first version restructuring of new bidding mechanism * preliminary test run of bidder and dispatcher nodes * update codes * redesign task action interfaces and test out task action interactions * restructure rmf tasks dir and enhance task tracking on dispatcher * add simple test on bidding * refactor and define dispatchernode api * halfway game thru restructuring of code * expose dispatcher api and change action msg fields * dispatcher lib api * continuation of work on restucturing dispatcher api * update msg definitions and apis * adding srv msg, basic integration test * cleanups and further complete dispatcher node * lint, use TaskSummary as TaskStatus * minor changes based on comments * update msgs for dispatcher * Update dispatcher api * extend impl for dispatcher, and add dockerfile * sequential bidding and further refactoring, then test * latest minor fix on UB * merge with new msgs * cleanup diff * add loop type * receiving stray task summarry msg * merge with dispatcher-demo and rm charging task from cache on every reassignment * merge latest master on traffic light * refactoring actino task templates * refactor and cleanups again * remove charge battery id gen * first review cleanup iteration * more cleanups * remove template action * further refactoring * fix compilations * con't refactor * create TaskDescription.Msg in TaskProfile * append task_description and update task_id gen * reorg apis and add internal_Auctioneer * fix issue on ignoring stray taskstatus * change default eval and update cancel task impl * switch to std::optional * remove max limit terminated tasks according to submission time * refactor headers * fix bug on unusual short bid duration * loop delivery tests for dispatcher (#236) * unit tests for loop and delivery requests with task dispatcher * minor cleanup * refactor dispatch_task() method * Implementation of EstimateCache uses std::mutex object and not shared pointer * add changelog and clean printout logs Co-authored-by: Aaron Chong <[email protected]> Co-authored-by: youliang <[email protected]> Co-authored-by: Rushyendra Maganty <[email protected]> Co-authored-by: Michael X. Grey <[email protected]>
1 parent 5fc81d3 commit 8019060

File tree

129 files changed

+12423
-673
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+12423
-673
lines changed

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
ARG TAG="foxy-ros-base-focal"
2+
FROM ros:$TAG
3+
4+
ENV HOME /home/ws_rmf/
5+
6+
RUN apt-get update && apt-get install -y g++-8 \
7+
ros-foxy-rmw-cyclonedds-cpp
8+
RUN mkdir -p /home/ws_rmf
9+
10+
WORKDIR /home/ws_rmf/
11+
COPY . src
12+
RUN rosdep update
13+
RUN rosdep install --from-paths src --ignore-src --rosdistro foxy -yr
14+
15+
RUN /ros_entrypoint.sh \
16+
colcon build --cmake-args -DCMAKE_BUILD_TYPE=RELEASE && \
17+
sed -i '$isource "/home/ws_rmf/install/setup.bash"' /ros_entrypoint.sh && \
18+
rm -rf build devel src
19+
20+
# todo: should have a multistage build
21+
22+
ENTRYPOINT ["/ros_entrypoint.sh"]
23+
CMD ["bash"]

rmf_battery/CHANGELOG.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2+
Changelog for package rmf_battery
3+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
5+
1.0.0 (2021-XX-XX)
6+
------------------
7+
* Provides core `rmf_battery::agv` utilities
8+
* `BatterySystem` - Describe battery properties of the vehicle
9+
* `MechanicalSystem` - Describe mechanical properties of the vehicle
10+
* `PowerSystem` - Describe a power system on-board the vehicle
11+
* Provides `rmf_battery::agv::SimpleMotionPowerSink`
12+
* Sample implementation of `rmf_battery::MotionPowerSink`
13+
* Compute change in battery charge due to locomotion over a specified `rmf_traffic::Trajectory`
14+
* Provides `rmf_traffic::agv::SimpleDevicePowerSink`
15+
* Sample implementation of `rmf_battery::DevicePowerSink`
16+
* Compute change in battery charge due to power systems over a specified duration
17+
* Contributors: Yadunund

rmf_battery/CMakeLists.txt

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(rmf_battery)
3+
4+
# Default to C++17
5+
if(NOT CMAKE_CXX_STANDARD)
6+
set(CMAKE_CXX_STANDARD 17)
7+
endif()
8+
9+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
10+
add_compile_options(-Wall -Wextra -Wpedantic)
11+
endif()
12+
13+
if(NOT CMAKE_BUILD_TYPE)
14+
# Use the Release build type by default if the user has not specified one
15+
set(CMAKE_BUILD_TYPE Release)
16+
endif()
17+
18+
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
19+
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
20+
21+
include(GNUInstallDirs)
22+
23+
# find dependencies
24+
find_package(ament_cmake REQUIRED)
25+
find_package(rmf_utils REQUIRED)
26+
find_package(rmf_traffic REQUIRED)
27+
find_package(Eigen3 REQUIRED)
28+
29+
# ===== Battery modelling library
30+
file(GLOB_RECURSE core_lib_srcs "src/rmf_battery/*.cpp")
31+
add_library(rmf_battery SHARED
32+
${core_lib_srcs}
33+
)
34+
35+
target_link_libraries(rmf_battery
36+
PUBLIC
37+
rmf_utils::rmf_utils
38+
rmf_traffic::rmf_traffic
39+
)
40+
41+
target_include_directories(rmf_battery
42+
PUBLIC
43+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
44+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
45+
${EIGEN3_INCLUDE_DIRS}
46+
)
47+
48+
ament_export_targets(rmf_battery HAS_LIBRARY_TARGET)
49+
ament_export_dependencies(rmf_utils)
50+
51+
if(BUILD_TESTING)
52+
find_package(ament_cmake_catch2 REQUIRED)
53+
54+
file(GLOB_RECURSE unit_test_srcs "test/*.cpp")
55+
56+
ament_add_catch2(
57+
test_rmf_battery test/main.cpp ${unit_test_srcs}
58+
TIMEOUT 300)
59+
target_link_libraries(test_rmf_battery
60+
rmf_battery
61+
)
62+
63+
target_include_directories(test_rmf_battery
64+
PRIVATE
65+
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/>
66+
)
67+
68+
find_package(rmf_cmake_uncrustify REQUIRED)
69+
find_file(uncrustify_config_file NAMES "share/format/rmf_code_style.cfg")
70+
71+
rmf_uncrustify(
72+
ARGN include src test
73+
CONFIG_FILE ${uncrustify_config_file}
74+
MAX_LINE_LENGTH 80
75+
)
76+
endif()
77+
78+
install(
79+
DIRECTORY include/
80+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
81+
)
82+
83+
install(
84+
TARGETS rmf_battery
85+
EXPORT rmf_battery
86+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
87+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
88+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
89+
)
90+
91+
ament_package()
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (C) 2020 Open Source Robotics Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
#ifndef RMF_BATTERY__DEVICEPOWERSINK_HPP
19+
#define RMF_BATTERY__DEVICEPOWERSINK_HPP
20+
21+
namespace rmf_battery {
22+
23+
24+
//==============================================================================
25+
class DevicePowerSink
26+
{
27+
public:
28+
29+
/// Compute change in state-of-charge of the battery due to an onboard
30+
/// device over a time period.
31+
///
32+
/// \param[in] run_time
33+
/// The duration in seconds over which the power system drains charge from
34+
/// the battery
35+
///
36+
/// \return The charge depleted as a fraction of the total battery capacity
37+
virtual double compute_change_in_charge(
38+
const double run_time) const = 0;
39+
40+
virtual ~DevicePowerSink() = default;
41+
};
42+
43+
} // namespace rmf_battery
44+
45+
#endif // RMF_BATTERY__DEVICEPOWERSINK_HPP
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (C) 2020 Open Source Robotics Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
#ifndef RMF_BATTERY__MOTIONPOWERSINK_HPP
19+
#define RMF_BATTERY__MOTIONPOWERSINK_HPP
20+
21+
#include <rmf_traffic/Trajectory.hpp>
22+
23+
namespace rmf_battery {
24+
25+
26+
//==============================================================================
27+
class MotionPowerSink
28+
{
29+
public:
30+
31+
/// Compute change in state-of-charge of the battery due to locomotion
32+
/// of the robot along a trajectory.
33+
///
34+
/// \param[in] trajectory
35+
/// A valid rmf_traffic:::Trajectory over which the change in charge has to
36+
/// to be computed
37+
///
38+
/// \return The charge depleted as a fraction of the total battery capacity
39+
virtual double compute_change_in_charge(
40+
const rmf_traffic::Trajectory& trajectory) const = 0;
41+
42+
virtual ~MotionPowerSink() = default;
43+
};
44+
45+
} // namespace rmf_battery
46+
47+
#endif // RMF_BATTERY__MOTIONPOWERSINK_HPP
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
/*
3+
* Copyright (C) 2020 Open Source Robotics Foundation
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
#ifndef RMF_BATTERY__AGV__BATTERYSYSTEM_HPP
20+
#define RMF_BATTERY__AGV__BATTERYSYSTEM_HPP
21+
22+
#include <rmf_utils/impl_ptr.hpp>
23+
24+
#include <optional>
25+
26+
namespace rmf_battery {
27+
namespace agv {
28+
29+
class BatterySystem
30+
{
31+
public:
32+
/// Returns a BatterySystem object if valid values were supplied for the
33+
/// various fields else returns std::nullopt. Here valid implies that the
34+
/// values are greater than zero.
35+
/// \param[in] nominal_voltage
36+
/// The nominal voltage of the battery in Volts
37+
///
38+
/// \param[in] capacity
39+
/// The nominal capacity of the battery in Ampere-hours
40+
///
41+
/// \param[in] charging_current
42+
/// The rated current in Amperes for charging the battery
43+
static std::optional<BatterySystem> make(
44+
double nominal_voltage,
45+
double capacity,
46+
double charging_current);
47+
48+
/// Get the nominal voltage of this battery system
49+
double nominal_voltage() const;
50+
51+
/// Get the capacity of this battery system
52+
double capacity() const;
53+
54+
/// Get the charging current of this battery system
55+
double charging_current() const;
56+
57+
class Implementation;
58+
private:
59+
BatterySystem();
60+
rmf_utils::impl_ptr<Implementation> _pimpl;
61+
};
62+
63+
using BatterySystemPtr = std::shared_ptr<BatterySystem>;
64+
using ConstBatterySystemPtr = std::shared_ptr<const BatterySystem>;
65+
66+
} // namespace agv
67+
} // namespace rmf_battery
68+
69+
#endif // RMF_BATTERY__AGV__BATTERYSYSTEM_HPP
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (C) 2020 Open Source Robotics Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
#ifndef RMF_BATTERY__AGV__MECHANICALSYSTEM_HPP
19+
#define RMF_BATTERY__AGV__MECHANICALSYSTEM_HPP
20+
21+
#include <rmf_utils/impl_ptr.hpp>
22+
23+
#include <optional>
24+
25+
namespace rmf_battery {
26+
namespace agv {
27+
28+
class MechanicalSystem
29+
{
30+
public:
31+
32+
/// Returns a MechanicalSystem object if valid values were supplied for the
33+
/// various fields else returns std::nullopt. Here valid implies that the
34+
/// values are greater than zero.
35+
/// \param[in] mass
36+
/// The mass of the robot in Kilograms(kg)
37+
///
38+
/// \param[in] moment_of_inertia
39+
/// The moment of inertia of the robot along its yaw axis in kg.m^2
40+
///
41+
/// \param[in] friction_coefficient
42+
/// The coefficient of kinetic friction or rolling resistance coefficient
43+
/// measured at the wheels of the robot. This value is used to compute the
44+
/// energy loss due to rotation of the vehicle's wheels during locomotion.
45+
/// This value is the dimensionless constant Crr as described in the
46+
/// reference below.
47+
/// Ref: https://en.wikipedia.org/wiki/Rolling_resistance#Rolling_resistance_coefficient
48+
static std::optional<MechanicalSystem> make(
49+
double mass,
50+
double moment_of_inertia,
51+
double friction_coefficient);
52+
53+
/// Get the mass of this mechanical system
54+
double mass() const;
55+
56+
/// Get the moment of inertia of this mechanical system
57+
double moment_of_inertia() const;
58+
59+
/// Get the friction coefficient of this mechanical system
60+
double friction_coefficient() const;
61+
62+
class Implementation;
63+
private:
64+
MechanicalSystem();
65+
rmf_utils::impl_ptr<Implementation> _pimpl;
66+
};
67+
68+
using MechanicalSystemPtr = std::shared_ptr<MechanicalSystem>;
69+
using ConstMechanicalSystemPtr = std::shared_ptr<const MechanicalSystem>;
70+
71+
} // namespace agv
72+
} // namespace rmf_battery
73+
74+
#endif // RMF_BATTERY__AGV__MECHANICALSYSTEM_HPP

0 commit comments

Comments
 (0)