Skip to content

Commit

Permalink
Merge branch 'develop' into Team/teamball2
Browse files Browse the repository at this point in the history
# Conflicts:
#	NaoTHSoccer/Config/platform/SimSpark/modules.cfg
#	NaoTHSoccer/Source/Cognition/Modules/Behavior/XABSLBehaviorControl/Symbols/BallSymbols.cpp
  • Loading branch information
strouble committed May 6, 2017
2 parents 0b09d76 + b1d5c5e commit cd8f59f
Show file tree
Hide file tree
Showing 800 changed files with 143,613 additions and 14,347 deletions.
8 changes: 6 additions & 2 deletions .gitattributes
Expand Up @@ -7,12 +7,15 @@
*.cpp text diff=cpp
*.c text diff=cpp
*.cc text diff=cpp
*.java text diff=java
*.py text diff=python
*.java text diff=java
*.py text diff=python

*.lua text
*.proto text

# Netbeans *.form files
*.form text

# Declare files that will always have LF line endings on checkout.
*.sh text eol=lf
*.bat text
Expand All @@ -22,6 +25,7 @@
*.properties text
*.form text
*.html text
*.xabsl text

# Images should be treated as binary
# (binary is a macro for -text -diff)
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -13,6 +13,8 @@ genfiles.properties

#python
*.pyc
.idea/
naoth.egg-info*

#
trace.dump.*
Expand Down
26 changes: 11 additions & 15 deletions Framework/BuildTools/ansicolors.lua
Expand Up @@ -115,38 +115,34 @@ local function replaceDebugCodes(str)
-- parse keywords
a,b = string.find(str, ":")
if a ~= nil then
t = string.sub(str,1,a-1)
if mems[t] ~= nil then
str = mems[t] .. string.sub(str,1,a) .. "%{reset}" .. string.sub(str,a+1)
return str
end
t = string.sub(str,1,a-1)
if mems[t] ~= nil then
str = mems[t] .. string.sub(str,1,a) .. "%{reset}" .. string.sub(str,a+1)
return str
end
end

-- parse assignement
a,b = string.find(str, "=")
if a ~= nil then
str = "%{cyan}" .. string.sub(str,1,a-1) .. "%{reset}%{yellow}" .. string.sub(str,a)
return str
str = "%{cyan}" .. string.sub(str,1,a-1) .. "%{reset}%{yellow}" .. string.sub(str,a)
return str
end

-- highlight
if string.sub(str,1,1) == ">" then
return str
return str
end

-- dim everything else
str = "%{dim}" .. str;
str = "%{dim}" .. str
return str
end


-- redefine print
function print (...)
if #arg == 0 then
std_print()
else
for i,v in ipairs(arg) do
std_print(ansicolors(replaceDebugCodes(tostring(v))))
end
for i = 1, select("#",...) do
std_print(ansicolors(replaceDebugCodes(tostring( select(i,...) ))))
end
end
27 changes: 9 additions & 18 deletions Framework/BuildTools/protoc.lua
Expand Up @@ -91,11 +91,10 @@ local function protocCompile(inputFiles, cppOut, javaOut, pythonOut, ipaths)
print("INFO: executing " .. cmd)
local returnCode = os.execute(cmd)

if _OPTIONS["Wno-conversion"] == nil and returnCode == 0 then
-- add few lines to suppress the conversion warnings to each of the generated *.cc files
add_gcc_ignore_pragmas(os.matchfiles(cppOut .. "**.pb.cc"))
add_gcc_ignore_pragmas(os.matchfiles(cppOut .. "**.pb.h"))
--
if returnCode == 0 then
-- add few lines to suppress the conversion warnings to each of the generated *.cc files
add_gcc_ignore_pragmas(os.matchfiles(cppOut .. "**.pb.cc"))
add_gcc_ignore_pragmas(os.matchfiles(cppOut .. "**.pb.h"))
end

return returnCode == 0
Expand All @@ -104,26 +103,18 @@ end

