示例#1
0
void GerberGenerator::drawPathOutline(
    const Path& path, const UnsignedLength& lineWidth) noexcept {
  if (path.getVertices().count() < 2) {
    qWarning() << "Invalid path was ignored in gerber output!";
    return;
  }
  setCurrentAperture(mApertureList->setCircle(lineWidth, UnsignedLength(0)));
  moveToPosition(path.getVertices().first().getPos());
  for (int i = 1; i < path.getVertices().count(); ++i) {
    const Vertex& v  = path.getVertices().at(i);
    const Vertex& v0 = path.getVertices().at(i - 1);
    if (v0.getAngle() == 0) {
      // linear segment
      linearInterpolateToPosition(v.getPos());
    } else {
      // arc segment
      if (v0.getAngle().abs() <= Angle::deg90()) {
        setMultiQuadrantArcModeOff();
      } else {
        setMultiQuadrantArcModeOn();
      }
      if (v0.getAngle() < 0) {
        switchToCircularCwInterpolationModeG02();
      } else {
        switchToCircularCcwInterpolationModeG03();
      }
      Point center = Toolbox::arcCenter(v0.getPos(), v.getPos(), v0.getAngle());
      circularInterpolateToPosition(v0.getPos(), center, v.getPos());
      switchToLinearInterpolationModeG01();
    }
  }
}
示例#2
0
void autonomousFcns(int Btn4, int startPos)
{
	switch(Btn4)
		{
		case 256: //8U
		servoCount = 0;
		moveAtAngle(motor1, pot2, 15, 500, 3, startPos, 0.5, 0.25, 0.75, 0.5);
		break;

		case 1024: //8D
		servoCount = 0;
		moveToPosition(motor4, pot1, 2048, 80, 3, 1024, 512, 0.7, 0.3);
		moveToPosition(motor1, pot2, 1024, 80, 3, 512, 256, 0.7, 0.3);
		break;
		}
}
void DragableCardFrame::mouseMoveEvent(QMouseEvent *event) {
	if (!pressed)
		return;
	raise();
	QPoint moveToPosition(event->pos() - dragPoint + pos());
	this->move(normalizePosition(moveToPosition));
}
示例#4
0
void WindowManager::moveToWorkspaceCenter(QWidget *window)
{
	const QSize windowSizeHint = window->sizeHint();
	const QRect workspaceGeometry = qApp->desktop()->availableGeometry(window);

	int xPosition = (workspaceGeometry.width() - windowSizeHint.width()) / 2;
	int yPosition = (workspaceGeometry.height() - windowSizeHint.height()) / 2;

	moveToPosition(window, QPoint(xPosition, yPosition));
}
示例#5
0
void Caret::moveToPrevBar()
{
    const System &system = myLocation.getSystem();
    const Barline *prevBar = system.getPreviousBarline(
                myLocation.getPositionIndex());
    if (prevBar)
        prevBar = system.getPreviousBarline(prevBar->getPosition());

    if (prevBar)
        moveToPosition(prevBar->getPosition());
    else if (myLocation.getSystemIndex() > 0)
    {
        // Move up by a system if we're at the start of our current system.
        moveToSystem(myLocation.getSystemIndex() - 1, true);

        // Move to the last barline if possible.
        const System &newSystem = myLocation.getSystem();
        const size_t count = newSystem.getBarlines().size();
        if (count > 2)
            moveToPosition(newSystem.getBarlines()[count - 2].getPosition());
    }
}
示例#6
0
void autonomousFcns(int Btn4, int startPos)
{
	switch(Btn4)
		{
		case 256:
		moveAtAngle(motor1, pot1, 15, 500, 3, startPos, 0.5, 0.25, 0.75, 0.5);
		break;

		case 1024:
		moveToPosition(motor3, pot2, 30, 2048, 3, 1024, 512, 0.7, 0.35);
		break;
		}
}
示例#7
0
void autonomousFcns(int Btn4)
{
	switch(Btn4)
		{
		case 1024: //8D
		servoCount = 0;
		moveToPosition(motor1, pot2, 3500, 120, 3, 512, 256, 0.8, 0.5);
		motor[servo1] = 60;
		motor[servo2] = -60;
		motor[servo3] = -127;
		motor[servo4] = -127;
		break;
		}
}
示例#8
0
void KNMusicDetailTooltip::showTooltip(const QPoint &position)
{
    //Set the position.
    moveToPosition(position);
    //Show the tooltip box if it didn't display before.
    if(!isVisible())
    {
        show();
    }
    //Reset the fade out counter.
    resetCounter();
    //Start the fade out counter.
    m_fadeOutCounter->start();
}
示例#9
0
void autonomousFcns(int Btn4)
{
	switch(Btn4)
	{
	case 256:
	moveAtAngle(motor1, pot1, 15, 500, 3, x, 0.5, 0.25, 0.75, 0.5);
	break;

	case 1024:
	moveToPosition(motor3, pot2, 30, 2048, 3, 1024, 512, 0.7, 0.35);}
	break;

	default:
	wait1Msec(3);
	}
