mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
[copybara] mostrobotpy to allwpilib (#8545)
Project import generated by Copybara. GitOrigin-RevId: f10284b37498bb6a088891ca41f160793ec7fd90
This commit is contained in:
18
simulation/halsim_ds_socket/src/main/python/README.md
Normal file
18
simulation/halsim_ds_socket/src/main/python/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
robotpy-halsim-ds-socket
|
||||
==================
|
||||
|
||||
Installing this package will allow you to utilize the 2020+ WPILib GUI
|
||||
DS Socket from a RobotPy program.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
First, install pyfrc. Then run your robot with the 'sim' argument and --ds-socket flag:
|
||||
|
||||
# Windows
|
||||
py -3 -m robotpy sim --ds-socket
|
||||
|
||||
# Linux/OSX
|
||||
python3 -m robotpy sim --ds-socket
|
||||
|
||||
WPILib's documentation for using the simulator can be found at http://docs.wpilib.org/en/latest/docs/software/wpilib-tools/robot-simulation/
|
||||
@@ -0,0 +1 @@
|
||||
from .main import loadExtension
|
||||
@@ -0,0 +1,23 @@
|
||||
import logging
|
||||
import os
|
||||
from os.path import abspath, dirname, join
|
||||
|
||||
logger = logging.getLogger("halsim_ds_socket")
|
||||
|
||||
|
||||
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 DS Socket Extension %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)
|
||||
40
simulation/halsim_ds_socket/src/main/python/pyproject.toml
Normal file
40
simulation/halsim_ds_socket/src/main/python/pyproject.toml
Normal file
@@ -0,0 +1,40 @@
|
||||
[build-system]
|
||||
build-backend = "hatchling.build"
|
||||
requires = [
|
||||
"hatchling",
|
||||
"hatch-robotpy~=0.2.1",
|
||||
]
|
||||
|
||||
[project]
|
||||
name = "robotpy-halsim-ds-socket"
|
||||
version = "0.0.0"
|
||||
description = "WPILib simulator DS Socket Extension"
|
||||
authors = [
|
||||
{name = "RobotPy Development Team", email = "robotpy@googlegroups.com"},
|
||||
]
|
||||
license = "BSD-3-Clause"
|
||||
dependencies = [
|
||||
"robotpy-native-wpihal==0.0.0",
|
||||
"robotpy-native-wpinet==0.0.0",
|
||||
]
|
||||
|
||||
[project.entry-points."robotpy_sim.2027"]
|
||||
ds-socket = "halsim_ds_socket"
|
||||
|
||||
|
||||
[tool.hatch.build.hooks.robotpy]
|
||||
version_file = "halsim_ds_socket/version.py"
|
||||
|
||||
[[tool.hatch.build.hooks.robotpy.maven_lib_download]]
|
||||
artifact_id = "halsim_ds_socket"
|
||||
group_id = "org.wpilib.halsim"
|
||||
repo_url = ""
|
||||
version = "0.0.0"
|
||||
use_headers = false
|
||||
|
||||
extract_to = "halsim_ds_socket"
|
||||
libs = ["halsim_ds_socket"]
|
||||
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["halsim_ds_socket"]
|
||||
@@ -0,0 +1,18 @@
|
||||
import ctypes
|
||||
import pathlib
|
||||
|
||||
|
||||
def test_halsim_ds_socket():
|
||||
# dependencies
|
||||
import native.wpihal._init_robotpy_native_wpihal
|
||||
import native.wpinet._init_robotpy_native_wpinet
|
||||
|
||||
import halsim_ds_socket as base
|
||||
|
||||
loaded = 0
|
||||
for fname in (pathlib.Path(base.__file__).parent / "lib").iterdir():
|
||||
if fname.is_file() and fname.suffix in (".dll", ".dylib", ".so"):
|
||||
ctypes.CDLL(str(fname))
|
||||
loaded += 1
|
||||
|
||||
assert loaded
|
||||
Reference in New Issue
Block a user