Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial UI #37

Merged
merged 46 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
d637ed0
Initial JavaScript testing
chachmu Aug 28, 2021
0b25bf0
Add custom git ignore for the UI file
chachmu Sep 30, 2021
600455e
Remove faulty python script
chachmu Sep 30, 2021
3e7a3cf
Functioning helloworld using neutralino, Vue, and Vite
chachmu Sep 30, 2021
5006527
Add readme file
chachmu Sep 30, 2021
54345fa
modify yarn.lock
chachmu Sep 30, 2021
c9e8606
Vuetify installed but havent fully figured out how to use it
chachmu Sep 30, 2021
39b1854
functioning test ui with konva, shapes not reacting to change in state
chachmu Oct 2, 2021
9f9d718
Working reactive konva, adding field markings
chachmu Oct 3, 2021
a78cc3c
Fully functioning ui test
chachmu Oct 3, 2021
d86a616
Windows compatibility is dumb
chachmu Oct 3, 2021
68c9766
Fix performance issue with moving the ball
chachmu Oct 3, 2021
f42de36
Simplify robot drawing method
chachmu Oct 4, 2021
2db2f5c
just dont update state while dragging objects
chachmu Oct 5, 2021
424f92f
Add basic robot status window
chachmu Dec 1, 2021
71c4e0e
Testing build system
chachmu Dec 1, 2021
2edfc0f
Merge branch 'main' into dev/chachmu/ui
chachmu Dec 1, 2021
3d5f7e1
Add ROS subscriber logic and a debug launch file
chachmu Dec 1, 2021
b3cf9ea
Add npm dependency installation to cmake and move UI build process to…
chachmu Dec 29, 2021
e78faf1
Add npm as dependency
chachmu Dec 29, 2021
7b26452
Nonfunctional test
chachmu Jan 5, 2022
1be1cbc
Test runs but UI node isn't appearing
chachmu Jan 8, 2022
3035fa8
Working test
chachmu Jan 10, 2022
5482308
Finally working CMake
chachmu Jan 24, 2022
0b02df3
Fully working CMake, switch to .py launch files, colcon test properly
chachmu Jan 25, 2022
2a742d0
Increase test timeout
chachmu Jan 25, 2022
6f62998
Increase setup time for UI
chachmu Jan 25, 2022
64c8c4f
Update readme now that cmake and dependencies are correct
chachmu Jan 25, 2022
77b2c9e
Fix cmake again? Also add --quiet and -host
chachmu Jan 26, 2022
83ff67c
Slience excessive CMake output
chachmu Feb 2, 2022
7332d91
Fix issue with CopySrc copying IDE autosave files
chachmu Feb 3, 2022
69441a2
Add overlays and prevent dragging robots/balls out of field
chachmu Feb 6, 2022
f8c7540
Merge remote-tracking branch 'origin/main' into dev/chachmu/ui
chachmu Feb 6, 2022
509c66b
Add keys to v-fors
chachmu Feb 7, 2022
8fdf34a
Splits JS dep install / build steps into their own scripts.
barulicm Feb 13, 2022
2d91f68
Remove todo comment.
barulicm Feb 13, 2022
5f2c1fb
Fixes typo'd path in readme.
barulicm Feb 19, 2022
8e1af3d
Adds UI dependency installation to CI steps.
barulicm Feb 19, 2022
91b7340
Fixes ui dependency install paths. For real this time?
barulicm Feb 19, 2022
c53e2ff
Fixes bad if statement in ui deps install script.
barulicm Feb 19, 2022
d226aba
Moves wget to be a rosdep dependency, instead of manually installed i…
barulicm Feb 19, 2022
20a21b1
Adds libwebkit2gtk to UI deps install script, since it's missing in CI.
barulicm Feb 19, 2022
9dd3273
Adds missing '-y' flag to apt install in script.
barulicm Feb 19, 2022
f5ece60
Reverts addition of libwebkit2gtk and adds skip flag for ateam_ui tes…
barulicm Feb 19, 2022
21bf980
Merge pull request #50 from SSL-A-Team/dev/barulicm/ui_build
chachmu Feb 19, 2022
24600b6
Fix mesh1d issue
chachmu Feb 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
path: src/stsl
path: src/ateam_software
- name: Install Dependencies
shell: bash
run: |
source /opt/ros/galactic/setup.bash
sudo apt-get update
sudo apt install wget -y
rosdep update --rosdistro=galactic
rosdep install --from-paths . --ignore-src -y
./src/ateam_software/ateam_ui/install_deps.sh
- name: Build
shell: bash
run: |
Expand All @@ -30,5 +30,5 @@ jobs:
shell: bash
run: |
source /opt/ros/galactic/setup.bash
colcon test
colcon test --packages-skip ateam_ui
colcon test-result --verbose
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
rosdep install --from-paths . --ignore-src -y
```

1. Install our non-ROS dependencies

```bash
# In the ateam_ws directory
source /opt/ros/galactic/setup.bash
./src/software/ateam_ui/install_deps.sh
```

1. Build the code

```bash
Expand Down
2 changes: 2 additions & 0 deletions ateam_msgs/CMakeLists.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ rosidl_generate_interfaces(${PROJECT_NAME}
msg/BallState.msg
msg/RobotMotionCommand.msg
msg/RobotState.msg
msg/Mesh1d.msg
msg/Overlay.msg
msg/TeamClientConnectionStatus.msg

srv/ReconnectTeamClient.srv
Expand Down
2 changes: 2 additions & 0 deletions ateam_msgs/msg/Mesh1d.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Helper message for generating 2d array to be used with mesh overlays
float32[] mesh1d
57 changes: 57 additions & 0 deletions ateam_msgs/msg/Overlay.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# All units in meters

# Type of overlay
uint8 POINT=0
uint8 LINE=1
uint8 RECTANGLE=2
uint8 ELLIPSE=3
uint8 POLYGON=4
uint8 TEXT=5
uint8 MESH=6
uint8 CUSTOM=7

# Type of Command
uint8 REPLACE=0 # Replaces overlay with matching name or creates it if none exist
uint8 EDIT=1 # Edits the overlay with matching name
uint8 REMOVE=2 # Removes the overlay with matching name

# Namespace for the overlay, preferably sending node's name prepended with its namespace to help prevent collisions
string ns

# All overlays are named so we can keep track of them
string name

# Determines if the overlay is visible in the ui
bool visible

# Specifies the type of overlay to use
uint8 type

# Specifies the command to be used
uint8 command

# Center position specified as (X, Y, rotation around center in degrees)
geometry_msgs/Point position

# Scale specified as (Width, Height, _)
geometry_msgs/Point scale

# Colors are specified using "#RRGGBBAA" hexadecimal RGBA format. The # is required
string stroke_color
string fill_color

# Also used as font size when using the TEXT type
uint8 stroke_width 1

# lifetime of overlay in milliseconds, 0 for infinite
uint32 lifetime 0

# List of points for the LINE and POLYGON types (relative to the center position point)
geometry_msgs/Point[] points

# when using the MESH type specify the boundaries of the mesh as a rectangle using the position and scale values
ateam_msgs/Mesh1d[] mesh
ateam_msgs/Mesh1d[] mesh_alpha

# When using the TEXT type place the text here, when using the CUSTOM type put arbitrary javascript in this variable
string text
25 changes: 25 additions & 0 deletions ateam_ui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.5)
project(ateam_ui)

