Ejemplo n.º 1
0
void turnBack(){
	clear_motor_position_counter(LM);
	clear_motor_position_counter(RM);
	mtp(LM, 1500, ONE_CIRCLE);
	mtp(RM, -1500, -1 * ONE_CIRCLE);
	bmd(LM);
	bmd(RM);
}
Ejemplo n.º 2
0
void turnRight(){
	clear_motor_position_counter(LM);
	clear_motor_position_counter(RM);
	mtp(LM, 1500,HALF_CIRCLE);
	mtp(RM, -1500, -1 * HALF_CIRCLE);
	bmd(LM);
	bmd(RM);
}
Ejemplo n.º 3
0
// move:
void moveStraight(int distance)
{
	clear_motor_position_counter(c_ileftMotor);
	clear_motor_position_counter(c_irightMotor);
	mtp(c_ileftMotor, c_iforwardSpeed, distance);
	mtp(c_irightMotor, c_iforwardSpeed, distance);
	bmd(c_ileftMotor);
	bmd(c_irightMotor);
}
Ejemplo n.º 4
0
void collectBall(){
	motor(FM, FM_COLLECT);
	clear_motor_position_counter(LM);
	clear_motor_position_counter(RM);
	mtp(LM, LM_SP_STR2, 800);
	mtp(RM, RM_SP_STR2, 800);
	bmd(LM);
	bmd(RM);
	motor(FM, 0);
	// move and collect rest balls
}
Ejemplo n.º 5
0
void collectBall(){
	motor(FM, FM_COLLECT);
	clear_motor_position_counter(LM);
	clear_motor_position_counter(RM);
	mtp(LM, 1500, 1000);
	mtp(RM, 1500, 1000);
	bmd(LM);
	bmd(RM);
	motor(FM, 0);
	msleep(2500);
	// move and collect rest balls
}
/*
 * Class:     Motor
 * Method:    mtp
 * Signature: (III)I
 */
