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

Groundstation #2

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
951cbc1
created react app
kira-the-engineer Nov 11, 2023
04e89e0
removed stock favicons, added ours
kira-the-engineer Nov 11, 2023
8475b4d
include joypad.js for later modification and also react fixes
kira-the-engineer Dec 2, 2023
4acc50b
Created basic implementation of controller code
kira-the-engineer Dec 2, 2023
f22483e
Solved button_held emitter
kira-the-engineer Dec 9, 2023
82cf721
XBox controller press, hold implementation done
kira-the-engineer Dec 9, 2023
7ea81c7
Fixing joypad library inputs on joysticks.
HenryDalrymple53 Dec 26, 2023
8caa6e7
New groundstation early implementation
HenryDalrymple53 Feb 3, 2024
fbd0e63
Added roslibjs node module install, alog with basic integration.
kira-the-engineer Feb 3, 2024
ba1f467
Added experimental topic subscription with images and publishing with…
HenryDalrymple53 Feb 8, 2024
4d73783
Dockerfile ros update from foxy to humble
kira-the-engineer Feb 16, 2024
3dfd6be
Merge branch 'groundstation' of https://github.com/OSURoboticsClub/Ro…
kira-the-engineer Feb 16, 2024
adc6ec2
Rover control and camera feed fully operational
kira-the-engineer Feb 17, 2024
70e987a
Full complete implementation of Rover vision, chassis and tower camer…
kira-the-engineer Mar 5, 2024
414a65c
Made chassis control fully reactable with statehooks instead of direc…
kira-the-engineer Mar 5, 2024
8a361c1
Revert "Full complete implementation of Rover vision, chassis and tow…
kira-the-engineer Mar 7, 2024
47c3914
Stable commit for reactable chassis base
kira-the-engineer Mar 9, 2024
99dbed0
Proper integration of state management instead of direct DOM manipula…
kira-the-engineer Mar 12, 2024
8cfcb0a
Final touches of optimization, error cleaning and edge case testing.
kira-the-engineer Mar 16, 2024
279d50a
Added framework for selection of front mount selection (Arm, Mining)
kira-the-engineer Mar 16, 2024
c0cf825
Stable commit tested on Rover, full functionality with basic infrastr…
kira-the-engineer Apr 23, 2024
fdfcdf4
Im getting real sick of modifying controller code (︶︹︺)
kira-the-engineer May 11, 2024
3521eeb
Stable and communication tested build.
kira-the-engineer Jun 4, 2024
48183b4
Arm controls/scuffed cv displays
kira-the-engineer Jul 26, 2024
c89776b
Fixed arm directions
kira-the-engineer Jul 26, 2024
8fc81e9
added gripper code
kira-the-engineer Jul 26, 2024
96f2570
Stable groundstation
kira-the-engineer Aug 6, 2024
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
18 changes: 7 additions & 11 deletions software/Dockerfile.rover
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
FROM --platform=linux/arm64 ros:foxy
FROM --platform=linux/arm64 ros:humble

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
ros-foxy-angles ros-foxy-composition ros-foxy-depthimage-to-laserscan \
ros-foxy-image-tools ros-foxy-joy ros-foxy-lifecycle ros-foxy-pcl-conversions \
ros-foxy-pendulum-control ros-foxy-pendulum-msgs ros-foxy-rqt-common-plugins \
ros-foxy-rviz2 ros-foxy-rviz-default-plugins ros-foxy-teleop-twist-joy \
ros-foxy-teleop-twist-keyboard ros-foxy-tlsf ros-foxy-tlsf-cpp ros-foxy-topic-monitor \
ros-foxy-image-common ros-foxy-image-pipeline ros-foxy-image-transport-plugins \
ros-foxy-laser-geometry ros-foxy-perception-pcl ros-foxy-vision-opencv ros-foxy-ros-ign \
ros-foxy-nmea-msgs nano socat xxd pip \
ros-humble-vision-opencv ros-humble-cv-bridge ros-humble-image-transport \
ros-humble-image-transport-plugins ros-humble-image-common ros-humble-image-pipeline \
ros-humble-image-tools ros-humble-rosbridge-server ros-humble-nmea-msgs \
nano pip \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

RUN pip install numpy pyserial pynmea2 minimalmodbus

RUN /bin/bash -c 'echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc'
RUN /bin/bash -c 'echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc'

RUN git clone https://github.com/OSURoboticsClub/Rover_2022_2023.git
RUN git clone https://github.com/OSURoboticsClub/Rover_2023_2024.git

ENTRYPOINT []

Expand Down
81 changes: 40 additions & 41 deletions software/firmware/modbus_master/modbus_master.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import struct
import serial
from typing import Any, List, Tuple, Dict

# Constants
_WRITE_INSTR = 16
Expand All @@ -22,17 +21,17 @@
_MAX_DATA_BYTES = 255
_INT_MAX = 65536

_serialports: Dict[str, serial.Serial] = {}
_serialports = {}