function add_gcc_ignore_pragmas(files)
-- add gcc pragma to suppress the conversion warnings to each of the generated *.cc files
-- hack for the GCC version < 4.6.x
-- this is because "#pragma GCC diagnostic push/pop" was introduced in GCC 4.6
-- NOTE: we assume GCC version >= 4.9
local prefix = "// added by NaoTH \n" ..
"#if defined(__GNUC__) && defined(_NAOTH_CHECK_CONVERSION_)\n" ..
"#if (__GNUC__ > 3 && __GNUC_MINOR__ > 5) || (__GNUC__ > 4)\n" ..
"#if defined(__GNUC__)\n" ..
"#pragma GCC diagnostic push\n" ..
"#endif\n" ..
"#pragma GCC diagnostic ignored \"-Wconversion\"\n" ..
"#pragma GCC diagnostic ignored \"-Wunused-parameter\"\n" ..
"#endif\n\n"
-- enable the warnings at the end
-- restore the previous state at the end
local suffix = "\n\n// added by NaoTH \n" ..
"#if defined(__GNUC__) && defined(_NAOTH_CHECK_CONVERSION_)\n" ..
"#if (__GNUC__ > 3 && __GNUC_MINOR__ > 5) || (__GNUC__ > 4)\n" ..
"#if defined(__GNUC__)\n" ..
"#pragma GCC diagnostic pop\n" ..
"#else\n" ..
"#pragma GCC diagnostic error \"-Wconversion\"\n" ..
"#pragma GCC diagnostic error \"-Wunused-parameter\"\n" ..
"#endif\n" ..
"#endif\n\n"

for i,v in ipairs(files) do
Expand Down
8 changes: 6 additions & 2 deletions Framework/Commons/Messages/Framework-Representations.proto
Expand Up @@ -88,9 +88,13 @@ message RobotInfo {
}

message FSRData {
repeated double force = 1;
repeated double force = 1 [deprecated=true];
repeated double data = 2;
repeated bool valid = 3;
repeated bool valid = 3 [deprecated=true];

// should we separate them in the future?
//repeated double dataLeft = 4;
//repeated double dataRight = 5;
}

