Updated signals and added pictures for pres
This commit is contained in:
4
code/rc-car/.gitignore
vendored
Normal file
4
code/rc-car/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
_env/
|
||||
old/
|
||||
__pycache__/
|
||||
.ipynb_checkpoints/
|
49
code/rc-car/RCCar.py
Normal file
49
code/rc-car/RCCar.py
Normal file
@ -0,0 +1,49 @@
|
||||
from subprocess import run, DEVNULL
|
||||
from os import path
|
||||
from enum import Enum
|
||||
from time import sleep
|
||||
|
||||
class Direction(Enum):
|
||||
FORWARD = "Forward.complex" # car go vroom vroom random distances
|
||||
BACKWARD = "Back.complex" # same here but backwards
|
||||
LEFT = "Left.complex" # 360 + n*36 degrees at a time
|
||||
RIGHT = "Right.complex" # 360 + n*40 degrees at a time
|
||||
FINE_FORWARD = "Fine_forward.complex" # 30cm
|
||||
FINE_BACKWARD = "Fine_back.complex" # 30~cm
|
||||
|
||||
class RCCar:
|
||||
def __init__(self):
|
||||
self.sample_rate = 2_000_000
|
||||
self.frequency = 27_150_000
|
||||
self.bandwidth = 4_000_000
|
||||
# Get path of current file
|
||||
self.angle = 0
|
||||
self.forward = 0
|
||||
self.backward = 0
|
||||
self.signals = path.dirname(path.realpath(__file__)) + "/signals/"
|
||||
|
||||
def move(self, movement_file) -> str:
|
||||
|
||||
silent = run(["hackrf_transfer",
|
||||
"-t", f"{self.signals}{movement_file}",
|
||||
"-f", str(self.frequency),
|
||||
"-s", str(self.sample_rate),
|
||||
"-b", str(self.bandwidth),
|
||||
"-x", "47",
|
||||
|
||||
],
|
||||
stdout = DEVNULL,
|
||||
stderr = DEVNULL
|
||||
|
||||
)
|
||||
return movement_file
|
||||
|
||||
def test_move(self):
|
||||
for direction in Direction:
|
||||
self.move(direction.value)
|
||||
sleep(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
car = RCCar()
|
||||
car.test_move()
|
25
code/rc-car/README.md
Normal file
25
code/rc-car/README.md
Normal file
@ -0,0 +1,25 @@
|
||||
## RC-Car
|
||||
This is where I will upload all of the information regarding the RC car hacking.
|
||||
|
||||
<p align="center">
|
||||
<img src="https://media.discordapp.net/attachments/458628210272239626/1121750003669549066/IMG_20230622_162634_514.jpg?width=374&height=664" alt="RC car in the store"/>
|
||||
</p>
|
||||
|
||||
Technical information about the transmitter:
|
||||
* Uses a [YX 4116 21013](https://www.chinaglobalmall.com/products/559732132610) chip.
|
||||
* The board is HY-4T69 40M
|
||||
* Receiver works on 27.15MHz
|
||||
* Transmitter transmits at 29.15
|
||||
|
||||
<p align="center">
|
||||
<img src="https://media.discordapp.net/attachments/458628210272239626/1121750003124281394/IMG_20230623_131159_876.jpg?width=374&height=664" alt="RC car transmitter"/>
|
||||
</p>
|
||||
|
||||
## TODOS
|
||||
* [x] Record
|
||||
* [x] Forward
|
||||
* [x] Backward
|
||||
* [x] Left
|
||||
* [x] Right
|
||||
* [ ] Make a cool demo of fine controls
|
||||
* [ ] Record a cool trick and make it consistent
|
21
code/rc-car/moves.py
Normal file
21
code/rc-car/moves.py
Normal file
@ -0,0 +1,21 @@
|
||||
from RCCar import RCCar, Direction
|
||||
from time import sleep
|
||||
|
||||
def u_turn(car: RCCar):
|
||||
print("Moving back...")
|
||||
car.move(Direction.BACKWARD.value)
|
||||
print("Moving forward...")
|
||||
car.move(Direction.FORWARD.value)
|
||||
|
||||
print("Turning left...")
|
||||
for i in range(10):
|
||||
car.move(Direction.LEFT.value)
|
||||
|
||||
|
||||
def main():
|
||||
car = RCCar()
|
||||
u_turn(car)
|
||||
# 10
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
BIN
code/rc-car/signals/Back.complex
Normal file
BIN
code/rc-car/signals/Back.complex
Normal file
Binary file not shown.
BIN
code/rc-car/signals/Fine_back.complex
Normal file
BIN
code/rc-car/signals/Fine_back.complex
Normal file
Binary file not shown.
BIN
code/rc-car/signals/Fine_forward.complex
Normal file
BIN
code/rc-car/signals/Fine_forward.complex
Normal file
Binary file not shown.
BIN
code/rc-car/signals/Forward.complex
Normal file
BIN
code/rc-car/signals/Forward.complex
Normal file
Binary file not shown.
BIN
code/rc-car/signals/Left.complex
Normal file
BIN
code/rc-car/signals/Left.complex
Normal file
Binary file not shown.
BIN
code/rc-car/signals/Right.complex
Normal file
BIN
code/rc-car/signals/Right.complex
Normal file
Binary file not shown.
Reference in New Issue
Block a user