class Instrument:
"""Represents a slave
"""
def __init__(
self,
port: str,
slave_id: int,
baudrate: int = 19200
) -> None:
port,
slave_id,
baudrate=19200
):
"""Opens serial comms with a node and assigns it a slave id
"""
self.slave_id = slave_id
Expand All @@ -50,9 +49,9 @@ def __init__(

def write_registers(
self,
register_addr: int,
values: List[Any]
) -> None:
register_addr,
values
):
"""Write a list of values starting at register_addr
"""
if not self.serial:
Expand Down Expand Up @@ -101,9 +100,9 @@ def write_registers(

def read_registers(
self,
register_addr: int,
num_registers: int
) -> List[Any]:
register_addr,
num_registers
):
"""Read num_registers starting at register_addr
"""
if not self.serial:
Expand Down Expand Up @@ -161,23 +160,23 @@ def read_registers(

def write_register(
self,
register_addr: int,
value: Any
) -> None:
register_addr,
value
):
"""Write a value to register at register_addr
"""
self.write_registers(register_addr, [value])

def read_register(
self,
register_addr: int,
) -> Any:
register_addr,
):
"""Read register at register_addr
"""
res = self.read_registers(register_addr, 1)
return res[0] if res else None

def _create_byte_string(values: List[Any]) -> str:
def _create_byte_string(values):
"""Convert a list of values into a byte string
"""
bstr = ''
Expand All @@ -193,7 +192,7 @@ def _create_byte_string(values: List[Any]) -> str:
return bstr


def _create_byte_string_int8(values: List[int]) -> str:
def _create_byte_string_int8(values):
"""Converts a list of integers into a uint8 byte string
"""
bstr = ''
Expand All @@ -202,7 +201,7 @@ def _create_byte_string_int8(values: List[int]) -> str:
return bstr


def _calculate_num_bytes(values: List[Any]) -> int:
def _calculate_num_bytes(values):
"""Calculates the total number of bytes for a list of values
"""
num_bytes = 0
Expand All @@ -218,7 +217,7 @@ def _calculate_num_bytes(values: List[Any]) -> int:
return num_bytes


def _calculate_resp_size(instr: int, num_bytes: int = 0) -> int:
def _calculate_resp_size(instr, num_bytes=0):
"""Calculates the expected response size for a command
"""
if instr == _WRITE_INSTR:
Expand All @@ -227,7 +226,7 @@ def _calculate_resp_size(instr: int, num_bytes: int = 0) -> int:
return _READ_RESP_SZ_BASE + num_bytes


def _calculate_crc(packet: bytes) -> int:
def _calculate_crc(packet):
"""Calculates the CRC for a list of values (BLACK MAGIC)
"""
crc = 0xffff
Expand All @@ -244,31 +243,31 @@ def _calculate_crc(packet: bytes) -> int:
return crc


def _check_crc(resp: bytes, crc: int) -> bool:
def _check_crc(resp, crc):
"""Checks that the CRC of a list of values matches the expected CRC
"""
return _calculate_crc(resp[:-2]) == crc


def _add_crc(packet: bytes) -> bytes:
def _add_crc(packet):
"""Adds crc to packet"""
crc = _calculate_crc(packet)
packet += crc.to_bytes(2, 'big')
return packet


def _pack(formatstring: str, value: Any) -> str:
def _pack(formatstring, value):
"""Packs a value into a bytestring based on format
"""
return str(struct.pack(formatstring, value), encoding='latin1')


def _unpack(
resp: bytes,
register_addr: int,
num_registers: int,
skip_header: bool = True
) -> List[Any]:
resp,
register_addr,
num_registers,
skip_header=True
):
"""Given a response byte string, unpacks it into a list of values
"""
# Get the number of each register type in the packet
Expand Down Expand Up @@ -310,10 +309,10 @@ def _unpack(


def _calc_num_type(
register_addr: int,
num_registers: int,
max_reg: int
) -> int:
register_addr,
num_registers,
max_reg
):
"""Returns the number of a register type in a packet
"""
if num_registers <= 0:
Expand All @@ -329,9 +328,9 @@ def _calc_num_type(


def _calc_num_types(
register_addr: int,
num_registers: int,
) -> Tuple[int]:
register_addr,
num_registers,
):
"""Returns the total number of each register type in a packet
"""
# To calculate the number of each register type, we increase the register
Expand Down Expand Up @@ -361,16 +360,16 @@ def _calc_num_types(
return num_ints, num_floats, num_chars, num_bools


def _reg_in_range(addr: int, start: int, end: int) -> bool:
def _reg_in_range(addr, start, end):
"""Checks whether a given register address falls within the range provided (end exclusive)
"""
return addr >= start and addr < end


def _is_valid_write_data (
reg_addr: int,
values: list[Any]
) -> bool:
reg_addr,
values
):
"""Checks that the type of the given list of values matches the registers
"""
if reg_addr < _INT_REG_OFFSET or reg_addr >= _REG_MAX:
Expand Down
5 changes: 5 additions & 0 deletions software/firmware/modbus_master/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from modbus_master import Instrument

inst = Instrument('/dev/serial/by-id/usb-FTDI_FT230X_Basic_UART_D3499JFZ-if00-port0', 15, 115200)

inst.write_registers(1, [1])
23 changes: 23 additions & 0 deletions software/react_groundstation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
70 changes: 70 additions & 0 deletions software/react_groundstation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can't go back!**

If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.

You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `npm run build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
Loading