Skip to content

Commit

Permalink
Uploaded more code
Browse files Browse the repository at this point in the history
  • Loading branch information
AtomicGamer9523 committed Dec 22, 2023
1 parent 5ac566f commit eafa630
Show file tree
Hide file tree
Showing 219 changed files with 1,132 additions and 196 deletions.
23 changes: 11 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,23 @@ members = [
# Python interface implementation
"arc",
# ARC client (used to control the robot)
"libs/client",
"client",
# Code uploader (used to upload code to the robot)
"libs/uploader",
# Robot [Server] side of the robot (rust)
"libs/robot",
"uploader",
# Robot HTTP server, used to control the robot via HTTP
"server",
# Robot runtime (used to run the robot code)
"robot",

#################################
### Helper crates ###
#################################
# Low level math functions
"libs/helper/l2math",
# "libs/libodo",
# "libs/libpath",
# "libs/libtrig",
# Core macros functions
"libs/helper/macros-core",
"helpers/l2math",
# Trigonometric abstractions
"helpers/libtrig",
# Macros used to simplify code
"libs/helper/macros",
"helpers/macros",
]

[workspace.package]
Expand Down Expand Up @@ -52,4 +51,4 @@ debug = true

# What to do when a panic occurs
panic = "unwind"
# panic = "abort"
# panic = "abort"
35 changes: 19 additions & 16 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
MIT License
BSD 2-Clause License

Copyright (c) 2023 AtomicGamer9523 <https://matveit.dev>

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:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

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.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@ ARC is a feature complete framework for writing robot code. It is designed to be
For Developers who are planning on using this [read here](./docs/GUIDE.md).

For Developers who are going to be contributing to this [read here](./docs/CONTRIBUTING.md).

<!--
Colors:
Complete Black: #000000
Black: #06070E
Gray: #2d2d2d
Blue: #00A7E1
Green: #84DD63
Red: #DF2935
Yellow: #FFA400
-->
4 changes: 2 additions & 2 deletions arc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ crate-type = ["cdylib", "rlib"]

[dependencies.arc_robot_hardware]
package = "arc-robot-hardware"
path = "../libs/robot/hardware"
path = "../robot/hardware"

[dependencies.libtrig]
package = "libtrig"
path = "../libs/helper/libtrig"
path = "../helpers/libtrig"

[dependencies.pyo3]
#!!! Important - DO NOT ENABLE extension-module FEATURE HERE!!!
Expand Down
12 changes: 11 additions & 1 deletion arc/__init__.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ pub struct OpHolder {
start_time: std::time::Instant,
}

impl Default for OpHolder {
fn default() -> Self {
Self {
running: true.into(),
gamepad: hardware::gamepad::Gamepad::default(),
start_time: std::time::Instant::now(),
}
}
}

