Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
alkaza authored Nov 30, 2017
1 parent 182f1de commit 5911eca
Showing 1 changed file with 101 additions and 14 deletions.
115 changes: 101 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
# Overview
## Guidelines
## Getting Started
Get Source Code
```
git clone https://github.com/alkaza/RPiRobot.git
```
Go to library directory
Update reposidory
```
cd /home/pi/CityScience/src/lib
git pull
```
Compile static library
Go to library directory
```
make all
cd /home/pi/CityScience/src/lib
```
Cleanup static library (if changes were made to static library)
```
make clean
```
Compile static library
```
make all
```
Go to source directory
```
cd /home/pi/CityScience/src
```
Copy static library to working directory
Remove static library from working directory (if changes were made to static library)
```
sh /home/pi/CityScience/src/scripts/cplib.sh
sh /home/pi/CityScience/src/scripts/rmlib.sh
examples
```
Remove static library from working directory (if changes were made to static library)
Copy static library to examples directory
```
sh /home/pi/CityScience/src/scripts/rmlib.sh
sh /home/pi/CityScience/src/scripts/cplib.sh
examples
```
Go to working directory
Go to examples directory
```
cd /home/pi/CityScience/src/examples
```
Cleanup all programs (if changes were made to examples)
```
make clean
```
Compile all programs
```
make all
Expand All @@ -42,10 +50,6 @@ Compile one program
```
make sensor
```
Cleanup program (if changes were made to the program)
```
rm sensor
```
Run the program
```
sudo ./sensor
Expand All @@ -55,6 +59,89 @@ Terminate the program
Ctrl-C
```

## Robot Library
### Sample code
```
#include <stdio.h>
#include <wiringPi.h>
#include "robot.h"
int main(void)
{
setup();
while (1) {
/* Implement here */
}
return 0;
}
```
- **stdio.h** is provides many standard library functions for file input and output
- **wiringPi.h** is a GPIO Interface library for the Raspberry Pi
- **robot.h** is a static library for RPiRobot

### Setup function
- Must include to run once
- Allows to terminate the program with Ctrl-C
- Initializes WiringPi, ultrasonic sensor and dc motor driver and

```
setup ();
```

### Infinite loop
Put your main code here to run repeatedly
```
while (1) {
/* Your code */
}
```

### Calculate distance detected by ultrasonic sensor
```
calc_dist ();
```

### Simple motor control
```
move (direction, speedA, speedB);
```

### Motor control with gradual deceleration
```
move_slow (direction, speedA, speedB);
```

**Recommended speed range**: 70~150

### Direction modes
- **FW** – go straight
- **BW** – go back
- **RIGHT** – turn right
- **LEFT** – turn left


### Advanced variables
Change until which speed to decelerate (70 by default)
```
min_speed = speed;
```
Check the previous direction taken
```
prev_dir
```

### Low-level motor control
Set direction
```
setDir (direction);
```
Set speed
```
setSpeed (speedA, speedB);
```

## Experiments
- Measuring distance
- Going forward and backward
Expand Down

0 comments on commit 5911eca

Please sign in to comment.