Esempio n. 1
0
HRESULT CClientSession::DoPutFile( const string& strSrcFile, const string& strDstFile )
{
	if( !IsFileExist( strSrcFile.c_str() ) ){
		return E_NOENT;
	}

	//step 1. request passive mode to get the data channel address
	u_int nPasPort = 0;
	HRESULT hRet = DoPassive( nPasPort );
	if( FAILED(hRet) )return hRet;

	//step 2. send the put file command.
	CMessage1Param<char*>* pMsgPut = (CMessage1Param<char*>*)CMessageBase::Alloc( sizeof(CMessageBase)+strDstFile.length()+1 );
	pMsgPut->Init( NCM_PUTFILE, GetAddr(), GetServAddr(), strDstFile.c_str() );
	CMessageTrash trash1(pMsgPut);
	m_pClntProxy->SendMessage( pMsgPut );

	CMessage1Param<int>* pMsgAck = (CMessage1Param<int>*)WaitForMessage( NCF_ACK|NCM_PUTFILE );
	CMessageTrash trash2(pMsgAck);
	if( !pMsgAck->IsSucceeded() )return pMsgAck->GetResult();

	pMsgAck->ntoh( false );
	int nFileMode = pMsgAck->GetParam();

	//step 3. now the server agrees on the file transfer, connect the data channel and send file
	SOCKET sock_stream = OpenStream( nPasPort );
	if( sock_stream==INVALID_SOCKET )return E_OPENSTREAM;

	//open the data stream channel.
/*	CMessageBase msg;
	msg.Init( NCM_OPENSTREAM, GetAddr(), GetServAddr() );
	SendMessage( sock_stream, &msg );
	CMessageBase* pMsg = RecvMessage<CMessageBase>( sock_stream );
	if( pMsg==NULL ){
		closesocket( sock_stream );
		return E_OPENSTREAM;
	}

	CMessageTrash trash3(pMsg);
	if( pMsg->IsFailed() ){
		closesocket( sock_stream );
		return pMsg->GetResult();
	}*/

	//send the file stream
	int nLen = SendFileEx( sock_stream, strSrcFile.c_str(), nFileMode );
	shutdown( sock_stream, SD_BOTH );
	closesocket( sock_stream );

	//step 4. exchange the error code.
	CMessageBase msg;
	msg.Init( NCM_STREAMLENGTH, GetAddr(), GetServAddr(), nLen );
	m_pClntProxy->SendMessage( &msg );

	CMessageBase* pMsg = WaitForMessage( NCF_ACK|NCM_STREAMLENGTH );
	CMessageTrash trash4(pMsg);

	return pMsg->GetResult();
}
Esempio n. 2
0
HRESULT CClientSession::DoListDir( const string& strPath, EnumNetfEntryProc pEnumProc )
{
	//step 1. request passive mode to get the data channel address
	u_int nPasPort = 0;
	HRESULT hRet = DoPassive( nPasPort );
	if( FAILED(hRet) )return hRet;

	//step 2. send the put file command.
	CMessage1Param<char*>* pMsgList = (CMessage1Param<char*>*)CMessageBase::Alloc( sizeof(CMessageBase)+strPath.length()+1 );
	pMsgList->Init( NCM_LISTDIR, GetAddr(), GetServAddr(), strPath.c_str() );
	CMessageTrash trash1(pMsgList);
	m_pClntProxy->SendMessage( pMsgList );

	CMessageBase* pMsgAck = WaitForMessage( NCF_ACK|NCM_LISTDIR );
	CMessageTrash trash2(pMsgAck);
	if( !pMsgAck->IsSucceeded() )return pMsgAck->GetResult();

	//step 3. now the server agrees on the file transfer, connect the data channel and send file
	SOCKET sock_stream = OpenStream( nPasPort );
	if( sock_stream==INVALID_SOCKET )return E_OPENSTREAM;

	//open the data stream channel.
/*	CMessageBase msg;
	msg.Init( NCM_OPENSTREAM, GetAddr(), GetServAddr() );
	SendMessage( sock_stream, &msg );
	CMessageBase* pMsg = RecvMessage<CMessageBase>( sock_stream );
	if( pMsg==NULL ){
		closesocket( sock_stream );
		return E_OPENSTREAM;
	}

	CMessageTrash trash3(pMsg);
	if( pMsg->IsFailed() ){
		closesocket( sock_stream );
		return pMsg->GetResult();
	}*/

	NETF_ENTRY entry;
	int nLen = 0;
	while( true ){
		if( RecvBuffer( sock_stream, (char*)&entry, sizeof(NETF_ENTRY) )<sizeof(NETF_ENTRY) )break;

		(*pEnumProc)( &entry );
		nLen += sizeof(NETF_ENTRY);
	}
	closesocket( sock_stream );

	//step 4. exchange the error code.
	CMessageBase msg;
	msg.Init( NCM_STREAMLENGTH, GetAddr(), GetServAddr(), nLen );
	m_pClntProxy->SendMessage( &msg );

	CMessageBase* pMsg = WaitForMessage( NCF_ACK|NCM_STREAMLENGTH );
	CMessageTrash trash4(pMsg);

	return pMsg->GetResult();
}
Esempio n. 3
0
void PollServerThread::run()
{
    extern volatile bool gPhoneScreenSyncOn;
    while ( !m_exit && gPhoneScreenSyncOn ) {
        if ( !connecting() ) {
            int n = WaitForMessage(m_rfbClient, 500);
            if ( n < 0 ) {
                m_exit = true;
                break;
            } else if ( n > 0 ) {
                emit messageArrived();
                m_lastMessageReceivedTimer.start();
            } else if ( checkConnection() ) {
                if ( ((ConnectionWindow *)parent())->connected() && m_lastMessageReceivedTimer.elapsed() > QVNCVIEWER_CONNPEND_TIMEOUT ) {
                    setCheckConnection(false);
                    m_rfbClient->updateRect.x = m_rfbClient->updateRect.y = 0;
                    m_rfbClient->updateRect.w = m_rfbClient->width;
                    m_rfbClient->updateRect.h = m_rfbClient->height;
                    SendIncrementalFramebufferUpdateRequest(m_rfbClient);
                }
            }
            QTest::qWait(0);
        } else  if ( connecting() ) {
            setCheckConnection(true);
            qApp->processEvents(QEventLoop::AllEvents, 10);
        }
    }

    emit connectionClosed();
}
Esempio n. 4
0
CLStatus CLMessageLoopManager::EnterMessageLoop(void *pContext)
{
	CLStatus s = Initialize();
	if(!s.IsSuccess())
	{
		CLLogger::WriteLogMsg("In CLMessageLoopManager::EnterMessageLoop(), Initialize error", 0);
		return CLStatus(-1, 0);
	}
	
	while(true)
	{
		CLMessage *pMsg = WaitForMessage();
		if(pMsg == 0)
		{
			CLLogger::WriteLogMsg("In CLMessageLoopManager::EnterMessageLoop(), pMsg == 0", 0);
			continue;
		}
		
		CLStatus s3 = DispatchMessage(pMsg);

		delete pMsg;

		if(s3.m_clReturnCode == QUIT_MESSAGE_LOOP)
			break;
	}

	CLStatus s4 = Uninitialize();
	if(!s4.IsSuccess())
	{
		CLLogger::WriteLogMsg("In CLMessageLoopManager::EnterMessageLoop(), Uninitialize() error", 0);
		return CLStatus(-1, 0);
	}

	return CLStatus(0, 0);
}
Esempio n. 5
0
 /*
  * Input zero speed and nonzero pose. Input same pose state and pose setpoint. Expect zero output.
  */