示例#10
0
bool Caret::moveToNextBar()
{
    const Barline *nextBar = myLocation.getSystem().getNextBarline(
                myLocation.getPositionIndex());
    if (!nextBar)
        return false;

    // Move into the next system if necessary.
    if (*nextBar == myLocation.getSystem().getBarlines().back())
        return moveToSystem(myLocation.getSystemIndex() + 1, true);
    else
    {
        moveToPosition(nextBar->getPosition());
        return true;
    }
}
示例#11
0
void Enemy1::moving()
{
	if (currentGoal != currentSquare[FIRST_SQUARE_ID])
	{

		if (posX_ != destX || posY_ != destY)
		{
			moveToPosition(destX, destY);

			if (posX_ == destX && posY_ == destY && !path.empty())
			{
				changeSquare(getLocationRow(path.back()), getLocationCol(path.back()));
				Row_ = getLocationRow(currentSquare[FIRST_SQUARE_ID]);
				Col_ = getLocationCol(currentSquare[FIRST_SQUARE_ID]);
			}
		}
		else
		{	
				findDestination();
		}
	}
}
示例#12
0
void Dxl::moveToDegree(double degree, unsigned int device_id)
{
    moveToPosition(degree / POSITION_TO_DEGREE, device_id);
}
示例#13
0
void sbsRobSys::robotAccuracyTest(position pos[5], 
							   char* filename, int noOfStep)
{
	vector<double> temp[30];
	position step;
	moveToPosition(pos[0]);

	moveJointTo(pos[0].joint_1, pos[0].joint_2, pos[0].joint_3, pos[0].joint_4, pos[0].joint_5, pos[0].joint_6);
	
	for (int i = 0; i<4; i++)
	{
		step.joint_1 = (pos[i+1].joint_1-pos[i].joint_1)/noOfStep;
		step.joint_2 = (pos[i+1].joint_2-pos[i].joint_2)/noOfStep;
		step.joint_3 = (pos[i+1].joint_3-pos[i].joint_3)/noOfStep;
		step.joint_4 = (pos[i+1].joint_4-pos[i].joint_4)/noOfStep;
		step.joint_5 = (pos[i+1].joint_5-pos[i].joint_5)/noOfStep;
		step.joint_6 = (pos[i+1].joint_6-pos[i].joint_6)/noOfStep;
		for(int j = 0; j < noOfStep; j++)
		{
			updateJoint();
			updateTCP();
			temp[0].push_back(m_robot.m_joint[0]);
			temp[1].push_back(m_robot.m_joint[1]);
			temp[2].push_back(m_robot.m_joint[2]);
			temp[3].push_back(m_robot.m_joint[3]);
			temp[4].push_back(m_robot.m_joint[4]);
			temp[5].push_back(m_robot.m_joint[5]);
			temp[6].push_back(m_robot.m_tcp.o.x);
			temp[7].push_back(m_robot.m_tcp.o.y);
			temp[8].push_back(m_robot.m_tcp.o.z);
			temp[9].push_back(m_robot.m_tcpEuler.x);
			temp[10].push_back(m_robot.m_tcpEuler.y);
			temp[11].push_back(m_robot.m_tcpEuler.z);
			temp[12].push_back(step.joint_1);
			temp[13].push_back(step.joint_2);
			temp[14].push_back(step.joint_3);
			temp[15].push_back(step.joint_4);
			temp[16].push_back(step.joint_5);
			temp[17].push_back(step.joint_6);

			moveJointBy(step.joint_1, step.joint_2, step.joint_3, step.joint_4, step.joint_5, step.joint_6);
			boost::this_thread::sleep(boost::posix_time::seconds(5));
			updateJoint();
			updateTCP();
			temp[18].push_back(m_robot.m_joint[0]);
			temp[19].push_back(m_robot.m_joint[1]);
			temp[20].push_back(m_robot.m_joint[2]);
			temp[21].push_back(m_robot.m_joint[3]);
			temp[22].push_back(m_robot.m_joint[4]);
			temp[23].push_back(m_robot.m_joint[5]);
			temp[24].push_back(m_robot.m_tcp.o.x);
			temp[25].push_back(m_robot.m_tcp.o.y);
			temp[26].push_back(m_robot.m_tcp.o.z);
			temp[27].push_back(m_robot.m_tcpEuler.x);
			temp[28].push_back(m_robot.m_tcpEuler.y);
			temp[29].push_back(m_robot.m_tcpEuler.z);
			cout << i << " " << j << endl;
		}
	}
	
	char* option;
	FILE* processed = NULL;
	option = "w";

	processed = fopen(filename,option);

	if (processed == NULL)
	{
		printf("Error: Opening file\n");
		return;
	}
	for (unsigned int k = 0; k < temp[0].size(); k++)
	{
		for(int l = 0; l < 30; l++)
		{
			fprintf(processed, "%f,", temp[l][k]);
		}
		fprintf(processed, "\n");
	}

	fclose(processed);
}
示例#14
0
void Motor::moveRelativePosition(const short& speed, const int& deltaPos)
{
	moveToPosition(speed, Private::Motor::instance()->backEMF(m_port) + deltaPos);
}
示例#15
0
void GerberGenerator::drawLine(const Point& start, const Point& end,
                               const UnsignedLength& width) noexcept {
  setCurrentAperture(mApertureList->setCircle(width, UnsignedLength(0)));
  moveToPosition(start);
  linearInterpolateToPosition(end);
}
示例#16
0
void Caret::moveToEndPosition()
{
    moveToPosition(getLastPosition());
}
示例#17
0
void Caret::moveToStartPosition()
{
    moveToPosition(0);
}
示例#18
0
void Motor::moveRelativePosition(short speed, int deltaPos)
{
	moveToPosition(speed, Private::get_motor_bemf(m_port, nullptr) + deltaPos);
}
示例#19
0
void Dxl::moveToRadian(double radian, unsigned int device_id)
{
    moveToPosition(radian / POSITION_TO_RADIAN, device_id);
}
示例#20
0
task main()
{
 int x = SensorValue[pot1];
 int y = SensorValue[pot2];

 while(true)
  {
   //assign values to buttons to change value of BtnX
   if (vexRT[Btn5U] == 1){
     BtnX = BtnX + 1;}

   if (vexRT[Btn5D] == 1){
     BtnX = BtnX + 2;}

   if (vexRT[Btn7U] == 1){
     BtnX = BtnX + 4;}

   if (vexRT[Btn7L] == 1){
     BtnX = BtnX + 8;}

   if (vexRT[Btn7D] == 1){
     BtnX = BtnX + 16;}

   if (vexRT[Btn7R] == 1){
     BtnX = BtnX + 32;}

   if (vexRT[Btn6U] == 1){
     BtnX = BtnX + 64;}

   if (vexRT[Btn6D] == 1){
     BtnX = BtnX + 128;}

   if (vexRT[Btn8U] == 1){
     BtnX = BtnX + 256;}

   if (vexRT[Btn8L] == 1){
     BtnX = BtnX + 512;}

   if (vexRT[Btn8D] == 1){
     BtnX = BtnX + 1024;}

   if (vexRT[Btn8R] == 1){
     BtnX = BtnX + 2048;}

   if ((vexRT[Btn7D] == 0)&&(vexRT[Btn7U] == 0)&&(vexRT[Btn7L] == 0)&&(vexRT[Btn7R] == 0)
     &&(vexRT[Btn8D] == 0)&&(vexRT[Btn8U] == 0)&&(vexRT[Btn8L] == 0)&&(vexRT[Btn8R] == 0)
     &&(vexRT[Btn5U] == 0)&&(vexRT[Btn5D] == 0)&&(vexRT[Btn6U] == 0)&&(vexRT[Btn6D] == 0)){
     BtnX = 0;}

   twoServos (servo1, servo2, BtnX);
   clawOpenCloseCenter (servo1, servo2, servo3, servo4, BtnX);

   //joystick ch1 controls servo
    if((vexRT[Ch1] <= -40) && (vexRT[Ch1] > -80))
		{
			stepServo(servo1, -1);
		}
		else if((vexRT[Ch1] <= -80) && (vexRT[Ch1] > -110))
		{
			stepServo(servo1, -2);
		}
		else if(vexRT[Ch1] <= -110)
		{
			stepServo(servo1, -3);
		}

		if((vexRT[Ch1] >= 40) && (vexRT[Ch1] < 80))
		{
			stepServo(servo1, 1);
		}
		else if((vexRT[Ch1] >= 80) && (vexRT[Ch1] < 110))
		{
			stepServo(servo1, 2);
		}
		else if(vexRT[Ch1] >= 110)
		{
			stepServo(servo1, 3);
		}

		motor[motor3] = vexRT[Ch2];
		limMotor(motor1, lim1, 0);

	  moveAtAngle(motor1, pot1, 15, 500, 3, x, 0.5, 0.25, 0.75, 0.5);
	  moveToPosition(motor2, pot2, 30, 2048, 3, 1024, 512, 0.7, 0.35);
	}
}
示例#21
0
uint8_t NMX::gotoEnd()
{
	return moveToPosition(endPos);
}
示例#22
0
void InterlinearChunkEditor::moveToLine(int line)
{
    line--; // zero-index it
    moveToPosition( (line / mChunkSize) * mChunkSize );
}
示例#23
0
void InterlinearChunkEditor::previous()
{
    moveToPosition( mPosition - mChunkSize );
}
示例#24
0
void InterlinearChunkEditor::next()
{
    moveToPosition( mPosition + mChunkSize );
}
示例#25
0
uint8_t NMX::gotoStart()
{
	return moveToPosition(0);
}
示例#26
0
void Caret::moveHorizontal(int offset)
{
    moveToPosition(myLocation.getPositionIndex() + offset);
}
示例#27
0
文件: Walker.cpp 项目: ourgames/dc208
void Walker::nextMove(int currentSeq)
{
    int startSeq = currentSeq;
    //int targetSeq = 0;
    int prevSeq = mCurrentSeq;
    vector<CCPoint> path;
    vector<int> seqs;
    float spd = 40;
    if (m_icon == "b020")
    {
        spd = 50;
    }
    auto iter = mPointsInPathGraph.find(startSeq);
    
    setSoldierPosition(iter->second.point);
    
    for(int i = 0; i < 2; i++)
    {
        iter = mPointsInPathGraph.find(startSeq);
        
        
        if(iter != mPointsInPathGraph.end())
        {
            path.push_back(iter->second.point);
            seqs.push_back(startSeq);
            
            int availableTargetNum = iter->second.connectedPointSeqs.size();
            int randomTargetIndex = 0;
            if (availableTargetNum > 1)
            {
                randomTargetIndex = rand() % (availableTargetNum);
                //if(iter->second.connectedPointSeqs[randomTargetIndex] == mCurrentSeq)
                if(iter->second.connectedPointSeqs[randomTargetIndex] == prevSeq)
                {
                    if (randomTargetIndex == 0)
                    {
                        randomTargetIndex = randomTargetIndex + 1;
                    }
                    else if(randomTargetIndex == (availableTargetNum -1))
                    {
                        randomTargetIndex = randomTargetIndex - 1;
                    }
                    else
                    {
                        int secondRandom = rand() % (2);
                        if(secondRandom == 0)
                            randomTargetIndex = randomTargetIndex - 1;
                        else
                            randomTargetIndex = randomTargetIndex + 1;
                    }
                    
                }
                
            }
            prevSeq = startSeq;
            startSeq = iter->second.connectedPointSeqs[randomTargetIndex];
        }
        
        
    }
    //moveToPosition(currentSeq, prevSeq, path, 0, spd);
    moveToPosition(seqs, path, 0, spd);
}
示例#28
0
/********************************************************************
 * Function:        void ProcessIO(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        This function is a place holder for other user
 *                  routines. It is a mixture of both USB and
 *                  non-USB tasks.
 *
 * Note:            None
 *******************************************************************/
