Skip to content

Commit

Permalink
update idl and dds rpc timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
holiray committed Dec 18, 2024
1 parent 578b387 commit a05fb25
Show file tree
Hide file tree
Showing 13 changed files with 1,009 additions and 238 deletions.
4 changes: 2 additions & 2 deletions include/unitree/common/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
if (debug) \
{ \
std::cout << "[" << ::time(NULL) \
<< "] [" << ::gettid() \
<< "] [" << ::syscall(SYS_gettid) \
<< "] UT_ASSERT DEBUG at __FILE__:" << file \
<< ", __FUNCTION__:" << func \
<< ", __LINE__:" << line \
Expand All @@ -21,7 +21,7 @@
else \
{ \
std::cout << "[" << ::time(NULL) \
<< "] [" << ::gettid() \
<< "] [" << ::syscall(SYS_gettid) \
<< "] UT_ASSERT ABORT at __FILE__:" << file \
<< ", __FUNCTION__:" << func \
<< ", __LINE__:" << line \
Expand Down
31 changes: 18 additions & 13 deletions include/unitree/common/dds/dds_entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

/*
* dds wait sub/pub matched default time slice.
* default 50000 us
* default 10000 us
*/
#define __UT_DDS_WAIT_MATCHED_TIME_SLICE 50000
#define __UT_DDS_WAIT_MATCHED_TIME_SLICE 10000
#define __UT_DDS_WAIT_MATCHED_TIME_MAX 1000000

using namespace org::eclipse::cyclonedds;

Expand Down Expand Up @@ -170,9 +171,9 @@ class DdsWriter : public DdsLogger

bool Write(const MSG& message, int64_t waitMicrosec)
{
if (waitMicrosec > 0 && !WaitReader(waitMicrosec))
if (waitMicrosec > 0)
{
return false;
WaitReader(waitMicrosec);
}

UT_DDS_EXCEPTION_TRY
Expand All @@ -186,20 +187,24 @@ class DdsWriter : public DdsLogger
}

private:
bool WaitReader(int64_t waitMicrosec)
void WaitReader(int64_t waitMicrosec)
{
while (mNative.publication_matched_status().current_count() == 0)
if (waitMicrosec < __UT_DDS_WAIT_MATCHED_TIME_SLICE)
{
if (waitMicrosec <= 0)
{
return false;
}
return;
}

MicroSleep(__UT_DDS_WAIT_MATCHED_TIME_SLICE);
waitMicrosec -=__UT_DDS_WAIT_MATCHED_TIME_SLICE;
int64_t waitTime = (waitMicrosec / 2);
if (waitTime > __UT_DDS_WAIT_MATCHED_TIME_MAX)
{
waitTime = __UT_DDS_WAIT_MATCHED_TIME_MAX;
}

return true;
while (waitTime > 0 && mNative.publication_matched_status().current_count() == 0)
{
MicroSleep(__UT_DDS_WAIT_MATCHED_TIME_SLICE);
waitTime -=__UT_DDS_WAIT_MATCHED_TIME_SLICE;
}
}

private:
Expand Down
7 changes: 4 additions & 3 deletions include/unitree/common/decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <sys/syscall.h>
#include <sys/resource.h>
#include <sys/timerfd.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netdb.h>
#include <time.h>
Expand Down Expand Up @@ -73,9 +74,9 @@

#define UT_DESC_ERR(name) name##_DESC

#if defined(__GLIBC__) and defined(__aarch64__)
#define gettid() syscall(__NR_gettid)
#endif
#ifndef SYS_gettid
#define SYS_gettid __NR_gettid
#endif//SYS_gettid

#define UT_SAFE_DEL(x) \
if ((x) != NULL) { delete (x); (x) = NULL; }
Expand Down
3 changes: 3 additions & 0 deletions include/unitree/common/os.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class OsHelper
uint64_t GetThreadId();
int32_t GetTid();

bool GetNetworkInterfaceIps(std::map<std::string,std::string>& networkInterfaceIpMap);
bool GetIps(std::set<std::string>& ips);

void CpuSet(const std::string& cpuIds);
void CpuSet(uint64_t threadId, size_t cpuId);

Expand Down
161 changes: 112 additions & 49 deletions include/unitree/idl/hg/HandCmd_.hpp

Large diffs are not rendered by default.

484 changes: 314 additions & 170 deletions include/unitree/idl/hg/HandState_.hpp

Large diffs are not rendered by default.

Loading

0 comments on commit a05fb25

Please sign in to comment.