TEST_F(QuaternionPdControllerTest, ZeroErrorZeroOutput)
{
    uranus_dp::SetControlMode srv;
    srv.request.mode = ControlModes::POSITION_HOLD;
    if (!modeClient.call(srv))
        ROS_ERROR("Failed to call service set_control_mode. New mode POSITION_HOLD not set.");

    Eigen::Vector3d    p(1,2,3);
    Eigen::Quaterniond q(4,5,6,7);
    q.normalize();

    Eigen::Vector3d v(0,0,0);
    Eigen::Vector3d omega(0,0,0);

    PublishState(p, q, v, omega);
    PublishSetpoint(p, q);

    WaitForMessage();

    EXPECT_NEAR(tau(0), 0, EPSILON);
    EXPECT_NEAR(tau(1), 0, EPSILON);
    EXPECT_NEAR(tau(2), 0, EPSILON);
    EXPECT_NEAR(tau(3), 0, EPSILON);
    EXPECT_NEAR(tau(4), 0, EPSILON);
    EXPECT_NEAR(tau(5), 0, EPSILON);
}
static void* clientLoop(void* data) {
	rfbClient* client=(rfbClient*)data;
	clientData* cd=(clientData*)client->clientData;

	client->appData.encodingsString=strdup(testEncodings[cd->encodingIndex].str);

	sleep(1);
	rfbClientLog("Starting client (encoding %s, display %s)\n",
			testEncodings[cd->encodingIndex].str,
			cd->display);
	if(!rfbInitClient(client,NULL,NULL)) {
		rfbClientErr("Had problems starting client (encoding %s)\n",
				testEncodings[cd->encodingIndex].str);
		updateStatistics(cd->encodingIndex,TRUE);
		return NULL;
	}
	while(1) {
		if(WaitForMessage(client,50)>=0)
			if(!HandleRFBServerMessage(client))
				break;
	}
	free(((clientData*)client->clientData)->display);
	free(client->clientData);
	if(client->frameBuffer)
		free(client->frameBuffer);
	rfbClientCleanup(client);
	return NULL;
}
Esempio n. 7
0
 /*
  * Give error only in yaw, assure rov force command only in yaw.
  */
