-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
484 additions
and
6 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
TARGET := bin/enviro | ||
|
||
all: | ||
$(MAKE) -C src all | ||
|
||
clean: | ||
$(MAKE) -C src clean | ||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
{ | ||
|
||
"name": "My Enviro Project", | ||
"ip": "0.0.0.0", | ||
"port": 8765, | ||
|
||
"buttons": [], | ||
|
||
"agents": [ | ||
{ | ||
"definition": "defs/guy.json", | ||
"style": { "fill": "lightblue", "stroke": "black" }, | ||
"position": { | ||
"x": 0, | ||
"y": 135, | ||
"theta": 0 | ||
} | ||
}, | ||
{ | ||
"definition": "defs/bumper.json", | ||
"style": { "fill": "red", "stroke": "none" }, | ||
"position": { | ||
"x": -145, | ||
"y": 68, | ||
"theta": 0 | ||
} | ||
}, | ||
{ | ||
"definition": "defs/bumper.json", | ||
"style": { "fill": "red", "stroke": "none" }, | ||
"position": { | ||
"x": 145, | ||
"y": 68, | ||
"theta": 0 | ||
} | ||
}, | ||
{ | ||
"definition": "defs/ghost.json", | ||
"style": { "fill": "lightgreen", "stroke": "black" }, | ||
"position": { | ||
"x": 0, | ||
"y": 80, | ||
"theta": 0 | ||
} | ||
} | ||
|
||
], | ||
|
||
"statics": [ | ||
{ | ||
"style": { "fill": "gray", "stroke": "none" }, | ||
"shape": [ | ||
{ "x": -350, "y": -200 }, | ||
{ "x": -350, "y": 200 }, | ||
{ "x": -340, "y": 200 }, | ||
{ "x": -340, "y": -200 } | ||
] | ||
}, | ||
{ | ||
"style": { "fill": "gray", "stroke": "none" }, | ||
"shape": [ | ||
{ "x": 350, "y": -200 }, | ||
{ "x": 350, "y": 200 }, | ||
{ "x": 340, "y": 200 }, | ||
{ "x": 340, "y": -200 } | ||
] | ||
}, | ||
{ | ||
"style": { "fill": "gray", "stroke": "none" }, | ||
"shape": [ | ||
{ "x": -350, "y": 200 }, | ||
{ "x": 350, "y": 200 }, | ||
{ "x": 350, "y": 190 }, | ||
{ "x": -350, "y": 190 } | ||
] | ||
}, | ||
{ | ||
"style": { "fill": "gray", "stroke": "none" }, | ||
"shape": [ | ||
{ "x": -350, "y": -200 }, | ||
{ "x": 350, "y": -200 }, | ||
{ "x": 350, "y": -190 }, | ||
{ "x": -350, "y": -190 } | ||
] | ||
}, | ||
|
||
{ | ||
"style": { "fill": "gray", "stroke": "none" }, | ||
"shape": [ | ||
{ "x": -350, "y": 125 }, | ||
{ "x": -250, "y": 125 }, | ||
{ "x": -250, "y": 115 }, | ||
{ "x": -350, "y": 115 } | ||
] | ||
}, | ||
|
||
{ | ||
"style": { "fill": "gray", "stroke": "none" }, | ||
"shape": [ | ||
{ "x": -150, "y": 90 }, | ||
{ "x": 150, "y": 90 }, | ||
{ "x": 150, "y": 80 }, | ||
{ "x": -150, "y": 80 } | ||
] | ||
}, | ||
|
||
{ | ||
"style": { "fill": "gray", "stroke": "none" }, | ||
"shape": [ | ||
{ "x": 350, "y": 55 }, | ||
{ "x": 250, "y": 55 }, | ||
{ "x": 250, "y": 45 }, | ||
{ "x": 350, "y": 45 } | ||
] | ||
} | ||
|
||
] | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Put agent definitions in this folder. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "Bumper", | ||
"type": "static", | ||
"description": "Replace this string with a description", | ||
"shape": [ | ||
{ "x": -5, "y": 10 }, | ||
{ "x": 5, "y": 10 }, | ||
{ "x": 5, "y": -10 }, | ||
{ "x": -5, "y": -10 } | ||
], | ||
"friction": { | ||
"collision": 5, | ||
"linear": 40, | ||
"rotational": 600 | ||
}, | ||
"sensors": [], | ||
"mass": 1, | ||
"controller": "lib/bumper.so" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "Ghost", | ||
"type": "dynamic", | ||
"description": "Replace this string with a description", | ||
"shape": [ | ||
{ "x": -10, "y": 15 }, | ||
{ "x": 10, "y": 15 }, | ||
{ "x": 10, "y": -15 }, | ||
{ "x": 0, "y": -17 }, | ||
{ "x": -10, "y": -15 } | ||
|
||
], | ||
"friction": { | ||
"collision": 5, | ||
"linear": 40, | ||
"rotational": 600 | ||
}, | ||
"sensors": [], | ||
"mass": 1, | ||
"controller": "lib/ghost.so" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "Guy", | ||
"type": "dynamic", | ||
"description": "Replace this string with a description", | ||
"shape": [ | ||
{ "x": -10, "y": 15 }, | ||
{ "x": 10, "y": 15 }, | ||
{ "x": 10, "y": -15 }, | ||
{ "x": -10, "y": -15 } | ||
], | ||
"friction": { | ||
"collision": 0, | ||
"linear": 0, | ||
"rotational": 0 | ||
}, | ||
"sensors": [ | ||
{ | ||
"type": "range", | ||
"location": { "x": 10, "y": 15 }, | ||
"direction": 1.57 | ||
}, | ||
{ | ||
"type": "range", | ||
"location": { "x": -10, "y": 15 }, | ||
"direction": 1.57 | ||
} | ||
], | ||
"mass": 1, | ||
"controller": "lib/guy.so" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Shared object libraries will be place here by make. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#Architecture | ||
ARCH := $(shell uname -m) | ||
|
||
#Compilers | ||
CC := g++ -std=c++17 -Wno-psabi | ||
|
||
#The Target Library | ||
|
||
#The Directories, Source, Includes, Objects, Binary and Resources | ||
SRCEXT := cc | ||
|
||
# Directories | ||
CHIPDIR := /usr/local/src/Chipmunk2D | ||
ENVIRODIR := ../../../server/include | ||
|
||
#Flags, Libraries and Includes | ||
CFLAGS := -ggdb -shared -fPIC | ||
INCLUDE := -I $(ENVIRODIR) -I $(CHIPDIR)/include/chipmunk | ||
|
||
#Files | ||
|
||
TARGETDIR := ../lib | ||
SOURCES := $(wildcard *.cc) | ||
HEADERS := $(wildcard *.h) | ||
TARGETS := $(patsubst %.cc,%.so,$(wildcard *.cc)) | ||
FULL_TARGETS := $(addprefix $(TARGETDIR)/, $(TARGETS)) | ||
|
||
#Default Make | ||
all: $(FULL_TARGETS) | ||
|
||
#Clean only Objects | ||
clean: | ||
@$(RM) -rf $(TARGETDIR)/*.so | ||
|
||
# Compile | ||
$(TARGETDIR)/%.so: %.cc %.h | ||
$(CC) $(CFLAGS) $(INCLUDE) $< -o $@ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <iostream> | ||
#include "bumper.h" | ||
|
||
using namespace enviro; | ||
|
||
// Put your implementations here |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef __BUMPER_AGENT__H | ||
#define __BUMPER_AGENT__H | ||
|
||
#include "enviro.h" | ||
|
||
using namespace enviro; | ||
|
||
class BumperController : public Process, public AgentInterface { | ||
|
||
public: | ||
BumperController() : Process(), AgentInterface() {} | ||
|
||
void init() {} | ||
void start() {} | ||
void update() {} | ||
void stop() {} | ||
|
||
}; | ||
|
||
class Bumper : public Agent { | ||
public: | ||
Bumper(json spec, World& world) : Agent(spec, world) { | ||
add_process(c); | ||
} | ||
private: | ||
BumperController c; | ||
}; | ||
|
||
DECLARE_INTERFACE(Bumper) | ||
|
||
#endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <iostream> | ||
#include "ghost.h" | ||
|
||
using namespace enviro; | ||
|
||
// Put your implementations here |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#ifndef __GHOST_AGENT__H | ||
#define __GHOST_AGENT__H | ||
|
||
#include "enviro.h" | ||
|
||
using namespace enviro; | ||
|
||
class GhostController : public Process, public AgentInterface { | ||
|
||
public: | ||
GhostController() : Process(), AgentInterface(), vx(20) {} | ||
|
||
void init() { | ||
prevent_rotation(); | ||
notice_collisions_with("Bumper", [&](Event &e) { | ||
if ( counter == 0 ) { | ||
vx = -vx; | ||
counter = 10; | ||
} | ||
}); | ||
decorate(R"(<g> | ||
<circle cx=-5 cy=-3 r=2 style='fill:black'></circle> | ||
<circle cx=5 cy=-3 r=2 style='fill:black'></circle></g>)"); | ||
} | ||
|
||
void start() {} | ||
|
||
void update() { | ||
double fx = -30*(velocity().x-vx); | ||
omni_apply_force(fx,0); | ||
if ( counter > 0 ) { | ||
counter--; | ||
} | ||
} | ||
|
||
void stop() {} | ||
|
||
double vx; | ||
int counter; | ||
|
||
}; | ||
|
||
class Ghost : public Agent { | ||
public: | ||
Ghost(json spec, World& world) : Agent(spec, world) { | ||
add_process(c); | ||
} | ||
private: | ||
GhostController c; | ||
}; | ||
|
||
DECLARE_INTERFACE(Ghost) | ||
|
||
#endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <iostream> | ||
#include "guy.h" | ||
|
||
using namespace enviro; | ||
|
||
// Put your implementations here |
Oops, something went wrong.