JNIEXPORT jint JNICALL Java_cbccore_low_Motor_mtp(JNIEnv* env, jobject obj, jint port, jint speed, jint delta)
{
#ifdef CBC
    return mtp(port, speed, delta);
#else
    printf("Java_cbccore_low_Motor_mtp stub\n");
    return -1;
#endif
}
Ejemplo n.º 7
0
void turn_left()
{

	motor(0,0);
	motor(2,0);
	clear_motor_position_counter(2);
	mtp(2, 1500, 1300);
	block_motor_done(2);

}
Ejemplo n.º 8
0
void turn_right()
{

	motor(0,0);
	motor(2,0);
	clear_motor_position_counter(0);
	mtp(0, 1000, 850); // this is what got changed from 1050 to 950 to 850
	block_motor_done(0);

}
Ejemplo n.º 9
0
void turn_right()
{

	motor(0,0);
	motor(2,0);
	clear_motor_position_counter(0);
	mtp(0, 1000, 1050); 
	block_motor_done(0);

}
Ejemplo n.º 10
0
void moveFor(){
	int frontDis = analog_et(FSS);
	int backDis = analog_et(BSS);
	int disDiff = frontDis - backDis;
	int turnLM = MOVE_FOR_TP - disDiff * KDp;
	int turnRM = MOVE_FOR_TP + disDiff * KDp;
	
	while(frontDis > 295){
		motor(LM, turnLM);
		motor(RM, turnRM);
		frontDis = analog_et(FSS);
		backDis = analog_et(BSS);
		printf("%d\t%d\n", frontDis, backDis);
		disDiff = frontDis - backDis;
		turnLM = MOVE_BACK_TP - disDiff * KDp;
		turnRM = MOVE_BACK_TP + disDiff * KDp;
	}
	clear_motor_position_counter(LM);
	clear_motor_position_counter(RM);
	mtp(LM, 800, 500);
	mtp(RM, 800, 500);
	bmd(LM);
	bmd(RM);
	clear_motor_position_counter(LM);
	clear_motor_position_counter(RM);
	mtp(LM, 800, 260);
	mtp(RM, -800, -260);
	bmd(LM);
	bmd(RM);
	while(analog(RSS) < RSS_OFFSET){
		motor(RM, 82);
		motor(LM, 90);
	}
	while(analog(RSS) > RSS_OFFSET){
		motor(RM, 82);
		motor(LM, 90);
	}
	while(analog(RSS) < RSS_OFFSET){
		motor(RM, 82);
		motor(LM, 90);
	}
}
Ejemplo n.º 11
0
void FORTE_MotorPOS::executeEvent(int pa_nEIID){
  //TODO MotorPOS add error checks and  messages
  QO() = QI();
  switch (pa_nEIID){
    case scm_nEventINITID:
      if(true == QI()){
        if(PORT() <= 3){
          libcbc_init(); //TODO: only call once //initialises the CBC Library :)
          m_nPort = PORT();
          QO() = true; /* Turned on and No Error */
        }
        else{
          QO() = false;
        }
      }
      sendOutputEvent(scm_nEventINITOID);
      break;
    case scm_nEventREQID:
      if(true == QI()){
        if(true == RELPOS())
          mrp(m_nPort, 1000, POS());
        else
          mtp(m_nPort, 1000, POS());
      }
      sendOutputEvent(scm_nEventCNFID);
      break;
    case scm_nEventRSPID:
//TODO respond to IND
      break;
    case scm_nEventSTOPID:
      if(true == QI()){
        motor(m_nPort, 0);
        if(true == FREEZE()){
          freeze(m_nPort);
        }
        else{
          off(m_nPort);
        }
      }
      sendOutputEvent(scm_nEventSTOPOID);
      break;
  }
}
void QgsPointPatternFillSymbolLayer::startRender( QgsSymbolV2RenderContext& context )
{
  //render 3 rows and columns in one go to easily incorporate displacement
  double width = context.outputPixelSize( mDistanceX ) * 2.0;
  double height = context.outputPixelSize( mDistanceY ) * 2.0;

  QImage patternImage( width, height, QImage::Format_ARGB32 );
  patternImage.fill( 0 );

  if ( mMarkerSymbol )
  {
    QPainter p( &patternImage );

    //marker rendering needs context for drawing on patternImage
    QgsRenderContext pointRenderContext;
    pointRenderContext.setPainter( &p );
    pointRenderContext.setRasterScaleFactor( 1.0 );
    pointRenderContext.setScaleFactor( context.renderContext().scaleFactor() * context.renderContext().rasterScaleFactor() );
    QgsMapToPixel mtp( context.renderContext().mapToPixel().mapUnitsPerPixel() / context.renderContext().rasterScaleFactor() );
    pointRenderContext.setMapToPixel( mtp );
    pointRenderContext.setForceVectorOutput( false );

    mMarkerSymbol->setOutputUnit( context.outputUnit() );
    mMarkerSymbol->startRender( pointRenderContext );

    //render corner points
    mMarkerSymbol->renderPoint( QPointF( 0, 0 ), context.feature(), pointRenderContext );
    mMarkerSymbol->renderPoint( QPointF( width, 0 ), context.feature(), pointRenderContext );
    mMarkerSymbol->renderPoint( QPointF( 0, height ), context.feature(), pointRenderContext );
    mMarkerSymbol->renderPoint( QPointF( width, height ), context.feature(), pointRenderContext );

    //render displaced points
    double displacementPixelX = context.outputPixelSize( mDisplacementX );
    double displacementPixelY = context.outputPixelSize( mDisplacementY );
    mMarkerSymbol->renderPoint( QPointF( width / 2.0, -displacementPixelY ), context.feature(), pointRenderContext );
    mMarkerSymbol->renderPoint( QPointF( displacementPixelX, height / 2.0 ), context.feature(), pointRenderContext );
    mMarkerSymbol->renderPoint( QPointF( width / 2.0 + displacementPixelX, height / 2.0 - displacementPixelY ), context.feature(), pointRenderContext );
    mMarkerSymbol->renderPoint( QPointF( width + displacementPixelX, height / 2.0 ), context.feature(), pointRenderContext );
    mMarkerSymbol->renderPoint( QPointF( width / 2.0, height - displacementPixelY ), context.feature(), pointRenderContext );

    mMarkerSymbol->stopRender( pointRenderContext );
  }

  if ( !doubleNear( context.alpha(), 1.0 ) )
  {
    QImage transparentImage = patternImage.copy();
    QgsSymbolLayerV2Utils::multiplyImageOpacity( &transparentImage, context.alpha() );
    mBrush.setTextureImage( transparentImage );
  }
  else
  {
    mBrush.setTextureImage( patternImage );
  }
  QTransform brushTransform;
  brushTransform.scale( 1.0 / context.renderContext().rasterScaleFactor(), 1.0 / context.renderContext().rasterScaleFactor() );
  mBrush.setTransform( brushTransform );

  if ( mOutline )
  {
    mOutline->startRender( context.renderContext() );
  }
}