https://github.com/dkogan/mine-rover
https://github.com/dkogan/mine-rover
Last synced: 17 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/dkogan/mine-rover
- Owner: dkogan
- Created: 2019-05-11T05:52:44.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-01-23T09:03:55.000Z (over 5 years ago)
- Last Synced: 2025-02-28T16:09:19.911Z (over 1 year ago)
- Language: C++
- Size: 1.54 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
* Overview
This is a set of tools to drive the mine rover. There's a generic single-board
computer (a Raspberry Pi 3b+ currently). I'm talking via I2C to a PCA9685-based
16-Channel 12-bit PWM board. The first 4 PWM channels each talk to a motor via
an XY-160D motor controller.
Various datasheets are in docs/
* Tools
This repo has a few tools
** Basic test
For the most basic testing you can run =pwm-init.sh= and then =pwm-set.sh= to
write arbitrary values to the motor controllers. First run =pwm-init.sh= to set
up the port, and =pwm-set.sh= to write out the i2c values. This is needed only
for testing.
** Full system
When running the full system we run =motors-from-udp= on the board talking to
the motors (to read UDP commands and to command the motors). And we run
=motors-gui-to-udp= on a GUI-enabled computer talking to the board via the
network (to run a GUI to send commands to the network). The IPs and ports are
hard-coded.
*** =motors.py=
=motors.py= reads commands from STDIN, and commands the motors.
If --maxcmdinterval T is given on the commandline, then we send a motor-stop
command if T seconds elapses before receiving a command. This is intended as a
safety stop in case the network connection goes down.
Each line of text on STDIN is a command. Each command is a list of
whitespace-separated integers. The number of integers defines a different type
of command.
0 integers:
If an empty line is received, we release all the motors
1 integer:
0. Value in [0,3]: the motor index
We release the requested motor
2 integers:
0. Value in [0,3]: the motor index
1. Value in [-4095,4095]: the velocity.
Velocity 0 means "power hold".
4 integers:
0. Value in [-4095,4095]: the velocity of motor 0
1. Value in [-4095,4095]: the velocity of motor 1
2. Value in [-4095,4095]: the velocity of motor 2
3. Value in [-4095,4095]: the velocity of motor 3
Velocity 0 means "power hold".
*** =motors-from-udp=
A tiny script to read a UDP socket (via =socat=), and to connect it to
=motors.py=
*** =motors-gui-to-udp=
A fltk GUI application to send motor commands to a (hard-coded) UDP socket. This
application is meant to be controlled via a keyboard. Keys:
- Up/down: throttle. How fast the motors are spinning. This can be commanded
positive to drive forwards or negative to drive backwards. A value of 0 means
"stop"
- Left/right: turn. By default we drive straight: the left and right wheels
rotate evenly. If we want to turn, we rotate the left wheels faster or slower
than the right wheels. This imbalance is controlled with the left/right
buttons
- Space: go. At startup, the motors aren't engaged. We can plan a motion with
left/right/up/down, but the motors will not move until enabled by pressing
space. Similarly, while the motors are engaged, pressing space will stop them,
regardless of what they're doing
- Backspace: reset. At any point this will stop the motors, and reset the
steering to "straight" and the throttle to 0