diff --git a/docs/static/tutorial6/configure-icon.png b/docs/static/tutorial6/configure-icon.png new file mode 100644 index 00000000..52a9e2e8 Binary files /dev/null and b/docs/static/tutorial6/configure-icon.png differ diff --git a/docs/static/tutorial6/create-nodes.png b/docs/static/tutorial6/create-nodes.png new file mode 100644 index 00000000..38257e24 Binary files /dev/null and b/docs/static/tutorial6/create-nodes.png differ diff --git a/docs/static/tutorial6/hidden-nodes.png b/docs/static/tutorial6/hidden-nodes.png new file mode 100644 index 00000000..604829dd Binary files /dev/null and b/docs/static/tutorial6/hidden-nodes.png differ diff --git a/docs/static/tutorial6/linked-nodes.png b/docs/static/tutorial6/linked-nodes.png new file mode 100644 index 00000000..8e75007e Binary files /dev/null and b/docs/static/tutorial6/linked-nodes.png differ diff --git a/docs/static/tutorial6/only-node1-moving.png b/docs/static/tutorial6/only-node1-moving.png new file mode 100644 index 00000000..01ac2ebd Binary files /dev/null and b/docs/static/tutorial6/only-node1-moving.png differ diff --git a/docs/static/tutorial6/scenario-with-motion.png b/docs/static/tutorial6/scenario-with-motion.png new file mode 100644 index 00000000..e30e781c Binary files /dev/null and b/docs/static/tutorial6/scenario-with-motion.png differ diff --git a/docs/static/tutorial6/scenario-with-terrain.png b/docs/static/tutorial6/scenario-with-terrain.png new file mode 100644 index 00000000..db424e9b Binary files /dev/null and b/docs/static/tutorial6/scenario-with-terrain.png differ diff --git a/docs/static/tutorial6/select-wallpaper.png b/docs/static/tutorial6/select-wallpaper.png new file mode 100644 index 00000000..41d40f57 Binary files /dev/null and b/docs/static/tutorial6/select-wallpaper.png differ diff --git a/docs/static/tutorial6/wlan-links.png b/docs/static/tutorial6/wlan-links.png new file mode 100644 index 00000000..ab6c152d Binary files /dev/null and b/docs/static/tutorial6/wlan-links.png differ diff --git a/docs/tutorials/overview.md b/docs/tutorials/overview.md new file mode 100644 index 00000000..733157bd --- /dev/null +++ b/docs/tutorials/overview.md @@ -0,0 +1,29 @@ +# CORE Tutorials + +These tutorials will cover various use cases within CORE. These +tutorials will provide example python, gRPC, XML, and related files, as well +as an explanation for their usage and purpose. + +## Checklist + +These are the items you should become familiar with for running all the tutorials below. + +* [Install CORE](../install.md) +* [Tutorial Setup](setup.md) + +## Tutorials + +* [Tutorial 1 - Wired Network](tutorial1.md) + * Covers interactions when using a simple 2 node wired network +* [Tutorial 2 - Wireless Network](tutorial2.md) + * Covers interactions when using a simple 3 node wireless network +* [Tutorial 3 - Basic Mobility](tutorial3.md) + * Covers mobility interactions when using a simple 3 node wireless network +* [Tutorial 4 - Tests](tutorial4.md) + * Covers automating scenarios as tests to validate software +* [Tutorial 5 - Access Windows](tutorial5.md) + * Covers using the RJ45 node to connect a Windows OS +* [Tutorial 6 - Improve Visuals](tutorial6.md) + * Covers changing the look of a scenario within the CORE GUI +* [Tutorial 7 - EMANE](tutorial7.md) + * Covers using EMANE within CORE for higher fidelity RF networks diff --git a/docs/tutorials/tutorial6.md b/docs/tutorials/tutorial6.md new file mode 100644 index 00000000..6135d21e --- /dev/null +++ b/docs/tutorials/tutorial6.md @@ -0,0 +1,97 @@ +# Tutorial 6 - Improved Visuals + +## Overview + +This tutorial will cover changing the node icons, changing the background, and changing or hiding links. + +## Files + +Below is the list of files used for this tutorial. + +* drone.png - icon for a drone +* demo.py - a mobility script for a node +* terrain.png - a background +* completed-scenario.xml - the scenario after making all changes below + +## Running this Tutorial + +This section will cover running this sample tutorial that develops a scenario file. + +* Ensure that **/etc/core/core.conf** has **grpcaddress** set to **0.0.0.0** +* Make sure the **core-daemon** is running in a terminal + ```shell + sudop core-daemon + ``` +* In another terminal run the GUI + ```shell + core-gui + ``` + +### Changing Node Icons + +* Create three MDR nodes +

+ +

+* Double click on each node for configuration, click the icon and set it to use the **drone.png** image +

+ +

+* Use **Session -> Options** and set **Control Network 0** to **172.16.0.0./24** + +### Linking Nodes to WLAN + +* Add a WLAN Node +* Link the three prior MDR nodes to the WLAN node +

+ +

+* Click play to start the scenario +* Observe wireless links being created +

+ +

+* Click stop to end the scenario +* Right click the WLAN node and select **Edit -> Hide** +* Now you can view the nodes in isolation +