find_package(ament_cmake REQUIRED)
find_package(rosbridge_server REQUIRED)

add_custom_target(build_js ALL
COMMAND bash ${CMAKE_SOURCE_DIR}/build.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)

install(DIRECTORY
launch
src
DESTINATION share/${PROJECT_NAME}
USE_SOURCE_PERMISSIONS
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
add_subdirectory(test)
endif()

ament_package()
50 changes: 50 additions & 0 deletions ateam_ui/CopySrc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Get recursive list of files in ./src
# Copyright 2021 A Team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.


file(GLOB_RECURSE src_files
LIST_RECURSE true
RELATIVE ${SOURCE_DIR}/src
${SOURCE_DIR}/src/*
)

# Filter out autosave files (files starting with .# or #)
list(FILTER src_files EXCLUDE REGEX "(([.][#])|(#))[^\n]*")

# Add file_list to ./src files
list(APPEND src_files file_list)

# Copy ./src to install directory
foreach(src_file ${src_files})
if(${src_file} STREQUAL file_list)
configure_file(
${BINARY_DIR}/file_list
${INSTALL_PREFIX}/share/${PROJECT_NAME}/src/${src_file}
COPYONLY
)
else()
configure_file(
${SOURCE_DIR}/src/${src_file}
${INSTALL_PREFIX}/share/${PROJECT_NAME}/src/${src_file}
COPYONLY
)
endif()
endforeach()
8 changes: 8 additions & 0 deletions ateam_ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Setting up dependencies
The UI is currently designed to use [Vue](https://vuejs.org/) as a framework to develop the actual framework to lay everything out. Then, [Vite](https://vitejs.dev/) is used to compile everything into efficient contained code. Finally, everything is put into an executable using [nuetralino](https://neutralino.js.org/).

Running the usual `rosdep install` followed by `colcon build` should properly install all dependencies and build the UI.

# Launch files
The `ateam_ui_launch.py` file launches both [rosbridge](https://github.com/RobotWebTools/rosbridge_suite) and the ui.
The `ateam_ui_debug_launch.py` launches rosbridge and runs the ui in development mode where it can be viewed in a web browser.
20 changes: 20 additions & 0 deletions ateam_ui/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#! /bin/bash

set -e

pushd src > /dev/null

# Build the UI
echo "Building"
yarn vite build
neu build --release

# Fix potential permissions issue
if [ ! -x ./dist/Ateam_UI/neutralino-linux_x64 ]; then
echo "Fixing executable permissions"
chmod +x ./dist/Ateam_UI/*
fi

popd > /dev/null

echo "UI Build Complete!"
43 changes: 43 additions & 0 deletions ateam_ui/install_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#! /bin/bash

# This script installs javascript dependencies which can't be handled via
# rosdep. It requires internet access. It must be run within the same colcon
# workspace as the ateam_ui package.

set -e

install_npm_package_if_missing () {
local package_name=$1
echo "Checking for npm package: $package_name"
if npm list --depth 1 --global $package_name > /dev/null 2>&1; then
echo "$package_name already installed"
else
echo "Installing $package_name"
sudo npm install -g $package_name &> /dev/null
fi
}

install_npm_package_if_missing n
echo "Upgrading node to latest stable"
sudo n stable &> /dev/null

install_npm_package_if_missing yarn

install_npm_package_if_missing @neutralinojs/neu

# Assumes the script runs somewhere inside the colcon workspace
ateam_ui_pkg_path=$(colcon --log-base /dev/null list --packages-select ateam_ui -p)

pushd $ateam_ui_pkg_path/src &> /dev/null

echo "Installing UI yarn dependencies"
yarn install

if [ ! -d ./bin ]; then
echo "Configuring neu"
neu update
fi

popd &> /dev/null

echo "UI dependencies installed!"
55 changes: 55 additions & 0 deletions ateam_ui/launch/ateam_ui_debug_launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2021 A Team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import launch
import launch_ros.actions
import os
from ament_index_python.packages import get_package_share_directory


def generate_launch_description():
ateam_ui_src = os.path.join(get_package_share_directory("ateam_ui"), "src")
ui_process = launch.actions.ExecuteProcess(
cmd=["yarn", "dev"],
cwd=ateam_ui_src,
output="screen"
)

rosbridge_node = launch_ros.actions.Node(
package="rosbridge_server",
namespace="ui",
name="rosbridge",
executable="rosbridge_websocket.py"
)

shutdown_handler = launch.actions.RegisterEventHandler(
launch.event_handlers.OnProcessExit(
target_action=ui_process,
on_exit=[launch.actions.EmitEvent(
event=launch.events.Shutdown(reason="Window Closed")
)]
)
)

return launch.LaunchDescription([
ui_process,
rosbridge_node,
shutdown_handler
])
55 changes: 55 additions & 0 deletions ateam_ui/launch/ateam_ui_launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2021 A Team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import launch
import launch_ros.actions
import os
from ament_index_python.packages import get_package_share_directory


def generate_launch_description():
ateam_ui_src = os.path.join(get_package_share_directory("ateam_ui"), "src")
ui_process = launch.actions.ExecuteProcess(
cmd=["neu", "run"],
cwd=ateam_ui_src,
output="screen"
)

rosbridge_node = launch_ros.actions.Node(
package="rosbridge_server",
namespace="ui",
name="rosbridge",
executable="rosbridge_websocket.py"
)

shutdown_handler = launch.actions.RegisterEventHandler(
launch.event_handlers.OnProcessExit(
target_action=ui_process,
on_exit=[launch.actions.EmitEvent(
event=launch.events.Shutdown(reason="Window Closed")
)]
)
)

return launch.LaunchDescription([
ui_process,
rosbridge_node,
shutdown_handler
])
Loading