TEST_F(QuaternionPdControllerTest, OnlyYaw)
{
    uranus_dp::SetControlMode srv;
    srv.request.mode = ControlModes::POSITION_HOLD;
    if (!modeClient.call(srv))
        ROS_ERROR("Failed to call service set_control_mode. New mode POSITION_HOLD not set.");

    uranus_dp::SetControllerGains gainSrv;
    gainSrv.request.a = 1;
    gainSrv.request.b = 30;
    gainSrv.request.c = 200;
    if (!gainClient.call(gainSrv))
        ROS_ERROR("Failed to call service set_controller_gains.");

    Eigen::Vector3d    p(0,0,0);
    Eigen::Quaterniond q(1,0,0,0);
    Eigen::Vector3d    v(0,0,0);
    Eigen::Vector3d    omega(0,0,0);

    Eigen::Quaterniond q_sp(0.923879532511287,0,0,0.382683432365090); // Equal to 45 degrees yaw
    q_sp.normalize();

    PublishState(p, q, v, omega);
    PublishSetpoint(p, q_sp);

    ros::Duration(0.5).sleep(); // Controller runs at 10 Hz, must give it time to compute new value.
    WaitForMessage();

    EXPECT_NEAR(tau(0),  0, EPSILON);
    EXPECT_NEAR(tau(1),  0, EPSILON);
    EXPECT_NEAR(tau(2),  0, EPSILON);
    EXPECT_NEAR(tau(3),  0, EPSILON);
    EXPECT_NEAR(tau(4),  0, EPSILON);
    EXPECT_NEAR(tau(5), 76.536686473017951, EPSILON);
}
Esempio n. 8
0
 /*
  * Give error only in sway, assure rov force command only in sway.
  */