+ +

+ +### Changing Canvas Background + +* Click **Canvas -> Wallpaper** to set the background to terrain.png +

+ +

+* Click play to start the scenario again +* You now have a scenario with drone icons, terrain background, links displayed and hidden WLAN node +

+ +

+ +## Adding Mobility + +* Open and play the **completed-scenario.xml** +* Double click on **n1** and run the **demo.py** script + ```shell + # node id is first parameter, second is total nodes + /opt/core/venv/bin/python demo.py 1 3 + ``` +* Let it run to see the link break as the node 1 drone approches the right side +

+ +

+* Repeat for other nodes, double click on **n2** and **n3** and run the demo.py script + ```shell + # n2 + /opt/core/venv/bin/python demo.py 2 3 + # n3 + /opt/core/venv/bin/python demo.py 3 3 + ``` +* You can turn off wireless links via **View -> Wireless Links** +* Observe nodes moving in parallel tracks, when the far right is reached, the node will move down + and then move to the left. When the far left is reached, the drone will move down and then move to the right. +

+ +

diff --git a/mkdocs.yml b/mkdocs.yml index 4879e09e..b71a89bb 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -39,9 +39,11 @@ nav: - Ubuntu: install_ubuntu.md - CentOS: install_centos.md - Tutorials: + - Overview: tutorials/overview.md - Setup: tutorials/setup.md - Tutorial 1: tutorials/tutorial1.md - Tutorial 4: tutorials/tutorial4.md + - Tutorial 6: tutorials/tutorial6.md - Tutorial 7: tutorials/tutorial7.md - Detailed Topics: - GUI: gui.md diff --git a/package/examples/tutorials/tutorial6/completed-scenario.xml b/package/examples/tutorials/tutorial6/completed-scenario.xml new file mode 100644 index 00000000..2b985727 --- /dev/null +++ b/package/examples/tutorials/tutorial6/completed-scenario.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/package/examples/tutorials/tutorial6/demo.py b/package/examples/tutorials/tutorial6/demo.py new file mode 100644 index 00000000..3acca8c6 --- /dev/null +++ b/package/examples/tutorials/tutorial6/demo.py @@ -0,0 +1,103 @@ +import sys +import time + +from core.api.grpc import client +from core.api.grpc.wrappers import Position + + +# start_row can be used to share a search +def find_next_position(arr, start_row): + # find next position with value of 0 for 'not visited' + min_rows, min_cols = (25, 25) + rows, cols = (470, 900) + if start_row < min_rows: + start_row = min_rows + for y in range(start_row, rows): + for x in range(min_cols, cols): + if (y % 2) == 0: + print(f"search_x={x}") + print(f"search_y={y}") + val = arr[x][y] + if (val == 0) or (val == 100): + return x,y + else: + search_x = cols - (x - min_cols + 1) + print(f"search_x={search_x}") + print(f"search_y={y}") + val = arr[search_x][y] + if val == 0: + return search_x,y + + +def move(current_x, current_y, to_x, to_y): + # move 1 pixel + speed = 1 + if to_x > current_x: + move_x = current_x + speed + elif to_x < current_x: + move_x = current_x - speed + else: + move_x = current_x + if to_y > current_y: + move_y = current_y + speed + elif to_y < current_y: + move_y = current_y - speed + else: + move_y = current_y + return move_x, move_y + + +def main(): + n = len(sys.argv) + if (n < 3): + print("Usage: core-python demo.py ") + exit() + + # number of search nodes + num_search_nodes = int(sys.argv[2]) + + # create grpc client and connect + core = client.CoreGrpcClient("172.16.0.254:50051") + core.connect() + + # get session + sessions = core.get_sessions() + rows_per_zone = (499 - 25) / num_search_nodes + node_number = int(sys.argv[1]) + y_start = (node_number - 1) * int(rows_per_zone) + current_x = 25 + current_y = y_start + + # max x and y + rows, cols = (470, 900) + arr = [[0 for i in range(rows)] for j in range(cols)] + print(arr, "before") + + # place target + # update one element as target + arr[200][165] = 100 + print(arr, "after") + + while True: + val = arr[current_x][current_y] + # if position has target, stop + if val == 100: + print(f"found target, position={position}") + else: + #update one element for this starting position + arr[current_x][current_y] = 1 + # move + to_x, to_y = find_next_position(arr, y_start) + print(f"next x={to_x}, next y={to_y}") + x, y = move(current_x, current_y, to_x, to_y) + # command the move + position = Position(x , y) + print(f"move to position {position}") + core.move_node(sessions[0].id, node_number, position=position) + current_x = x + current_y = y + time.sleep(.25) + + +if __name__ == "__main__": + main() diff --git a/package/examples/tutorials/tutorial6/drone.png b/package/examples/tutorials/tutorial6/drone.png new file mode 100644 index 00000000..61350373 Binary files /dev/null and b/package/examples/tutorials/tutorial6/drone.png differ diff --git a/package/examples/tutorials/tutorial6/terrain.png b/package/examples/tutorials/tutorial6/terrain.png new file mode 100644 index 00000000..cd06728b Binary files /dev/null and b/package/examples/tutorials/tutorial6/terrain.png differ