void ProcessIO(void)
{
    
    // User Application USB tasks
    if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) return;

    //Check if we have received an OUT data packet from the host
    if(!HIDRxHandleBusy(USBOutHandle))
    {
        
        //We just received a packet of data from the USB host.
        //Check the first byte of the packet to see what command the host
        //application software wants us to fulfill.
        switch (ReceivedDataBuffer[0]) {
            case 0x01: // System Commands
                switch (ReceivedDataBuffer[1]) {
                    case 0x01: // System Commands
                        // Copy any waiting debug text to the send data buffer
                        ToSendDataBuffer[0] = 0xFF;
                        // Transmit the response to the host
                        if (!HIDTxHandleBusy(USBInHandle)) {
                            USBInHandle = HIDTxPacket(HID_EP, (BYTE*) & ToSendDataBuffer[0], 64);
                        }
                        break;


                    default: // Unknown command received
                        break;
                }
                break;

            case 0x02: // Feeder Commands
                switch (ReceivedDataBuffer[1]) {
                    case 0x02: // Feeder Status
                        if (FeederStatus() == 1){
                            ToSendDataBuffer[0] = 0x01;
                        }
                        else{
                            ToSendDataBuffer[0] = 0x00;
                        }
                        // Transmit the response to the host
                        if (!HIDTxHandleBusy(USBInHandle)) {
                            USBInHandle = HIDTxPacket(HID_EP, (BYTE*) & ToSendDataBuffer[0], 64);
                        }
                        break;

                    case 0x03: // Go to feeder
                        if ((ReceivedDataBuffer[2] >= 0) && (ReceivedDataBuffer[2] <= 16)){
                            moveToPosition(ReceivedDataBuffer[2]);
                        }
                        break;

                    case 0x04: // Picker Up
                        PickerUp();
                        break;

                    case 0x05: // Zero Feeder
                        ZeroFeeder();
                        break;
                     case 0x06: // Picker Down
                         PickerDown();
                        break;
                     case 0x07: // Set Picker Port Output
                        pickerBusval = ((ReceivedDataBuffer[3] << 8) | ReceivedDataBuffer[2]);
                        pickerBus = pickerBusval;
                        break;
                     case 0x08: // Go to feeder
                        if ((ReceivedDataBuffer[2] > 0) && (ReceivedDataBuffer[2] <= 16)){
                            moveToPositionWithoutPick(ReceivedDataBuffer[2]);
                        }
                        break;

                    default: // Unknown command received
                        break;

                }
            break;
            case 0x03: // Vacuum and Vibration Commands
                
                switch (ReceivedDataBuffer[1]) {
                    case 0x01: // Vacuum 1 set
                        if (ReceivedDataBuffer[2] == 0x01){
                            setVac1on;
                        }
                        else{
                            setVac1off;
                        }
                        break;

                    case 0x02: // Vacuum 2 set
                        if (ReceivedDataBuffer[2] == 0x01){
                            setVac2on;
                        }
                        else{
                            setVac2off;
                        }
                        break;

                    case 0x03: // Vibration Motor set
                        if (ReceivedDataBuffer[2] == 0x01){
                           SetDCOC1PWM(vibrationmotor_duty_cycle);
                           vibrationrunning = 1;
                        }
                        else{
                           SetDCOC1PWM(0);
                           vibrationrunning = 0;
                        }
                        break;
                    case 0x04: // Vacuum 1 status
                        if (vac1running == 1){
                            ToSendDataBuffer[0] = 0x01;
                        }
                        else{
                           ToSendDataBuffer[0] = 0x00;
                        }
                        // Transmit the response to the host
                        if (!HIDTxHandleBusy(USBInHandle)) {
                            USBInHandle = HIDTxPacket(HID_EP, (BYTE*) & ToSendDataBuffer[0], 64);
                        }
                        break;
                    case 0x05: // Vacuum 2 status
                        if (vac2running == 1){
                            ToSendDataBuffer[0] = 0x01;
                        }
                        else{
                           ToSendDataBuffer[0] = 0x00;
                        }
                        // Transmit the response to the host
                        if (!HIDTxHandleBusy(USBInHandle)) {
                            USBInHandle = HIDTxPacket(HID_EP, (BYTE*) & ToSendDataBuffer[0], 64);
                        }
                        break;
                    case 0x06: // Vibration Motor status
                        if (vibrationrunning == 1){
                            ToSendDataBuffer[0] = 0x01;
                        }
                        else{
                           ToSendDataBuffer[0] = 0x00;
                        }
                        // Transmit the response to the host
                        if (!HIDTxHandleBusy(USBInHandle)) {
                            USBInHandle = HIDTxPacket(HID_EP, (BYTE*) & ToSendDataBuffer[0], 64);
                        }
                        break;
                    case 0x07: // Vibration Motor status
                        vibrationmotor_duty_cycle = ReceivedDataBuffer[2] * 4;
                        if (vibrationrunning == 1){
                            SetDCOC1PWM(vibrationmotor_duty_cycle);
                        }
                        break;

                    default: // Unknown command received
                        break;

                }
                break;
            case 0x04: // LED Commands
                switch (ReceivedDataBuffer[1]) {
                    case 0x01: // LED Base Camera on/off
                        if (ReceivedDataBuffer[2] == 0x01){
                            SetDCOC2PWM(led1_duty_cycle);
                            led1running = 1;
                        }else{
                           SetDCOC2PWM(0);
                           led1running = 0;
                        }
                        break;

                    case 0x02: // LED Base Camera PWM set
                        led1_duty_cycle = ReceivedDataBuffer[2] * 4;
                        if (led1running == 1){
                            SetDCOC2PWM(led1_duty_cycle);
                        }
                        break;

                    case 0x03: // LED Head Camera on/off
                        if (ReceivedDataBuffer[2] == 0x01){
                            SetDCOC3PWM(led2_duty_cycle);
                            led2running = 1;
                        }else{
                           SetDCOC3PWM(0);
                           led2running = 0;
                        }
                        break;

                    case 0x04: // LED Head Camera PWM set
                        led2_duty_cycle = ReceivedDataBuffer[2] * 4;
                        if (led2running == 1){
                            SetDCOC3PWM(led2_duty_cycle);
                        }
                        break;
                    case 0x05: // LED Base Status
                        if (led1running == 1){
                            ToSendDataBuffer[0] = 0x01;
                        }
                        else{
                           ToSendDataBuffer[0] = 0x00;
                        }
                        // Transmit the response to the host
                        if (!HIDTxHandleBusy(USBInHandle)) {
                            USBInHandle = HIDTxPacket(HID_EP, (BYTE*) & ToSendDataBuffer[0], 64);
                        }

                        break;
                    case 0x06: // LED Head Status
                        if (led2running == 1){
                            ToSendDataBuffer[0] = 0x01;
                        }
                        else{
                           ToSendDataBuffer[0] = 0x00;
                        }
                        // Transmit the response to the host
                        if (!HIDTxHandleBusy(USBInHandle)) {
                            USBInHandle = HIDTxPacket(HID_EP, (BYTE*) & ToSendDataBuffer[0], 64);
                        }


                        break;

                    default: // Unknown command received
                        break;
                }
                break;



            default: // Unknown command received
                break;
        }
        //Re-arm the OUT endpoint, so we can receive the next OUT data packet
        //that the host may try to send us.
        USBOutHandle = HIDRxPacket(HID_EP, (BYTE*)&ReceivedDataBuffer, 64);
    }


}//end ProcessIO