Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Oct 28, 2023
2 parents c50c1bf + 8ef3466 commit 984eb51
Show file tree
Hide file tree
Showing 14 changed files with 191 additions and 0 deletions.
14 changes: 14 additions & 0 deletions subprojects/robotpy-halsim-ws/.github/workflows/dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: dist

on:
pull_request:
push:
tags:
- '*'

jobs:
ci:
uses: robotpy/build-actions/.github/workflows/package-hal-extension.yml@v2024
secrets:
META_REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
25 changes: 25 additions & 0 deletions subprojects/robotpy-halsim-ws/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

*.pyc
*.egg-info

*.dll
*.so
*.dylib

.vscode

/build
/dist
*.egg-info

/halsim_ws/version.py

/halsim_ws/server/_init_server.py
/halsim_ws/server/pkgcfg.py
/halsim_ws/server/include
/halsim_ws/server/lib

/halsim_ws/client/_init_client.py
/halsim_ws/client/pkgcfg.py
/halsim_ws/client/include
/halsim_ws/client/lib
19 changes: 19 additions & 0 deletions subprojects/robotpy-halsim-ws/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
robotpy-halsim-ws
==================

Installing this package will allow you to utilize the 2020+ WPILib websim from a RobotPy program.

Usage
-----

First, install pyfrc. Then run your robot with the 'sim' argument and --ws-server or --ws-client flag:

# Windows
py -3 ./robot.py sim --ws-server
py -3 ./robot.py sim --ws-client

# Linux/OSX
python3 robot.py sim --ws-server
python3 robot.py sim --ws-client

WPILib's documentation for using the simulator can be found at http://docs.wpilib.org/en/latest/docs/software/wpilib-tools/robot-simulation/
Empty file.
1 change: 1 addition & 0 deletions subprojects/robotpy-halsim-ws/halsim_ws/client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .main import loadExtension
23 changes: 23 additions & 0 deletions subprojects/robotpy-halsim-ws/halsim_ws/client/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import logging
import os
from os.path import abspath, dirname, join

logger = logging.getLogger("halsim_ws.client")


def loadExtension():
try:
import hal
except ImportError as e:
# really, should never happen...
raise ImportError("you must install robotpy-hal!") from e

from ..version import version

logger.info("WPILib HAL Simulation websim client %s", version)

root = join(abspath(dirname(__file__)), "lib")
ext = join(root, os.listdir(root)[0])
retval = hal.loadOneExtension(ext)
if retval != 0:
logger.warn("loading extension may have failed (error=%d)", retval)
1 change: 1 addition & 0 deletions subprojects/robotpy-halsim-ws/halsim_ws/server/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .main import loadExtension
23 changes: 23 additions & 0 deletions subprojects/robotpy-halsim-ws/halsim_ws/server/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import logging
import os
from os.path import abspath, dirname, join

logger = logging.getLogger("halsim_ws.server")


def loadExtension():
try:
import hal
except ImportError as e:
# really, should never happen...
raise ImportError("you must install robotpy-hal!") from e

from ..version import version

logger.info("WPILib HAL Simulation websim server %s", version)

root = join(abspath(dirname(__file__)), "lib")
ext = join(root, os.listdir(root)[0])
retval = hal.loadOneExtension(ext)
if retval != 0:
logger.warn("loading extension may have failed (error=%d)", retval)
55 changes: 55 additions & 0 deletions subprojects/robotpy-halsim-ws/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[tool.robotpy-build.metadata]
name = "robotpy-halsim-ws"
description = "WPILib simulator websim Extensions"
author = "RobotPy Development Team"
author_email = "robotpy@googlegroups.com"
url = "https://github.com/robotpy/robotpy-halsim-gui"
license = "BSD-3-Clause"
install_requires = [
"robotpy-hal~=2024.0.0b2",
"robotpy-wpinet~=2024.0.0b2",
]

[tool.robotpy-build.metadata.entry_points]
robotpysimext = [
"ws-server = halsim_ws.server",
"ws-client = halsim_ws.client",
]


[build-system]
requires = [
"robotpy-build<2025.0.0,~=2024.0.0b1",
"robotpy-hal~=2024.0.0b2",
"robotpy-wpinet~=2024.0.0b2",
]

[tool.robotpy-build]
base_package = "halsim_ws"

[tool.robotpy-build.wrappers."halsim_ws.server".maven_lib_download]
artifact_id = "halsim_ws_server"
group_id = "edu.wpi.first.halsim"
# repo_url = "https://frcmaven.wpi.edu/artifactory/release"
repo_url = "https://frcmaven.wpi.edu/artifactory/release"
version = "2024.1.1-beta-2"

dlopenlibs = ["halsim_ws_server"]

[tool.robotpy-build.wrappers."halsim_ws.server"]
name = "server"
depends = ["wpiHal", "wpinet"]

[tool.robotpy-build.wrappers."halsim_ws.client".maven_lib_download]
artifact_id = "halsim_ws_client"
group_id = "edu.wpi.first.halsim"
# repo_url = "https://frcmaven.wpi.edu/artifactory/release"
repo_url = "https://frcmaven.wpi.edu/artifactory/release"
version = "2024.1.1-beta-2"

dlopenlibs = ["halsim_ws_client"]

[tool.robotpy-build.wrappers."halsim_ws.client"]
name = "client"
depends = ["wpiHal", "wpinet", "wpiutil"]

5 changes: 5 additions & 0 deletions subprojects/robotpy-halsim-ws/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env python3

from robotpy_build.setup import setup

setup()
1 change: 1 addition & 0 deletions subprojects/robotpy-halsim-ws/tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest
12 changes: 12 additions & 0 deletions subprojects/robotpy-halsim-ws/tests/run_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python3

import os
from os.path import abspath, dirname
import sys
import subprocess

if __name__ == "__main__":
root = abspath(dirname(__file__))
os.chdir(root)

subprocess.check_call([sys.executable, "-m", "pytest"])
6 changes: 6 additions & 0 deletions subprojects/robotpy-halsim-ws/tests/test_halsim_ws_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# tests the internals
import halsim_ws.client._init_client


def test_halsim_ws_client():
pass
6 changes: 6 additions & 0 deletions subprojects/robotpy-halsim-ws/tests/test_halsim_ws_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# tests the internals
import halsim_ws.server._init_server


def test_halsim_ws_server():
pass

0 comments on commit 984eb51

Please sign in to comment.