+++ added soccer robot framework
This commit is contained in:
parent
f2e4b847be
commit
d22cf4b33b
15 changed files with 542 additions and 0 deletions
208
source/Concept/Concept.vcproj
Normal file
208
source/Concept/Concept.vcproj
Normal file
|
@ -0,0 +1,208 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="Concept"
|
||||
ProjectGUID="{556125BE-937F-4A2B-89C7-B086575BE0F0}"
|
||||
RootNamespace="Concept"
|
||||
Keyword="ManagedCProj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
ManagedExtensions="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG"
|
||||
MinimalRebuild="FALSE"
|
||||
BasicRuntimeChecks="0"
|
||||
RuntimeLibrary="1"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)\$(ProjectName).exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"
|
||||
AssemblyDebug="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
ManagedExtensions="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG"
|
||||
MinimalRebuild="FALSE"
|
||||
RuntimeLibrary="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)\$(ProjectName).exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\main.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<File
|
||||
RelativePath=".\defines.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\stdafx.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Modules"
|
||||
Filter="">
|
||||
<Filter
|
||||
Name="IO_Module"
|
||||
Filter="">
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\io_module.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\io_module.h">
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Engine"
|
||||
Filter="">
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\engine.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\engine.h">
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Robot"
|
||||
Filter="">
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\robot.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\robot.h">
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Sensor"
|
||||
Filter="">
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\sensor.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\sensor.h">
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
91
source/Concept/defines.h
Normal file
91
source/Concept/defines.h
Normal file
|
@ -0,0 +1,91 @@
|
|||
#ifndef _DEFINES_H
|
||||
#define _DEFINES_H
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
//Integer definition
|
||||
#ifndef int8
|
||||
#ifdef __int8
|
||||
#define int8 __int8
|
||||
#else
|
||||
#define int8 char
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef int16
|
||||
#ifdef __int16
|
||||
#define int16 __int16
|
||||
#else
|
||||
#define int16 int
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef int32
|
||||
#ifdef __int32
|
||||
#define int32 __int32
|
||||
#else
|
||||
#define int32 long
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef int64
|
||||
#ifdef __int64
|
||||
#define int64 __int64
|
||||
#else
|
||||
#define int64 long long
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Unsigned
|
||||
#ifndef uint8
|
||||
#define uint8 unsigned int8
|
||||
#endif
|
||||
|
||||
#ifndef uint16
|
||||
#define uint16 unsigned int16
|
||||
#endif
|
||||
|
||||
#ifndef uint32
|
||||
#define uint32 unsigned int32
|
||||
#endif
|
||||
|
||||
#ifndef uint64
|
||||
#define uint64 unsigned int64
|
||||
#endif
|
||||
|
||||
//Sensor types
|
||||
enum SensorTypes
|
||||
{
|
||||
SENSOR_TYPE_ANALOG,
|
||||
SENSOR_TYPE_DIGITAL,
|
||||
};
|
||||
|
||||
//IO Module Names
|
||||
enum IOModuleNames
|
||||
{
|
||||
//General
|
||||
IO_START,
|
||||
|
||||
//Engines
|
||||
IO_ENGINE_START = IO_START,
|
||||
|
||||
IO_ENGINE_DRIVE_LEFT = IO_ENGINE_START,
|
||||
IO_ENGINE_DRIVE_RIGHT,
|
||||
IO_ENGINE_DRIVE_BACK,
|
||||
|
||||
IO_ENGINE_END,
|
||||
|
||||
//Sensors
|
||||
IO_SENSOR_START = IO_ENGINE_END,
|
||||
|
||||
IO_SENSOR_MOUSE = IO_SENSOR_START,
|
||||
|
||||
IO_SENSOR_END,
|
||||
|
||||
//General
|
||||
IO_END = IO_SENSOR_END,
|
||||
};
|
||||
|
||||
#endif
|
1
source/Concept/engine.cpp
Normal file
1
source/Concept/engine.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
#include "engine.h"
|
19
source/Concept/engine.h
Normal file
19
source/Concept/engine.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef _ENGINE_H
|
||||
#define _ENGINE_H
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
class Engine : public IO_Module
|
||||
{
|
||||
public:
|
||||
Engine()
|
||||
{
|
||||
}
|
||||
|
||||
Engine(uint32 engineId)
|
||||
{
|
||||
this->moduleId = engineId;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
1
source/Concept/io_module.cpp
Normal file
1
source/Concept/io_module.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
#include "io_module.h"
|
29
source/Concept/io_module.h
Normal file
29
source/Concept/io_module.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef _MODULE_H
|
||||
#define _MODULE_H
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
class IO_Module
|
||||
{
|
||||
public:
|
||||
IO_Module(uint32 moduleId)
|
||||
{
|
||||
this->moduleId = moduleId;
|
||||
}
|
||||
|
||||
IO_Module(){}
|
||||
|
||||
protected:
|
||||
uint32 moduleId;
|
||||
|
||||
public:
|
||||
|
||||
uint32 GetId()
|
||||
{
|
||||
return moduleId;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
47
source/Concept/main.cpp
Normal file
47
source/Concept/main.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
//Init our robot
|
||||
Robot* localRobot = new Robot();
|
||||
|
||||
//Init Engines
|
||||
for(uint8 i = IO_ENGINE_START; i < IO_ENGINE_END; i++)
|
||||
{
|
||||
Engine* newEngine = new Engine(i);
|
||||
localRobot->AddModule(newEngine);
|
||||
newEngine = NULL;
|
||||
}
|
||||
|
||||
//Init Sensors
|
||||
for(uint8 i = IO_SENSOR_START; i < IO_SENSOR_END; i++)
|
||||
{
|
||||
SensorTypes newSensorType;
|
||||
|
||||
switch(i)
|
||||
{
|
||||
//Cases when sensor is digital:
|
||||
// newSensorType = SENSOR_TYPE_DIGITAL;
|
||||
// break;
|
||||
|
||||
//Other cases
|
||||
default:
|
||||
newSensorType = SENSOR_TYPE_ANALOG;
|
||||
break;
|
||||
}
|
||||
|
||||
Sensor* newSensor = new Sensor(i, newSensorType);
|
||||
localRobot->AddModule(newSensor);
|
||||
newSensor = NULL;
|
||||
}
|
||||
|
||||
//Run
|
||||
while(true)
|
||||
{
|
||||
localRobot->Update();
|
||||
}
|
||||
|
||||
//Cleanup
|
||||
delete localRobot;
|
||||
localRobot = NULL;
|
||||
}
|
0
source/Concept/module.cpp
Normal file
0
source/Concept/module.cpp
Normal file
0
source/Concept/module.h
Normal file
0
source/Concept/module.h
Normal file
37
source/Concept/robot.cpp
Normal file
37
source/Concept/robot.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include "robot.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Robot::~Robot()
|
||||
{
|
||||
while(!modules.empty())
|
||||
{
|
||||
moduleMap::iterator iter = modules.begin();
|
||||
delete iter->second;
|
||||
modules.erase(iter);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Robot::AddModule(IO_Module* newModule)
|
||||
{
|
||||
moduleMap::iterator itr = modules.find(newModule->GetId());
|
||||
if(itr != modules.end())
|
||||
return false;
|
||||
|
||||
modules[newModule->GetId()] = newModule;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Robot::RemoveModule(IO_Module* oldModule)
|
||||
{
|
||||
return RemoveModule(oldModule->GetId());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Robot::Update()
|
||||
{
|
||||
//insert code here
|
||||
}
|
||||
|
||||
//--- EOF ---
|
46
source/Concept/robot.h
Normal file
46
source/Concept/robot.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
#ifndef _ROBOT_H
|
||||
#define _ROBOT_H
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
class IO_Module;
|
||||
class Sensor;
|
||||
class Engine;
|
||||
|
||||
class Robot
|
||||
{
|
||||
public:
|
||||
~Robot();
|
||||
|
||||
private:
|
||||
typedef hash_map<uint32, IO_Module*> moduleMap;
|
||||
moduleMap modules;
|
||||
|
||||
public:
|
||||
bool AddModule(IO_Module* newModule);
|
||||
|
||||
template <class T> T* GetModule(uint32 moduleId)
|
||||
{
|
||||
moduleMap::const_iterator itr = modules.find(moduleId);
|
||||
if(itr == modules.end())
|
||||
return NULL;
|
||||
else
|
||||
return ((T*)itr->second);
|
||||
}
|
||||
|
||||
bool RemoveModule(uint32 moduleId)
|
||||
{
|
||||
moduleMap::iterator itr = modules.find(moduleId);
|
||||
if(itr == modules.end())
|
||||
return false;
|
||||
|
||||
modules.erase(itr);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveModule(IO_Module* oldModule);
|
||||
|
||||
void Update();
|
||||
};
|
||||
|
||||
#endif
|
1
source/Concept/sensor.cpp
Normal file
1
source/Concept/sensor.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
#include "sensor.h"
|
29
source/Concept/sensor.h
Normal file
29
source/Concept/sensor.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef _SENSOR_H
|
||||
#define _SENSOR_H
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
class Sensor : public IO_Module
|
||||
{
|
||||
public:
|
||||
Sensor()
|
||||
{
|
||||
}
|
||||
|
||||
Sensor(uint32 sensorId, SensorTypes sensorType)
|
||||
{
|
||||
this->moduleId = sensorId;
|
||||
this->sensorType = sensorType;
|
||||
}
|
||||
|
||||
protected:
|
||||
SensorTypes sensorType;
|
||||
|
||||
public:
|
||||
SensorTypes GetType()
|
||||
{
|
||||
return sensorType;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
12
source/Concept/stdafx.h
Normal file
12
source/Concept/stdafx.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <hash_map>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "defines.h"
|
||||
#include "io_module.h"
|
||||
#include "sensor.h"
|
||||
#include "engine.h"
|
||||
#include "robot.h"
|
21
source/RoboCode.sln
Normal file
21
source/RoboCode.sln
Normal file
|
@ -0,0 +1,21 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Concept", "Concept\Concept.vcproj", "{556125BE-937F-4A2B-89C7-B086575BE0F0}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{556125BE-937F-4A2B-89C7-B086575BE0F0}.Debug.ActiveCfg = Debug|Win32
|
||||
{556125BE-937F-4A2B-89C7-B086575BE0F0}.Debug.Build.0 = Debug|Win32
|
||||
{556125BE-937F-4A2B-89C7-B086575BE0F0}.Release.ActiveCfg = Release|Win32
|
||||
{556125BE-937F-4A2B-89C7-B086575BE0F0}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
Reference in a new issue