-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support apis for task dispatcher (#10)
* support apis for task dispatcher * append rmf_adapter.battery * fix def_property for battery * add dispatcher node to expand test scrips * create a simple example for dispatcher node * make loop and delivery test scripts work, compatible to task dispatcher * fix test_adpater link in setup.py * fix link on examples, update bindings according to feedbacks * update rmf_battery bindings * restructure pkg and clean setup.py * fix typo * update graph wp bind: is charger
- Loading branch information
1 parent
c5488e7
commit 5f16e0e
Showing
15 changed files
with
620 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Copyright 2021 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import time | ||
import rmf_adapter as adpt | ||
import rmf_adapter.type as Type | ||
import rmf_adapter.nodes as Nodes | ||
|
||
from threading import Thread | ||
|
||
|
||
def submit_task_thread(mod): | ||
time.sleep(2) | ||
task_desc = Type.CPPTaskDescriptionMsg() | ||
task_desc.delivery = adpt.type.CPPDeliveryMsg() | ||
print("Sumbiting 2 sample delivery tasks") | ||
id1 = mod.submit_task(task_desc) | ||
id2 = mod.submit_task(task_desc) | ||
print(f" active list >> {mod.get_active_task_ids()}") | ||
|
||
time.sleep(3) | ||
print("---- Assertion ----") | ||
state1 = mod.get_task_state(id1) | ||
state2 = mod.get_task_state(id2) | ||
state3 = mod.get_task_state("null_id") | ||
print(f" {id1}: {state1} \n {id2}: {state2} \n null_id: {state3}") | ||
|
||
assert state1 == Nodes.TaskState.Failed, "Fail due to absence of a bid" | ||
assert state2 == Nodes.TaskState.Pending, "state should be pending" | ||
assert state3 == None, "state should be none" | ||
assert mod.cancel_task(id2), "failed to cancel task" | ||
|
||
# check if task is canceled | ||
state2 = mod.get_task_state(id2) | ||
print(f" Canceled:: {id2}: {state2} \n") | ||
assert state2 == Nodes.TaskState.Canceled, "task should be canceled" | ||
print("Done Check") | ||
|
||
|
||
def main(): | ||
print("Starting Simple Dispatcher Node") | ||
adpt.init_rclcpp() | ||
dispatcher = Nodes.DispatcherNode.make_node("sample_dispatcher_node") | ||
|
||
th1 = Thread(target=submit_task_thread, args=(dispatcher,)) | ||
th1.start() | ||
|
||
while True: | ||
adpt.spin_some_rclcpp(dispatcher.node()) | ||
time.sleep(0.2) | ||
|
||
print("Exiting") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.