From 38ce92b29854f19e8035cb5558e90868e5ca4927 Mon Sep 17 00:00:00 2001 From: miky Date: Fri, 17 Jun 2016 23:41:22 -0400 Subject: [PATCH] First commit. --- .gitignore | 4 +++ LICENSE | 22 ++++++++++++++ Makefile | 19 ++++++++++++ README.org | 16 ++++++++++ ant.cfg | 35 ++++++++++++++++++++++ ant.world | 46 +++++++++++++++++++++++++++++ ant_bot.inc | 17 +++++++++++ ias_ss.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ map.inc | 11 +++++++ maps/cave.png | Bin 0 -> 3138 bytes robot.cpp | 23 +++++++++++++++ robot.hpp | 67 ++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 339 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.org create mode 100644 ant.cfg create mode 100644 ant.world create mode 100644 ant_bot.inc create mode 100644 ias_ss.cpp create mode 100644 map.inc create mode 100644 maps/cave.png create mode 100644 robot.cpp create mode 100644 robot.hpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2305030 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*~ +*# +*.o +ias-ss \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6414a84 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2016, Miguel Angel Astor Romero +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..66135be --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +CXX = g++ +TARGET = ias_ss +OBJECTS = ias_ss.o robot.o +CFLAGS = -ansi -pedantic -Wall -g `pkg-config --cflags playerc++` -g +LDLIBS = `pkg-config --libs playerc++` -lboost_system -lpthread + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + $(CXX) $(CFLAGS) -o $(TARGET) $(OBJECTS) $(LDLIBS) + +-include $(OBJECTS:.o=.d) + +%.o: %.cpp + $(CXX) -c $(CFLAGS) $*.cpp -o $*.o + $(CXX) -MM $(CFLAGS) $*.cpp > $*.d + +clean: + $(RM) $(TARGET) $(OBJECTS) *.d diff --git a/README.org b/README.org new file mode 100644 index 0000000..972761b --- /dev/null +++ b/README.org @@ -0,0 +1,16 @@ +* IAS-SS + +** Abstract +IAS-SS (Inverse Ant System-based Surveillance System) is a [[http://playerstage.sourceforge.net/][Player/Stage]] based C++ implementation of the bio-inspired control architecture presented in the +following papers: + + 1) R. Calvo et al. "/Inverse ACO for Exploration and Surveillance in Unknown Environments/", The Third International Conference on Advanced Cognitive Technologies and Applications, Rome, Italy 2011. + 2) R. Calvo et al. "/A Distributed, Bio-Inspired Coordination Strategy for Multiple Agent Systems Applied to Surveillance Tasks in Unknown Environments/", Proc. of the IEEE IJCNN, San Jose, USA, 2011. + +This is being developed as part of the Robotics and Bio-Inspired Learning graduate course at UCV. + +Future versions of this README file will include a technical report on the developed software. + +** Notes + +The file ~maps/cave.png~ is part of the standard Stage distribution. diff --git a/ant.cfg b/ant.cfg new file mode 100644 index 0000000..dfd7f11 --- /dev/null +++ b/ant.cfg @@ -0,0 +1,35 @@ +driver +( + name "stage" + plugin "stageplugin" + provides [ "simulation:0" ] + worldfile "ant.world" +) + +driver +( + name "stage" + provides [ "6666:position2d:0" ] + model "ant_robot_1" +) + +driver +( + name "stage" + provides [ "6667:position2d:0" ] + model "ant_robot_2" +) + +driver +( + name "stage" + provides [ "6668:position2d:0" ] + model "ant_robot_3" +) + +driver +( + name "stage" + provides [ "6669:position2d:0" ] + model "ant_robot_4" +) \ No newline at end of file diff --git a/ant.world b/ant.world new file mode 100644 index 0000000..7abfdd9 --- /dev/null +++ b/ant.world @@ -0,0 +1,46 @@ +include "map.inc" +include "ant_bot.inc" + +window +( + size [ 635.000 666.000 ] # in pixels + scale 36.995 # pixels per meter + center [ -0.040 -0.274 ] + rotate [ 0 0 ] + + show_data 1 # 1=on 0=off +) + +floorplan +( + bitmap "maps/cave.png" + size [ 16.000 16.000 1.000 ] +) + +ant_bot +( + name "ant_robot_1" + pose [ -6.432 -5.895 0 45.000 ] + color "green" +) + +ant_bot +( + name "ant_robot_2" + pose [ 6.432 -3.895 0 135.000 ] + color "green" +) + +ant_bot +( + name "ant_robot_3" + pose [ -6.432 5.895 0 -45.000 ] + color "green" +) + +ant_bot +( + name "ant_robot_4" + pose [ 6.432 5.895 0 -135.000 ] + color "green" +) \ No newline at end of file diff --git a/ant_bot.inc b/ant_bot.inc new file mode 100644 index 0000000..e9020c9 --- /dev/null +++ b/ant_bot.inc @@ -0,0 +1,17 @@ +define ant_bot position +( + block + ( + points 6 + point[0] [ 0.75 0 ] + point[1] [ 1 0.25 ] + point[2] [ 1 0.75 ] + point[3] [ 0.75 1 ] + point[4] [ 0 1 ] + point[5] [ 0 0 ] + z [ 0 0.45 ] + ) + + drive "diff" + localization "gps" +) diff --git a/ias_ss.cpp b/ias_ss.cpp new file mode 100644 index 0000000..ac8a7c1 --- /dev/null +++ b/ias_ss.cpp @@ -0,0 +1,79 @@ +/************************************************************************************* + * Copyright (c) 2016, Miguel Angel Astor Romero * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice, this * + * list of conditions and the following disclaimer. * + * 2. Redistributions in binary form must reproduce the above copyright notice, * + * this list of conditions and the following disclaimer in the documentation * + * and/or other materials provided with the distribution. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + *************************************************************************************/ + +#include +#include +#include +#include + +#include "robot.hpp" + +const std::string HOST_NAME = "localhost"; +const uint32_t PORT = 6666; +const uint32_t NUM_ROBOTS = 4; + +extern "C" { + void * robot_thread(void * arg) { + IASSS_Robot * robot = static_cast(arg); + + std::cout << "Running robot thread." << std::endl; + robot->run(); + + return NULL; + } +} + +int main(int argc, char **argv) { + pthread_t robot_threads[NUM_ROBOTS]; + std::vector robots; + + try { + // Initialize the robot objects and threads. + for(uint32_t i = 0; i < NUM_ROBOTS; ++i) { + robots.push_back(new IASSS_Robot(HOST_NAME, PORT + i)); + + if(pthread_create(&robot_threads[i], NULL, robot_thread, static_cast(robots[i])) != 0) { + perror("Could not create robot thread"); + return EXIT_FAILURE; + } + } + + // Wait for all the robots to finish. + for(uint32_t i = 0; i < NUM_ROBOTS; ++i) { + if(pthread_join(robot_threads[i], NULL) != 0) { + perror("Could not join robot thread"); + return EXIT_FAILURE; + } + delete robots[i]; + } + robots.clear(); + + } catch (PlayerCc::PlayerError & e) { + std::cerr << e << std::endl; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/map.inc b/map.inc new file mode 100644 index 0000000..b9c42a5 --- /dev/null +++ b/map.inc @@ -0,0 +1,11 @@ +define floorplan model +( + color "gray30" + boundary 1 + gui_nose 0 + gui_move 0 + gui_outline 0 + gripper_return 0 + fiducial_return 0 + ranger_return 1 +) diff --git a/maps/cave.png b/maps/cave.png new file mode 100644 index 0000000000000000000000000000000000000000..a4aefd670045f411da70bfdfb61e628155aeda5c GIT binary patch literal 3138 zcmbVOdo)yQ8|Ohzai1|s5oKgtN|UDC8nwN3`zCYfz-~GJL+WT40@Av+mAN9y#JGnJm z)`*FT$)Qo!PGVx>(AOm`3W!bB$GD0f|MJ1uS&Jw~Jz8vg^MtabSe9 zC<;mu(GE6J&t(;*5v$SlxJ1!eFWTDTSU7W%)k7*MRI-_gT3+Dp<>!oC0K9U_l^U6+ zh9{@`j>Rj&)>S%T%-tLGzrbej7PpGHfgC3@!$C9h?S)M**DedxUZUC@7Ybxtq!znx zL0$UXsFOKaHhAD(!tuA!9$XfmsjWpb16Lbs13OspVGcEP`H3Da*6otELNwpjl%@tI zx@EZ04?m@$vWd;R+w0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=JV_NzyqHZF5q{2&phvuV>k5@yOjg z$4BjV^-Sw1o{yS$SI!yMz{}<2f%&TSZd6&DdUZyFaFj;L;!R7YQBs7I2Tcb8$LsCp za-&9Khfu!=t$y&UvyCAo`x;+Q(oH%LsAl!y!9sN#;m*; zNM1f{9CvU}v{|E?+qtySCuOD6$N<$z1!Yp&XglrtQa&`GZVnrl0qdiR-;@|d8-`!j zC7`C?xp(>-Wr4hCVfrRrRYRO`1|iFOI_c4?_PS0$?qYsU3Iy}w?^RTAp1m91{Ono) z`R&V1z9{q1=Hb_y57(x{L(=*0?J(xOe(m|6rrvOdCwjYDSg&49QA(kU_q^BZv;0qW7ID%K9=1;CJ5eqI5*` zJ11vQ5S;X*dJo2KN!W8YxVua^D;j&OiN?ToEyZ5crEm4}VSk&gD+TL2vfp9+XKDMV zOv8ZE$e7e*tX}mQc_7TFBI$EwPAGf%Ro|{bceh|;t02(WkNiNk=~AjG#mim)JphDh zj}N$*z|BbZ-X8kz%bv#J2C2KkILR$NWBdD$f4MGjJ)m@0SbXK9(m133`3K**2QnEr z{-C?iN^F&mL+I;lnkrM-4eY1a9viuO9};XCyp(URXT{PBjiB1&r(?nr?crVaS8EE1 zv5!&etz{!f7dp}M0D!d{$I*26e5~9L3CvXg3&4;5B zG*7pVdc#*XYenT>z1qs4^`|AG__N|W!7q75*zn)I?UDUYBStoq2-dM3Et=f{DcqA&m^V$|r2S|X|6PFS$RN;KWFfh%ncBH+BDftJ#x-^Sa+Keapju_K{g;WDzn#m- z@CQk)|3>rv@0+2xhoogBY9utI%&pt-Km1D6fv9`SEfm!XWx~?(?do@u=ZE$^5IKG^ Nw9R4bVoR^sKLK}S24VmJ literal 0 HcmV?d00001 diff --git a/robot.cpp b/robot.cpp new file mode 100644 index 0000000..82d785c --- /dev/null +++ b/robot.cpp @@ -0,0 +1,23 @@ +#include "robot.hpp" + +Robot::Robot(std::string hostname, uint32_t port) { + _p_client = new PlayerCc::PlayerClient(hostname, port); + _p_proxy = new PlayerCc::Position2dProxy(_p_client, 0); +} + +Robot::~Robot() { + delete _p_proxy; + delete _p_client; +} + +IASSS_Robot::IASSS_Robot(std::string hostname, uint32_t port) : Robot(hostname, port) { + std::cout << "Creating IAS-SS robot on host \"" << hostname << "\" and port " << port << "." << std::endl; +} + +IASSS_Robot::~IASSS_Robot() { + std::cout << "Destroying IAS-SS robot." << std::endl; +} + +void IASSS_Robot::run() { + sleep(10); +} diff --git a/robot.hpp b/robot.hpp new file mode 100644 index 0000000..ab4f3fd --- /dev/null +++ b/robot.hpp @@ -0,0 +1,67 @@ +/************************************************************************************* + * Copyright (c) 2016, Miguel Angel Astor Romero * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice, this * + * list of conditions and the following disclaimer. * + * 2. Redistributions in binary form must reproduce the above copyright notice, * + * this list of conditions and the following disclaimer in the documentation * + * and/or other materials provided with the distribution. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + *************************************************************************************/ + +#ifndef ROBOT_HPP +#define ROBOT_HPP + +#include +#include +#include + +/** + * Base class for robot types. + */ +class Robot { +public: + Robot(std::string hostname, uint32_t port); + virtual ~Robot(); + + virtual void run() = 0; + +protected: + PlayerCc::PlayerClient * _p_client; + PlayerCc::Position2dProxy * _p_proxy; +}; + +/** + * Concrete robot that implements the IAS-SS architecture as defined in: + * + * 1) R. Calvo et al. "Inverse ACO for Exploration and Surveillance in + * Unknown Environments", The Third International Conference on Advanced + * Cognitive Technologies and Applications, Rome, Italy 2011. + * + * 2) R. Calvo et al. "A Distributed, Bio-Inspired Coordination Strategy + * for Multiple Agent Systems Applied to Surveillance Tasks in Unknown + * Environments", Proc. of the IEEE IJCNN, San Jose, USA, 2011. + */ +class IASSS_Robot : Robot{ +public: + IASSS_Robot(std::string hostname, uint32_t port); + virtual ~IASSS_Robot(); + + virtual void run(); +}; + +#endif