TEST_F(QuaternionPdControllerTest, OnlySway)
{
    uranus_dp::SetControlMode srv;
    srv.request.mode = ControlModes::POSITION_HOLD;
    if (!modeClient.call(srv))
        ROS_ERROR("Failed to call service set_control_mode. New mode POSITION_HOLD not set.");

    uranus_dp::SetControllerGains gainSrv;
    gainSrv.request.a = 1;
    gainSrv.request.b = 30;
    gainSrv.request.c = 200;
    if (!gainClient.call(gainSrv))
        ROS_ERROR("Failed to call service set_controller_gains.");

    Eigen::Vector3d    p(0,0,0);
    Eigen::Quaterniond q(1,0,0,0);
    Eigen::Vector3d    v(0,0,0);
    Eigen::Vector3d    omega(0,0,0);

    Eigen::Vector3d p_sp(0,1,0);

    PublishState(p, q, v, omega);
    PublishSetpoint(p_sp, q);

    ros::Duration(0.5).sleep(); // Controller runs at 10 Hz, must give it time to compute new value.
    WaitForMessage();

    EXPECT_NEAR(tau(0),  0, EPSILON);
    EXPECT_NEAR(tau(1), 30, EPSILON);
    EXPECT_NEAR(tau(2),  0, EPSILON);
    EXPECT_NEAR(tau(3),  0, EPSILON);
    EXPECT_NEAR(tau(4),  0, EPSILON);
    EXPECT_NEAR(tau(5),  0, EPSILON);
}
Esempio n. 9
0
SOCKET CClientSession::OpenStream( u_int nPasPort )
{
	SOCKADDR_IN addr;
	addr.sin_family = AF_INET;
	addr.sin_addr = GetServAddr().m_addrHost;
	addr.sin_port = htons( (u_short)nPasPort );

	SOCKET sock_stream = Socket( PF_INET, SOCK_STREAM, 0 );
	ASSERT( sock_stream!=INVALID_SOCKET );

	//import, must retry the socket initilization a few times.
	try{
		if( RedundantConnect( sock_stream, addr )!=0 )throw new CSockException();

		//open the data stream channel.
		CMessageBase msg;
		msg.Init( NCM_OPENSTREAM, GetAddr(), GetServAddr() );
		SendMessage( sock_stream, &msg );
		CMessageBase* pMsg = RecvMessage<CMessageBase>( sock_stream );
		if( pMsg==NULL )throw new CRemoteException(E_BROKENPIPE);

		CMessageTrash trash(pMsg);
		if( pMsg->IsFailed() )throw new CRemoteException( pMsg->GetResult() );
	}catch( ... ){
		CMessageBase msg;
		msg.Init( NCM_OPENSTREAM, GetAddr(), GetServAddr(), E_OPENSTREAM );
		m_pClntProxy->SendMessage( &msg );
		CMessageTrash trash(WaitForMessage( NCF_ACK|NCM_OPENSTREAM ) );
		closesocket( sock_stream );
		throw;
		return INVALID_SOCKET;
	}

	return sock_stream;
}
Esempio n. 10
0
void UBTTaskNode::WaitForMessage(UBehaviorTreeComponent* OwnerComp, FName MessageType, int32 RequestID) const
{
	if (OwnerComp)
	{
		WaitForMessage(*OwnerComp, MessageType, RequestID);
	}
}
CLStatus CLMessageLoopManager::EnterMessageLoop(void *pContext)
{
	SLExecutiveInitialParameter *para = (SLExecutiveInitialParameter *)pContext;
	CLStatus s = Initialize();//队列(管道,网络等对象)等的初始化工作
	if(!s.IsSuccess())
	{
		throw "In CLMessageLoopManager::EnterMessageLoop(), Initialize() error.";
		para->pNotifier->NotifyInitialFinished(false);
		return CLStatus(-1,0);
	}
	CLStatus s1 = m_pMessageOberver->Initialize(this,para->pContext);//初始化CLMessageOberver对象,如注册不同消息的处理方法
	if(!s1.IsSuccess())
	{
		throw "In CLMessageLoopManager::EnterMessageLoop(), m_pMessageOberver->Initialize error.";
		para->pNotifier->NotifyInitialFinished(false);
		return CLStatus(-1,0);
	}
	para->pNotifier->NotifyInitialFinished(true);

	while(true)
	{
		CLMessage *pMsg = WaitForMessage();
		CLStatus s3 = DispatchMessage(pMsg);
		if(s3.m_clReturnCode == QUIT_MESSAGE_LOOP)  //注意此退出返回码要与QUIT_MESSAGE_LOOP保持一致
			break;
		delete pMsg;
	}
	delete m_pMessageOberver; //所有消息处理完毕,删除消息处理方法CLMessageOberver对象
	m_pMessageOberver = 0;  //这里加入了赋值语句,使得m_pMessageOberver = 0,因为在本类的析构中还释放了一次,造成segmentation fault
	CLStatus s4 = Uninitialize();//反初始化队列(管道,网络等对象)等
	return CLStatus(0,0);
}
Esempio n. 12
0
int
main(int argc, char **argv)
{
	rfbClient* client = rfbGetClient(8,3,4);

	client->GotFrameBufferUpdate = HandleRect;
	rfbClientRegisterExtension(&backChannel);

	if (!rfbInitClient(client,&argc,argv))
		return 1;

	while (1) {
		/* After each idle second, send a message */
		if(WaitForMessage(client,1000000)>0)
			HandleRFBServerMessage(client);
		else if(rfbClientGetClientData(client, sendMessage))
			sendMessage(client, "Dear Server,\n"
					"thank you for understanding "
					"back channel messages!");
	}

	rfbClientCleanup(client);

	return 0;
}
Esempio n. 13
0
void
SystemTimeSource::ControlThread()
{
	TRACE("SystemTimeSource::ControlThread() enter\n");
	status_t err;
	do {
		err = WaitForMessage(B_INFINITE_TIMEOUT);
	} while (err == B_OK || err == B_ERROR);
	TRACE("SystemTimeSource::ControlThread() exit\n");
}
Esempio n. 14
0
HRESULT CClientSession::DoFileMode( int nFileMode )
{
	CMessageBase msg;
	msg.Init( NCM_FILEMODE, GetAddr(), GetServAddr(), nFileMode );
	m_pClntProxy->SendMessage( &msg );

	CMessageBase* pAck = WaitForMessage( NCF_ACK|NCM_FILEMODE );
	CMessageTrash trash( pAck );
	return pAck->GetResult();
}
Esempio n. 15
0
/**
 * Waits until data is available to be read from the given rfbClient, and thus
 * a call to HandleRFBServerMessages() should not block. If the timeout elapses
 * before data is available, zero is returned.
 *
 * @param rfb_client
 *     The rfbClient to wait for.
 *
 * @param timeout
 *     The maximum amount of time to wait, in microseconds.
 *
 * @returns
 *     A positive value if data is available, zero if the timeout elapses
 *     before data becomes available, or a negative value on error.
 */
