当前位置: 首页>>代码示例>>C++>>正文


C++ CANJaguar::DisableControl方法代码示例

本文整理汇总了C++中CANJaguar::DisableControl方法的典型用法代码示例。如果您正苦于以下问题:C++ CANJaguar::DisableControl方法的具体用法?C++ CANJaguar::DisableControl怎么用?C++ CANJaguar::DisableControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CANJaguar的用法示例。


在下文中一共展示了CANJaguar::DisableControl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Configure

void CANJaguarConfiguration :: Configure ( CANJaguar & Jag )
{
	
	Jag.DisableControl ();
	
	Jag.ConfigMaxOutputVoltage ( MaxOutputVoltage );
	Jag.SetVoltageRampRate ( VoltageRampRate );
	
	Jag.ConfigFaultTime ( FaultTime );
	
	Jag.ConfigNeutralMode ( NeutralMode );
	
	Jag.ConfigLimitMode ( LimitMode );
	Jag.ConfigForwardLimit ( ForwardPositionLimit );
	Jag.ConfigForwardLimit ( ReversePositionLimit );
	
	switch ( Feedback )
	{

	case kFeedbackType_None:

		switch ( Mode )
		{

		case CANSpeedController :: kPercentVbus:
			Jag.SetPercentMode ();
			break;

		case CANSpeedController :: kCurrent:
			
			Jag.SetCurrentMode ( P, I, D );
			
			Jag.Set ( 0 );
			Jag.EnableControl ();
			
			break;

		case CANSpeedController :: kVoltage:
			Jag.SetVoltageMode ();
			break;
			
		default:
			
			Jag.SetVoltageMode ( CANJaguar :: Encoder, EncoderCounts );
			Jag.ConfigMaxOutputVoltage ( 0.0 );
			
			break;

		}
		
		break;
		
	case kFeedbackType_Encoder:
		
		switch ( Mode )
		{
			
		case CANSpeedController :: kPercentVbus:
			Jag.SetPercentMode ( CANJaguar :: Encoder, EncoderCounts );
			break;
	
		case CANSpeedController :: kCurrent:
			
			Jag.SetCurrentMode ( CANJaguar :: Encoder, EncoderCounts, P, I, D );
			
			Jag.Set ( 0 );
			Jag.EnableControl ();
			
			break;
		
		case CANSpeedController :: kSpeed:
			
			Jag.SetSpeedMode ( CANJaguar :: Encoder, EncoderCounts, P, I, D );
			
			Jag.Set ( 0 );
			Jag.EnableControl ();
			
			break;
			
		case CANSpeedController :: kVoltage:
			Jag.SetVoltageMode ( CANJaguar :: Encoder, EncoderCounts );
			break;
			
		default:
			
			Jag.SetVoltageMode ( CANJaguar :: Encoder, EncoderCounts );
			Jag.ConfigMaxOutputVoltage ( 0.0 );
			
			break;
			
		}
		
		break;
		
	case kFeedbackType_QuadEncoder:
		
		switch ( Mode )
		{
			
		case CANSpeedController :: kPercentVbus:
//.........这里部分代码省略.........
开发者ID:FRC2605,项目名称:CodeDevelopment,代码行数:101,代码来源:CANJaguarConfiguration.cpp

示例2: DashboardCommandServer

	// Shamelessly stolen from PCVideoServer
	int DashboardCommandServer()
	{
	    /* Setup to PC sockets */
	    struct sockaddr_in serverAddr;
	    int sockAddrSize = sizeof(serverAddr);
	    int pcSock = ERROR;
	    bzero ((char *) &serverAddr, sockAddrSize);
	    serverAddr.sin_len = (u_char) sockAddrSize;
	    serverAddr.sin_family = AF_INET;
	    serverAddr.sin_port = htons (kDashboardCommandPort);
	    serverAddr.sin_addr.s_addr = htonl (INADDR_ANY);

	    while (true)
	    {
	        taskSafe();
	    	  //  Create the socket.
	        if ((pcSock = socket (AF_INET, SOCK_STREAM, 0)) == ERROR)
	        {
	            perror ("socket");
	            continue;
	        }
	        //  Set the TCP socket so that it can be reused if it is in the wait state.
	        int reuseAddr = 1;
	        setsockopt(pcSock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char*>(&reuseAddr), sizeof(reuseAddr));
	        //  Bind socket to local address.
	        if (bind (pcSock, (struct sockaddr *) &serverAddr, sockAddrSize) == ERROR)
	        {
	            perror ("bind");
	            close (pcSock);
	            continue;
	        }
	        //  Create queue for client connection requests.
	        if (listen (pcSock, 1) == ERROR)
	        {
	            perror ("listen");
	            close (pcSock);
	            continue;
	        }

	        struct sockaddr_in clientAddr;
	        int clientAddrSize;
	        int newPCSock = accept (pcSock, reinterpret_cast<sockaddr*>(&clientAddr), &clientAddrSize);
	        if (newPCSock  == ERROR)
	        {
	            close(pcSock);
	            continue;
	        }

	        char cmdBuffer[32];
	        char *pBuffer;
	        while(1)
	        {
	            int numBytes = 0;
	            pBuffer = cmdBuffer;
	            while (numBytes < 2 || (*(pBuffer-2) != '\r' && *(pBuffer-1) != '\n'))
	            {
		            numBytes += read(newPCSock, pBuffer++, 1);
	            }
	            char command = cmdBuffer[0];
	            switch (command)
	            {
	            case 'E':
	            	speedJag.EnableControl();
	            	//printf("Enable\n");
	            	break;
	            case 'D':
	            	speedJag.DisableControl();
	            	//printf("Disable\n");
	            	break;
	            case 'G':
	            	{
	            		double P, I, D;
	            		memcpy((char*)&P, cmdBuffer+1, sizeof(double));
	            		memcpy((char*)&I, cmdBuffer+9, sizeof(double));
	            		memcpy((char*)&D, cmdBuffer+17, sizeof(double));
	            		speedJag.SetPID(P, I, D);
	            		//printf("Set- P: %f I: %f D: %f\n", P, I, D);
	            		//P = speedJag.GetP();
	            		//I = speedJag.GetI();
	            		//D = speedJag.GetD();
	            		//printf("Get- P: %f I: %f D: %f\n", P, I, D);
	            	}
	            	break;
	            }

	            //no point in running too fast -
	            Wait(0.01);
	        }
	        //  Clean up
	        close (newPCSock);
	        newPCSock = ERROR;
	        close (pcSock);
	        pcSock = ERROR;
	        taskUnsafe();
	        Wait(0.1);
	    }
	    return (OK);
	}
开发者ID:FRC980,项目名称:FRC-Team-980,代码行数:99,代码来源:MyRobot.cpp


注:本文中的CANJaguar::DisableControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。