message AccelerometerData {
Expand Down
75 changes: 27 additions & 48 deletions Framework/Commons/Source/DebugCommunication/DebugServer.cpp
Expand Up @@ -23,34 +23,28 @@ DebugServer::DebugServer()
:
lastSendTime(0),
lastReceiveTime(0),
connectionThread(NULL),
abort(false)
{
m_executing = g_mutex_new();
m_abort = g_mutex_new();

answers = g_async_queue_new();
g_async_queue_ref(answers);
}

DebugServer::~DebugServer()
{
// notify the connectionThread to stop
g_mutex_lock(m_abort);
abort = true;
g_mutex_unlock(m_abort);
{
std::lock_guard<std::mutex> lock(m_abort);
abort = true;
}

// wait for connectionThread to stop
if(connectionThread != NULL) {
g_thread_join(connectionThread);
if(connectionThread.joinable()) {
connectionThread.join();
}

clearQueues();
comm.disconnect();

g_mutex_free(m_executing);
g_mutex_free(m_abort);

g_async_queue_unref(answers);
}

Expand All @@ -59,31 +53,22 @@ void DebugServer::start(unsigned short port)
{
comm.init(port);

if (!g_thread_supported()) {
g_thread_init(NULL);
}

GError* err = NULL;
g_debug("Starting debug server thread");
std::cout << "[INFO] Starting debug server thread" << std::endl;

connectionThread = g_thread_create(connection_thread_static, this, true, &err);
if(err) {
g_warning("Could not start debug server thread: %s", err->message);
}
connectionThread = std::thread([this] {this->run();});
}//end start

void DebugServer::run()
{
while(true)
{
// check if the stop is requested
g_mutex_lock(m_abort);
if(abort) {
g_mutex_unlock(m_abort);
break;
{
std::lock_guard<std::mutex> lock(m_abort);
if(abort) {
break;
}
}
g_mutex_unlock(m_abort);


if(comm.isConnected())
{
Expand All @@ -96,10 +81,10 @@ void DebugServer::run()
receive();

} catch(const char* msg) {
g_warning("debug server exception: %s", msg);
std::cout << "[WARN] debug server exception: " << msg << std::endl;
disconnect();
} catch(...) {
g_warning("unexpected exception in debug server");
std::cout << "[WARN] unexpected exception in debug server" << std::endl;
disconnect();
}
}
Expand All @@ -115,7 +100,7 @@ void DebugServer::run()
g_usleep(1000);

// TODO: do we really need this here?
g_thread_yield();
std::this_thread::yield();
} // end while true
}//end run

Expand Down Expand Up @@ -173,7 +158,7 @@ void DebugServer::send()
{
if(!comm.sendMessage(answer->id, answer->data.data(), answer->data.size()))
{
g_warning("could not send message");
std::cout << "[WARN] could not send message" << std::endl;
disconnect();
}
delete answer;
Expand All @@ -184,10 +169,10 @@ void DebugServer::send()
void DebugServer::disconnect()
{
// stop executing (so it's not messing up with our queues)
g_mutex_lock(m_executing);
clearQueues();
g_mutex_unlock(m_executing);

{
std::lock_guard<std::mutex> lock(m_executing);
clearQueues();
}
// all commands are "answered", disconnect
comm.disconnect();
}
Expand All @@ -209,14 +194,14 @@ void DebugServer::getDebugMessageInMotion(DebugMessageIn& buffer)

void DebugServer::setDebugMessageOut(const DebugMessageOut& buffer)
{
g_mutex_lock(m_executing);

for(std::list<DebugMessageOut::Message*>::const_iterator iter = buffer.answers.begin(); iter != buffer.answers.end(); ++iter)
{
g_async_queue_push(answers, *iter);
}
std::lock_guard<std::mutex> lock(m_executing);

g_mutex_unlock(m_executing);
for(std::list<DebugMessageOut::Message*>::const_iterator iter = buffer.answers.begin(); iter != buffer.answers.end(); ++iter)
{
g_async_queue_push(answers, *iter);
}
}
}

// TODO: serializer?
Expand Down Expand Up @@ -252,9 +237,3 @@ void DebugServer::clearQueues()
received_messages_motion.clear();
}

void* DebugServer::connection_thread_static(void* ref)
{
static_cast<DebugServer*>(ref)->run();
return NULL;
}

11 changes: 6 additions & 5 deletions Framework/Commons/Source/DebugCommunication/DebugServer.h
Expand Up @@ -19,6 +19,9 @@
#include <map>
#include <queue>

#include <thread>
#include <mutex>

class DebugServer
{
public:
Expand Down Expand Up @@ -96,14 +99,14 @@ class DebugServer
/** Communication interface */
DebugCommunicator comm;

GThread* connectionThread;
std::thread connectionThread;

GAsyncQueue* answers; // outgoing messages
Channel received_messages_cognition;
Channel received_messages_motion;

GMutex* m_executing;
GMutex* m_abort;
std::mutex m_executing;
std::mutex m_abort;

bool abort;

Expand All @@ -113,8 +116,6 @@ class DebugServer

void parseCommand(GString* cmdRaw, naoth::DebugMessageIn::Message& command) const;

static void* connection_thread_static(void* ref);

void disconnect();
void clearQueues();
};
Expand Down
15 changes: 7 additions & 8 deletions Framework/Commons/Source/Extern/libb64/cdecode.cpp
Expand Up @@ -5,10 +5,11 @@ This is part of the libb64 project, and has been placed in the public domain.
For details, see http://sourceforge.net/projects/libb64
*/

#if defined(__GNUC__) && defined(_NAOTH_CHECK_CONVERSION_)
#if __GNUC__ > 3 && __GNUC_MINOR__ > 5
// NOTE: we assume GCC version >= 4.9
#if defined(__GNUC__)
// save the current state
#pragma GCC diagnostic push
#endif
// ignore warnings
#pragma GCC diagnostic ignored "-Wconversion"
#endif

Expand Down Expand Up @@ -93,9 +94,7 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
return plainchar - plaintext_out;
}

#if defined(__GNUC__) && defined(_NAOTH_CHECK_CONVERSION_)
#if __GNUC__ > 3 && __GNUC_MINOR__ > 5
#pragma GCC diagnostic push
#endif
#pragma GCC diagnostic error "-Wconversion"
#if defined(__GNUC__)
// restore the old state
#pragma GCC diagnostic pop
#endif

0 comments on commit cd8f59f

Please sign in to comment.