static int guac_vnc_wait_for_messages(rfbClient* rfb_client, int timeout) {

    /* Do not explicitly wait while data is on the buffer */
    if (rfb_client->buffered)
        return 1;

    /* If no data on buffer, wait for data on socket */
    return WaitForMessage(rfb_client, timeout);

}
Esempio n. 16
0
int main (int argc, char *argv[])
{
	int i;
	GdkImage *image;

	rfbClientLog = GtkDefaultLog;
	rfbClientErr = GtkErrorLog;

	gtk_init (&argc, &argv);

	/* create a dummy image just to make use of its properties */
	image = gdk_image_new (GDK_IMAGE_FASTEST, gdk_visual_get_system(),
				200, 100);

	cl = rfbGetClient (image->depth / 3, 3, image->bpp);

	cl->format.redShift     = image->visual->red_shift;
	cl->format.greenShift   = image->visual->green_shift;
	cl->format.blueShift    = image->visual->blue_shift;

	cl->format.redMax   = (1 << image->visual->red_prec) - 1;
	cl->format.greenMax = (1 << image->visual->green_prec) - 1;
	cl->format.blueMax  = (1 << image->visual->blue_prec) - 1;

	g_object_unref (image);

	cl->MallocFrameBuffer = resize;
	cl->canHandleNewFBSize = TRUE;
	cl->GotFrameBufferUpdate = update;
	cl->GotXCutText = got_cut_text;
	cl->HandleKeyboardLedState = kbd_leds;
	cl->HandleTextChat = text_chat;
	cl->GetPassword = get_password;
	cl->GetCredential = get_credential;

	show_connect_window (argc, argv);

	if (!rfbInitClient (cl, &argc, argv))
		return 1;

	while (1) {
		while (gtk_events_pending ())
			gtk_main_iteration ();
		i = WaitForMessage (cl, 500);
		if (i < 0)
			return 0;
		if (i && framebuffer_allocated == TRUE)
			if (!HandleRFBServerMessage(cl))
				return 0;
	}

	gtk_main ();

	return 0;
}
Esempio n. 17
0
HRESULT CClientSession::DoChMod( const string& strFileName, int nMode )
{
	CMessage1Param<char*>* pMsg = (CMessage1Param<char*>*)CMessageBase::Alloc( sizeof(CMessageBase)+strFileName.length()+1 );
	pMsg->Init( NCM_CHMOD, GetAddr(), GetServAddr(), strFileName.c_str(), nMode );
	CMessageTrash trash(pMsg);

	m_pClntProxy->SendMessage( pMsg );
	CMessageBase* pAck = WaitForMessage( NCF_ACK|NCM_CHMOD );
	CMessageTrash trash2(pAck);
	return pAck->GetResult();
}
Esempio n. 18
0
HRESULT CClientSession::DoChDir( const string& strPath )
{
	CMessage1Param<char*>* pMsg = (CMessage1Param<char*>*)CMessageBase::Alloc( sizeof(CMessageBase)+strPath.length()+1 );
	pMsg->Init( NCM_CHDIR, GetAddr(), GetServAddr(), strPath.c_str() );
	CMessageTrash trash(pMsg);

	m_pClntProxy->SendMessage( pMsg );

	CMessageBase* pAck = WaitForMessage( NCF_ACK|NCM_CHDIR );
	CMessageTrash trash2( pAck );
	return pAck->GetResult();
}
Esempio n. 19
0
HRESULT CClientSession::DoLogon( const string& strUser, const string& strPassword )
{
	CMessage2Param<char*, char*>* pMsg = (CMessage2Param<char*, char*>*)CMessageBase::Alloc( sizeof(CMessageBase)+strUser.length()+strPassword.length()+2 );
	pMsg->Init( NCM_LOGON, GetAddr(), GetServAddr(), strUser.c_str(), strPassword.c_str() );
	CMessageTrash trash(pMsg);

	m_pClntProxy->SendMessage( pMsg );

	CMessageBase* pAck = WaitForMessage( NCF_ACK|NCM_LOGON );
	CMessageTrash trash2( pAck );
	return pAck->GetResult();
}
Esempio n. 20
0
TEST_F(AllocatorTest, Sideways)
{
    Publish(0, 1, 0, 0, 0, 0);
    WaitForMessage();

    EXPECT_NEAR(F1, 0, MAX_ERROR);
    EXPECT_TRUE(F2 < 0);
    EXPECT_TRUE(F3 < 0);
    EXPECT_NEAR(F4, 0, MAX_ERROR);
    EXPECT_TRUE(F5 > 0);
    EXPECT_TRUE(F6 > 0);
}
Esempio n. 21
0
HRESULT CClientSession::DoServerInfo( SERVERINFO& info )
{
	CMessageBase msg;
	msg.Init( NCM_SERVERINFO, GetAddr(), GetServAddr() );
	m_pClntProxy->SendMessage( &msg );

	CMessage1Param<SERVERINFO>* pAck = (CMessage1Param<SERVERINFO>*)WaitForMessage( NCF_ACK|NCM_SERVERINFO );
	CMessageTrash trash( pAck );
	pAck->ntoh( false );
	info = pAck->GetParam();
	return pAck->GetResult();
}
Esempio n. 22
0
HRESULT CClientSession::DoSoftLink( const string& strSrc, const string& strLnk )
{
	CMessage2Param<char*, char*>* pMsg = (CMessage2Param<char*, char*>*)CMessageBase::Alloc( sizeof(CMessageBase)+strSrc.length()+strLnk.length()+2 );
	pMsg->Init( NCM_SOFTLINK, GetAddr(), GetServAddr(), strSrc.c_str(), strLnk.c_str() );
	CMessageTrash trash(pMsg);

	m_pClntProxy->SendMessage( pMsg );

	CMessageBase* pAck = WaitForMessage( NCF_ACK|NCM_SOFTLINK );
	CMessageTrash trash2( pAck );
	return pAck->GetResult();
}
Esempio n. 23
0
TEST_F(AllocatorTest, TurnRight)
{
    Publish(0, 0, 0, 0, 0, 1);
    WaitForMessage();

    EXPECT_NEAR(F1, 0, MAX_ERROR);
    EXPECT_TRUE(F2 < 0);
    EXPECT_TRUE(F3 > 0);
    EXPECT_NEAR(F4, 0, MAX_ERROR);
    EXPECT_TRUE(F5 > 0);
    EXPECT_TRUE(F6 < 0);
}
Esempio n. 24
0
TEST_F(AllocatorTest, TiltUp)
{
    Publish(0, 0, 0, 0, 1, 0);
    WaitForMessage();

    EXPECT_TRUE(F1 < 0);
    EXPECT_NEAR(F2, 0, MAX_ERROR);
    EXPECT_NEAR(F3, 0, MAX_ERROR);
    EXPECT_TRUE(F4 > 0);
    EXPECT_NEAR(F5, 0, MAX_ERROR);
    EXPECT_NEAR(F6, 0, MAX_ERROR);
}
Esempio n. 25
0
TEST_F(AllocatorTest, ZeroInput)
{
    Publish(0, 0, 0, 0, 0, 0);
    WaitForMessage();

    EXPECT_NEAR(F1, 0, MAX_ERROR);
    EXPECT_NEAR(F2, 0, MAX_ERROR);
    EXPECT_NEAR(F3, 0, MAX_ERROR);
    EXPECT_NEAR(F4, 0, MAX_ERROR);
    EXPECT_NEAR(F5, 0, MAX_ERROR);
    EXPECT_NEAR(F6, 0, MAX_ERROR);
}
Esempio n. 26
0
TEST_F(AllocatorTest, Forward)
{
    Publish(1, 0, 0, 0, 0, 0);
    WaitForMessage();

    EXPECT_TRUE(F1 < 0);
    EXPECT_TRUE(F2 > 0);
    EXPECT_TRUE(F3 < 0);
    EXPECT_TRUE(F4 > 0);
    EXPECT_TRUE(F5 > 0);
    EXPECT_TRUE(F6 < 0);
}
TEST_F(ClosedLoopIntegrationTest, ZeroInput)
{
    JoystickPublish(0,0,0,0,0,ControlModes::POSITION_HOLD);
    SensorPublish(0,0,9.80665,0,0,0);
    WaitForMessage();

    EXPECT_NEAR(F_A, 0, MAX_ERROR);
    EXPECT_NEAR(F_B, 0, MAX_ERROR);
    EXPECT_NEAR(F_C, 0, MAX_ERROR);
    EXPECT_NEAR(F_D, 0, MAX_ERROR);
    EXPECT_NEAR(F_E, 0, MAX_ERROR);
    EXPECT_NEAR(F_F, 0, MAX_ERROR);
}
TEST_F(ClosedLoopIntegrationTest, SurgePositionError)
{
    JoystickPublish(1,0,0,0,0,ControlModes::POSITION_HOLD);
    SensorPublish(0,0,9.80665,0,0,0);
    WaitForMessage();

    EXPECT_TRUE(F_A < 0);
    EXPECT_TRUE(F_B > 0);
    EXPECT_TRUE(F_C < 0);
    EXPECT_TRUE(F_D > 0);
    EXPECT_TRUE(F_E > 0);
    EXPECT_TRUE(F_F < 0);
}
Esempio n. 29
0
 /*
  * Make sure we receive any messages at all.
  */
TEST_F(OpenLoopControllerTest, CheckResponsiveness)
{
    ros::Duration(0.5).sleep();

    uranus_dp::SetControlMode srv;
    srv.request.mode = ControlModes::OPEN_LOOP;
    if (!client.call(srv))
        ROS_ERROR("Failed to call service set_control_mode. New mode OPEN_LOOP not set.");

    PublishSetpoint(0,0,0,0,0,0);
    WaitForMessage();
    EXPECT_TRUE(true);
}
Esempio n. 30
0
HRESULT CClientSession::DoPassive( u_int& nPasPort )
{
	CMessageBase msg;
	msg.Init( NCM_PASSIVE, GetAddr(), GetServAddr() );
	m_pClntProxy->SendMessage( &msg );

	CMessage1Param<u_int>* pMsg = (CMessage1Param<u_int>*)WaitForMessage( NCF_ACK|NCM_PASSIVE );
	CMessageTrash trash( pMsg );
	if( pMsg->IsSucceeded() ){
		pMsg->ntoh( false );
		nPasPort = pMsg->GetParam();
	}
	return pMsg->GetResult();
}