impl OpHolder {
/// Returns whether the op mode is running
///
Expand Down Expand Up @@ -97,7 +107,7 @@ threadsafe::thread_safe!(OpHolder);
/// # }
/// ```
#[pyclass]
#[derive(Debug, Clone)]
#[derive(Default, Debug, Clone)]
pub struct Op(ThreadSafe<OpHolder>);

impl crate::PyWrappedComponent<hardware::gamepad::Gamepad> for Op {
Expand Down
10 changes: 9 additions & 1 deletion arc/hardware/gamepad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ pub struct GamepadHolder {
gamepad: Box<dyn gp::MutableGamepad>,
}

impl Default for GamepadHolder {
fn default() -> Self {
Self {
gamepad: Box::new(gp::impls::Stub),
}
}
}

macro_rules! i {
(g $n: ident $ty:ty) => {
#[inline]
Expand Down Expand Up @@ -194,7 +202,7 @@ impl GamepadDpad {
/// This struct should not be used to modify the gamepad data. For that,
/// use the `GamepadHolder` struct.
#[pyclass]
#[derive(Debug, Clone)]
#[derive(Default, Debug, Clone)]
pub struct Gamepad(ThreadSafe<GamepadHolder>);

impl<G: gp::MutableGamepad + 'static> crate::PyWrappedComponent<G> for Gamepad {
Expand Down
26 changes: 23 additions & 3 deletions arc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ fn make_err(e: &'static str) -> pyo3::PyErr {
pyo3::PyErr::new::<pyo3::exceptions::PyIOError, _>(e)
}

// pub fn run_op() -> pyo3::PyResult<()> {
//
// }
/// A type that represents a python function.
///
/// This type is used to call python functions from rust.
///
/// # Example
///
/// ```rust
/// # use pyo3::prelude::*;
/// # use arc_pylib as pylib;
/// ```
#[repr(transparent)]
#[derive(Debug, Clone)]
pub struct PyFunction(pyo3::Py<pyo3::PyAny>);

impl PyFunction {
/// Calls the python function with the given arguments.
pub fn call(&self,
py: pyo3::Python<'_>,
args: impl pyo3::IntoPy<pyo3::Py<pyo3::types::PyTuple>>
) -> pyo3::PyResult<pyo3::PyObject> {
self.0.call1(py, args)
}
}
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Private files
/*.xcf
Binary file added docs/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions docs/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/logo192.ico
Binary file not shown.
Binary file added docs/logo256.ico
Binary file not shown.
Binary file added docs/logo64.ico
Binary file not shown.
Binary file added docs/logo_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/logo_white_a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/logo_white_gear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion epearl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from libs.scripts import run_cmd, hlp
from scripts import run_cmd, hlp

# Parse command line arguments
def get_args() -> tuple[str, list[str]]:
Expand Down
17 changes: 9 additions & 8 deletions examples/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
def main(op: Op):
print("Starting...")

holding_a = False
# holding_a = False
while op.running:
if op.gamepad.a:
if not holding_a:
print("A pressed!")
holding_a = True
else:
if holding_a:
print("A released!")
holding_a = False
print("A pressed!")
# if not holding_a:
# print("A pressed!")
# holding_a = True
# else:
# if holding_a:
# print("A released!")
# holding_a = False

print("Done!")

Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion libs/helper/l2math/README.md → helpers/l2math/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

<h2>A port of <a href="https://musl.libc.org/" target="_blank">MUSL</a>'s <a href="https://git.musl-libc.org/cgit/musl/tree/src/math" target="_blank">Math</a> library to <a href="https://www.rust-lang.org/" target="_blank">Rust</a> for <a href="https://doc.rust-lang.org/1.8.0/book/no-stdlib.html" target="_blank">no_std</a> environments.</h2>

### It is exceptionally rare that you should use this library directly. It is intended to be used by other libraries that require math functionality. If you are looking for a math library, you should probably be using [`libtrig`](../libtrig/).
### Disclaimer

It is exceptionally rare that you should use this library directly.
It is intended to be used by other libraries that require low level math functionality.
If you are looking for a math library, you should probably be using [`libtrig`](../libtrig/).
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ path = "lib.rs"

[dependencies.mc]
package = "macros-core"
path = "../macros-core"
path = "./macros-core"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions libs/README.md

This file was deleted.

51 changes: 0 additions & 51 deletions libs/robot/main.rs

This file was deleted.

31 changes: 31 additions & 0 deletions robot/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "arc-robot"
description = "ARC Robot"
repository.workspace = true
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true

[lib]
name = "arc_robot"
path = "lib.rs"

[dependencies.hardware]
package = "arc-robot-hardware"
path = "./hardware"

[dependencies.pyruntime]
package = "arc-robot-python-runtime"
path = "./runtime"

[dependencies.macros]
path = "../helpers/macros"
package = "macros"

[dependencies.rocket]
version = "0.5"
features = []

[dependencies.log]
version = "0.4"
File renamed without changes.
4 changes: 2 additions & 2 deletions libs/robot/hardware/Cargo.toml → robot/hardware/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license.workspace = true
path = "lib.rs"

[dependencies.l2math]
path = "../../helper/l2math"
path = "../../helpers/l2math"

[dependencies.libtrig]
path = "../../helper/libtrig"
path = "../../helpers/libtrig"
Loading

0 comments on commit eafa630

Please sign in to comment.