|
@@ -17,6 +17,50 @@ RDBConn::~RDBConn()
|
|
mpthreadconn->join();
|
|
mpthreadconn->join();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void RDBConn::threadsend(int nsock)
|
|
|
|
+{
|
|
|
|
+ while(mbthreadconn)
|
|
|
|
+ {
|
|
|
|
+ if(mbEgoUpdate)
|
|
|
|
+ {
|
|
|
|
+ Framework::RDBHandler myHandler;
|
|
|
|
+
|
|
|
|
+ // start a new message
|
|
|
|
+ myHandler.initMsg();
|
|
|
|
+
|
|
|
|
+ // begin with an SOF identifier
|
|
|
|
+ myHandler.addPackage( simTime, simFrame, RDB_PKG_ID_START_OF_FRAME );
|
|
|
|
+
|
|
|
|
+ // add extended package for the object state
|
|
|
|
+ RDB_OBJECT_STATE_t *objState = ( RDB_OBJECT_STATE_t* ) myHandler.addPackage( simTime, simFrame, RDB_PKG_ID_OBJECT_STATE, 1, true );
|
|
|
|
+
|
|
|
|
+ if ( !objState )
|
|
|
|
+ {
|
|
|
|
+ fprintf( stderr, "sendOwnObjectState: could not create object state\n" );
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // copy contents of internally held object state to output structure
|
|
|
|
+ memcpy( objState, &sOwnObjectState, sizeof( RDB_OBJECT_STATE_t ) );
|
|
|
|
+
|
|
|
|
+ fprintf( stderr, "sendOwnObjectState: sending pos x/y/z = %.3lf/%.3lf/%.3lf,\n", objState->base.pos.x, objState->base.pos.y, objState->base.pos.z );
|
|
|
|
+
|
|
|
|
+ // terminate with an EOF identifier
|
|
|
|
+ myHandler.addPackage( simTime, simFrame, RDB_PKG_ID_END_OF_FRAME );
|
|
|
|
+
|
|
|
|
+ int retVal = send( nsock, ( const char* ) ( myHandler.getMsg() ), myHandler.getMsgTotalSize(), 0 );
|
|
|
|
+
|
|
|
|
+ if ( !retVal )
|
|
|
|
+ fprintf( stderr, "sendOwnObjectState: could not send object state\n" );
|
|
|
|
+ mbEgoUpdate = false;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
void RDBConn::threadconn(char *strserip, int nport)
|
|
void RDBConn::threadconn(char *strserip, int nport)
|
|
{
|
|
{
|
|
|
|
|
|
@@ -60,6 +104,7 @@ void RDBConn::threadconn(char *strserip, int nport)
|
|
char* szBuffer = new char[DEFAULT_BUFFER]; // allocate on heap
|
|
char* szBuffer = new char[DEFAULT_BUFFER]; // allocate on heap
|
|
|
|
|
|
|
|
|
|
|
|
+ std::thread * pthreadsend = NULL;
|
|
|
|
|
|
while(mbthreadconn)
|
|
while(mbthreadconn)
|
|
{
|
|
{
|
|
@@ -79,43 +124,48 @@ void RDBConn::threadconn(char *strserip, int nport)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if(pthreadsend == NULL)
|
|
|
|
+ {
|
|
|
|
+ pthreadsend = new std::thread(&RDBConn::threadsend,this,sClient);
|
|
|
|
+ }
|
|
|
|
+
|
|
ret = recv( sClient, szBuffer, DEFAULT_BUFFER, 0 );
|
|
ret = recv( sClient, szBuffer, DEFAULT_BUFFER, 0 );
|
|
|
|
|
|
std::cout<<" ret: "<<ret<<std::endl;
|
|
std::cout<<" ret: "<<ret<<std::endl;
|
|
|
|
|
|
- if(mbEgoUpdate)
|
|
|
|
- {
|
|
|
|
- Framework::RDBHandler myHandler;
|
|
|
|
|
|
+// if(mbEgoUpdate)
|
|
|
|
+// {
|
|
|
|
+// Framework::RDBHandler myHandler;
|
|
|
|
|
|
- // start a new message
|
|
|
|
- myHandler.initMsg();
|
|
|
|
|
|
+// // start a new message
|
|
|
|
+// myHandler.initMsg();
|
|
|
|
|
|
- // begin with an SOF identifier
|
|
|
|
- myHandler.addPackage( simTime, simFrame, RDB_PKG_ID_START_OF_FRAME );
|
|
|
|
|
|
+// // begin with an SOF identifier
|
|
|
|
+// myHandler.addPackage( simTime, simFrame, RDB_PKG_ID_START_OF_FRAME );
|
|
|
|
|
|
- // add extended package for the object state
|
|
|
|
- RDB_OBJECT_STATE_t *objState = ( RDB_OBJECT_STATE_t* ) myHandler.addPackage( simTime, simFrame, RDB_PKG_ID_OBJECT_STATE, 1, true );
|
|
|
|
|
|
+// // add extended package for the object state
|
|
|
|
+// RDB_OBJECT_STATE_t *objState = ( RDB_OBJECT_STATE_t* ) myHandler.addPackage( simTime, simFrame, RDB_PKG_ID_OBJECT_STATE, 1, true );
|
|
|
|
|
|
- if ( !objState )
|
|
|
|
- {
|
|
|
|
- fprintf( stderr, "sendOwnObjectState: could not create object state\n" );
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+// if ( !objState )
|
|
|
|
+// {
|
|
|
|
+// fprintf( stderr, "sendOwnObjectState: could not create object state\n" );
|
|
|
|
+// return;
|
|
|
|
+// }
|
|
|
|
|
|
- // copy contents of internally held object state to output structure
|
|
|
|
- memcpy( objState, &sOwnObjectState, sizeof( RDB_OBJECT_STATE_t ) );
|
|
|
|
|
|
+// // copy contents of internally held object state to output structure
|
|
|
|
+// memcpy( objState, &sOwnObjectState, sizeof( RDB_OBJECT_STATE_t ) );
|
|
|
|
|
|
- fprintf( stderr, "sendOwnObjectState: sending pos x/y/z = %.3lf/%.3lf/%.3lf,\n", objState->base.pos.x, objState->base.pos.y, objState->base.pos.z );
|
|
|
|
|
|
+// fprintf( stderr, "sendOwnObjectState: sending pos x/y/z = %.3lf/%.3lf/%.3lf,\n", objState->base.pos.x, objState->base.pos.y, objState->base.pos.z );
|
|
|
|
|
|
- // terminate with an EOF identifier
|
|
|
|
- myHandler.addPackage( simTime, simFrame, RDB_PKG_ID_END_OF_FRAME );
|
|
|
|
|
|
+// // terminate with an EOF identifier
|
|
|
|
+// myHandler.addPackage( simTime, simFrame, RDB_PKG_ID_END_OF_FRAME );
|
|
|
|
|
|
- int retVal = send( sClient, ( const char* ) ( myHandler.getMsg() ), myHandler.getMsgTotalSize(), 0 );
|
|
|
|
|
|
+// int retVal = send( sClient, ( const char* ) ( myHandler.getMsg() ), myHandler.getMsgTotalSize(), 0 );
|
|
|
|
|
|
- if ( !retVal )
|
|
|
|
- fprintf( stderr, "sendOwnObjectState: could not send object state\n" );
|
|
|
|
- mbEgoUpdate = false;
|
|
|
|
- }
|
|
|
|
|
|
+// if ( !retVal )
|
|
|
|
+// fprintf( stderr, "sendOwnObjectState: could not send object state\n" );
|
|
|
|
+// mbEgoUpdate = false;
|
|
|
|
+// }
|
|
|
|
|
|
if ( ret == -1 )
|
|
if ( ret == -1 )
|
|
{
|
|
{
|