Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ddefb's full-sized avatar
💭
I may be slow to respond.

Diego Bezerra ddefb

💭
I may be slow to respond.
View GitHub Profile
$./controller_sim
@ddefb
ddefb / Makefile
Last active March 12, 2019 19:43
$(SIGALI) < $(CONTRACT_PROG)_z3z/$(CONTRACT_NODE).z3z > /dev/null
$(HEPTC) -target c -target z3z -s $(SIM_NODE) $(CONTRACT_PROG).ept
@ddefb
ddefb / car.mli
Last active October 20, 2019 02:52
node obstacle(dist: int) returns (obs: bool)
let
automaton
state OBSTACLE do
obs = true;
unless (dist > 45) then NO_OBSTACLE
state NO_OBSTACLE do
obs = false;
unless (dist <= 45) then OBSTACLE
end
@ddefb
ddefb / Makefile
Last active March 12, 2019 19:29
SIM_PROG=car
SIM_NODE=controller
CONTRACT_NODE=controller
CONTRACT_PROG=$(SIM_PROG)
CC=gcc
HEPTC=heptc
HEPTS=hepts
@ddefb
ddefb / car.ino
Last active October 15, 2019 23:20
#include <AFMotor.h>
#include "controller_controller.c"
#include "car.c"
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
int obs_sensor;
source("jualib.R")
THINGSBOARD_SERVER = 'ip'
user = "username"
pass = "password"
station_name = "station_name"
keys = c('var_1', 'var_2', 'var_3')
start = "2000-01-01"
end = "2018-12-31"
#include <AFMotor.h>
#include "controller_controller.h"
#include "robo.h"
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
int obs_sensor;
void setup() {
Serial.begin(9600);
Robo__controller_reset(&mem);
pinMode(A0, OUTPUT);
pinMode(A1, INPUT);
digitalWrite(A0, LOW);
}
double read_obstacle(){
digitalWrite(A0, HIGH);
delayMicroseconds(15);
digitalWrite(A0, LOW);
uint32_t pulse_time = pulseIn(A1, HIGH);
double distance = 0.01715 * pulse_time;
return distance;
}