This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node movement(c: bool) returns (turning: bool; ombc:int) | |
var last mbc:int = 0; | |
let | |
ombc = mbc; | |
automaton | |
state MOVING do | |
mbc = 0; | |
turning = false; | |
unless not c then STURNING | |
state STURNING do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node motor(c: bool) returns (mode, velocity: int) | |
let | |
automaton | |
state FORWARD do | |
mode = 1; | |
velocity = 255; | |
unless not c then BACKWARD | |
state BACKWARD do | |
mode = 2; | |
velocity = 255; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node controller(distance: int) returns (obs, turning: bool; motor1, motor2, motor3, motor4, vel1, vel2, vel3, vel4, cont: int) | |
contract | |
var | |
rule: bool; | |
let | |
rule = not obs & not turning or (turning & (motor1=1 & motor2=2 & motor3=1 & motor4=2)); | |
tel | |
enforce rule | |
with (c_move, c_motor1, c_motor2, c_motor3, c_motor4: bool) | |
let |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void loop() { | |
obs_sensor = read_obstacle(); | |
Robo__controller_step(obs_sensor, &_res, &mem); | |
motor1.setSpeed(_res.vel1); | |
motor1.run(_res.motor1); | |
motor2.setSpeed(_res.vel2); | |
motor2.run(_res.motor2); | |
motor3.setSpeed(_res.vel3); | |
motor3.run(_res.motor3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
Serial.begin(9600); | |
Robo__controller_reset(&mem); | |
pinMode(A0, OUTPUT); | |
pinMode(A1, INPUT); | |
digitalWrite(A0, LOW); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
OlderNewer