Example #1
0
/**
 * The last direction the encoder value changed.
 *
 * @param aSlot The digital module slot for the A Channel on the encoder
 * @param aChannel The channel on the digital module for the A Channel of the encoder
 * @param bSlot The digital module slot for the B Channel on the encoder
 * @param bChannel The channel on the digital module for the B Channel of the encoder
 * @return The last direction the encoder value changed.
 */
bool GetEncoderDirection(UINT32 aSlot, UINT32 aChannel, UINT32 bSlot, UINT32 bChannel)
{
	Encoder *encoder = AllocateEncoder(aSlot, aChannel, bSlot, bChannel);
	if (encoder != NULL)
		return encoder->GetDirection();
	else
		return false;
}
Example #2
0
/**
 * Determine if the encoder is stopped.
 * Using the MaxPeriod value, a boolean is returned that is true if the encoder is considered
 * stopped and false if it is still moving. A stopped encoder is one where the most recent pulse
 * width exceeds the MaxPeriod.
 *
 * @param aChannel The channel on the digital module for the A Channel of the encoder
 * @param bChannel The channel on the digital module for the B Channel of the encoder
 * @return True if the encoder is considered stopped.
 */
bool GetEncoderStopped(UINT32 aChannel, UINT32 bChannel)
{
	Encoder *encoder = AllocateEncoder(aChannel, bChannel);
	if (encoder != NULL)
		return encoder->GetStopped();
	else
		return false;
}
Example #3
0
/**
 * Get the current rate of the encoder.
 * Units are distance per second as scaled by the value from SetEncoderDistancePerPulse().
 * 
 * @return The current rate of the encoder.
 *
 * @param aSlot The digital module slot for the A Channel on the encoder
 * @param aChannel The channel on the digital module for the A Channel of the encoder
 * @param bSlot The digital module slot for the B Channel on the encoder
 * @param bChannel The channel on the digital module for the B Channel of the encoder
  */
double GetEncoderRate(UINT32 aSlot, UINT32 aChannel, UINT32 bSlot, UINT32 bChannel)
{
	Encoder *encoder = AllocateEncoder(aSlot, aChannel, bSlot, bChannel);
	if (encoder != NULL)
		return encoder->GetRate();
	else
		return 0.0;
}
Example #4
0
/**
 * Gets the current count.
 * Returns the current count on the Encoder.
 * This method compensates for the decoding type.
 *
 * @deprecated Use GetEncoderDistance() in favor of this method.  This returns unscaled pulses and GetDistance() scales using value from SetEncoderDistancePerPulse().
 *
 * @return Current count from the Encoder.
 * 
 * @param aChannel The channel on the digital module for the A Channel of the encoder
 * @param bChannel The channel on the digital module for the B Channel of the encoder
 */
INT32 GetEncoder(UINT32 aChannel, UINT32 bChannel)
{
	Encoder *encoder = AllocateEncoder(aChannel, bChannel);
	if (encoder != NULL)
		return encoder->Get();
	else
		return 0;
}
Example #5
0
/**
 * Returns the period of the most recent pulse.
 * Returns the period of the most recent Encoder pulse in seconds.
 * This method compenstates for the decoding type.
 * 
 * @deprecated Use GetEncoderRate() in favor of this method.  This returns unscaled periods and GetEncoderRate() scales using value from SetEncoderDistancePerPulse().
 *
 * @return Period in seconds of the most recent pulse.
 * 
 * @param aChannel The channel on the digital module for the A Channel of the encoder
 * @param bChannel The channel on the digital module for the B Channel of the encoder
 */
double GetEncoderPeriod(UINT32 aChannel, UINT32 bChannel)
{
	Encoder *encoder = AllocateEncoder(aChannel, bChannel);
	if (encoder != NULL)
		return encoder->GetPeriod();
	else
		return 0.0;
}
Example #6
0
void x265_encoder_log(x265_encoder* enc, int argc, char **argv)
{
    if (enc)
    {
        Encoder *encoder = static_cast<Encoder*>(enc);
        encoder->writeLog(argc, argv);
    }
}
Example #7
0
/**
 * Start the encoder counting.
 *
 * @param aSlot The digital module slot for the A Channel on the encoder
 * @param aChannel The channel on the digital module for the A Channel of the encoder
 * @param bSlot The digital module slot for the B Channel on the encoder
 * @param bChannel The channel on the digital module for the B Channel of the encoder
 */
void StartEncoder(UINT32 aSlot, UINT32 aChannel, UINT32 bSlot, UINT32 bChannel)
{
	Encoder *encoder = AllocateEncoder(aSlot, aChannel, bSlot, bChannel);
	if (encoder != NULL)
	{
		encoder->Start();
	}
}
Example #8
0
/**
 * Get the distance the robot has driven since the last reset.
 * 
 * @return The distance driven since the last reset as scaled by the value from SetEncoderDistancePerPulse().
 *
 * @param aChannel The channel on the digital module for the A Channel of the encoder
 * @param bChannel The channel on the digital module for the B Channel of the encoder
 */
double GetEncoderDistance(UINT32 aChannel, UINT32 bChannel)
{
	Encoder *encoder = AllocateEncoder(aChannel, bChannel);
	if (encoder != NULL)
		return encoder->GetDistance();
	else
		return 0.0;
}
Example #9
0
void x265_encoder_get_stats(x265_encoder *enc, x265_stats *outputStats, uint32_t statsSizeBytes)
{
    if (enc && outputStats)
    {
        Encoder *encoder = static_cast<Encoder*>(enc);
        encoder->fetchStats(outputStats, statsSizeBytes);
    }
}
Example #10
0
void MainWindow::on_pushButton_clicked()
{
    Encoder encoder;
    int e,d,n;
    encoder.generate_passwords(e,d,n);
    ui->lineE->setText(QString::number(e));
    ui->lineD->setText(QString::number(d));
    ui->lineN->setText(QString::number(n));
}
Storage::Record SubresourcesEntry::encodeAsStorageRecord() const
{
    Encoder encoder;
    encoder << m_subresources;

    encoder.encodeChecksum();

    return { m_key, m_timeStamp, { encoder.buffer(), encoder.bufferSize() } , { } };
}
Example #12
0
	float RawControl::averageEncoders()
	{
		float traveled;
		traveled=(((abs(wheelEncoderFR->Get()))+(abs(wheelEncoderFL->Get()))+(abs(wheelEncoderBR->Get()))+(abs(wheelEncoderBL->Get())))/4);
		traveled/=250;
		traveled=traveled * 8 * 3.14;	
		traveled=fabs(traveled);
		return traveled;
	}
Example #13
0
File: api.cpp Project: VIasai/x265
x265_encoder *x265_encoder_open(x265_param *p)
{
    if (!p)
        return NULL;

    Encoder* encoder = NULL;
    x265_param* param = PARAM_NS::x265_param_alloc();
    x265_param* latestParam = PARAM_NS::x265_param_alloc();
    if (!param || !latestParam)
        goto fail;

    memcpy(param, p, sizeof(x265_param));
    x265_log(param, X265_LOG_INFO, "HEVC encoder version %s\n", PFX(version_str));
    x265_log(param, X265_LOG_INFO, "build info %s\n", PFX(build_info_str));

    x265_setup_primitives(param, param->cpuid);

    if (x265_check_params(param))
        goto fail;

    if (x265_set_globals(param))
        goto fail;

    encoder = new Encoder;
    if (!param->rc.bEnableSlowFirstPass)
        PARAM_NS::x265_param_apply_fastfirstpass(param);

    // may change params for auto-detect, etc
    encoder->configure(param);
    // may change rate control and CPB params
    if (!enforceLevel(*param, encoder->m_vps))
        goto fail;

    // will detect and set profile/tier/level in VPS
    determineLevel(*param, encoder->m_vps);

    if (!param->bAllowNonConformance && encoder->m_vps.ptl.profileIdc == Profile::NONE)
    {
        x265_log(param, X265_LOG_INFO, "non-conformant bitstreams not allowed (--allow-non-conformance)\n");
        goto fail;
    }

    encoder->create();
    encoder->m_latestParam = latestParam;
    memcpy(latestParam, param, sizeof(x265_param));
    if (encoder->m_aborted)
        goto fail;

    x265_print_params(param);
    return encoder;

fail:
    delete encoder;
    PARAM_NS::x265_param_free(param);
    PARAM_NS::x265_param_free(latestParam);
    return NULL;
}
Example #14
0
/**
 * Writes a description of the graph to the given stream, using the Dot 
 * language.
 * The method allows for both directed graphs and non-directed graphs, the
 * latter are required for drawing purposes (since Dot will not produce the
 * arrow heads and the splines terminate before reaching the nodes).
 * @param	str			The stream to write to
 * @param	sType		Either "graph" or "digraph"
 * @param	sEdge		The edge connector ("--" or "->")
 * @param	bWriteCall	true to write call information, false otherwise
 */
void GraphWidget::write(QTextStream& str, const QString& sType, 
	const QString& sEdge, bool bWriteCall)
{
	QFont font;
	QDictIterator<GraphNode> itr(m_dictNodes);
	GraphEdge* pEdge;
	Encoder enc;
	
	font = Config().getFont(KScopeConfig::Graph);

	// Header
	str << sType << " G {\n";
	
	// Graph attributes
	str << "\tgraph [rankdir=" << Config().getGraphOrientation() << ", "
		<< "kscope_zoom=" << m_dZoom 
		<< "];\n";
	
	// Default node attributes
	str << "\tnode [shape=box, height=\"0.01\", style=filled, "
		<< "fillcolor=\"" << Config().getColor(KScopeConfig::GraphNode).name()
		<< "\", "
		<< "fontcolor=\"" << Config().getColor(KScopeConfig::GraphText).name()
		<< "\", "
		<< "fontname=\"" << font.family() << "\", "
		<< "fontsize=" << QString::number(font.pointSize())
		<< "];\n";
	
	// Iterate over all nodes
	for (; itr.current(); ++itr) {
		// Write a node
		str << "\t" << itr.current()->getFunc() << ";\n";
		
		// Iterate over all edges leaving this node		
		QDictIterator<GraphEdge> itrEdge(itr.current()->getOutEdges());
		for (; itrEdge.current(); ++itrEdge) {
			pEdge = itrEdge.current();
			str << "\t" << pEdge->getHead()->getFunc() << sEdge
				<< pEdge->getTail()->getFunc();
				
			// Write call information
			if (bWriteCall) {
				str << " ["
					<< "kscope_file=\"" << pEdge->getFile() << "\","
					<< "kscope_line=" << pEdge->getLine() << ","
					<< "kscope_text=\"" << enc.encode(pEdge->getText()) << "\"" 
					<< "]";
			}
			
			str << ";\n";
		}
	}
	
	// Close the graph
	str << "}\n";
}
Example #15
0
x265_encoder *x265_encoder_open(x265_param *p)
{
    if (!p)
        return NULL;

    x265_param *param = X265_MALLOC(x265_param, 1);
    if (!param)
        return NULL;

    memcpy(param, p, sizeof(x265_param));
    x265_log(param, X265_LOG_INFO, "HEVC encoder version %s\n", x265_version_str);
    x265_log(param, X265_LOG_INFO, "build info %s\n", x265_build_info_str);

    x265_setup_primitives(param, param->cpuid);

    if (x265_check_params(param))
        return NULL;

    if (x265_set_globals(param))
        return NULL;

    Encoder *encoder = new Encoder;
    if (!param->rc.bEnableSlowFirstPass)
        x265_param_apply_fastfirstpass(param);

    // may change params for auto-detect, etc
    encoder->configure(param);
    
    // may change rate control and CPB params
    if (!enforceLevel(*param, encoder->m_vps))
    {
        delete encoder;
        return NULL;
    }

    // will detect and set profile/tier/level in VPS
    determineLevel(*param, encoder->m_vps);

    if (!param->bAllowNonConformance && encoder->m_vps.ptl.profileIdc == Profile::NONE)
    {
        x265_log(param, X265_LOG_INFO, "non-conformant bitstreams not allowed (--allow-non-conformance)\n");
        delete encoder;
        return NULL;
    }

    encoder->create();
    if (encoder->m_aborted)
    {
        delete encoder;
        return NULL;
    }

    x265_print_params(param);

    return encoder;
}
/*
 *  motionType parameter:
 *  1 - move forward
 *  2 - move backward
 *  3 - turn left
 *  4 - turn right
 */
void MotorController::updatePositionAndHeading(int motionType)
{
  double leftMotorPositionDelta = leftEncoder.getPosition() - _leftMotorLastPosition;
  double rightMotorPositionDelta = rightEncoder.getPosition() - _rightMotorLastPosition;

  _leftMotorLastPosition = leftEncoder.getPosition();
  _rightMotorLastPosition = rightEncoder.getPosition();

  double deltaPosition = (leftMotorPositionDelta + rightMotorPositionDelta) / 2;

  if (motionType == 1 || motionType == 2)
  {
    _position.setX(_position.getX() + deltaPosition * COS[round(_heading)]);
    _position.setY(_position.getY() + deltaPosition * SIN[round(_heading)]);

    // If robot turns slightly to left when moving forward or backward
    // if (leftMotorPositionDelta < rightMotorPositionDelta)
    // {
    //   double average = rightMotorPositionDelta - leftMotorPositionDelta;
    //   double radians = average / ROTATION_CIRCUMFERENCE;
    //   double degrees = radians * RAD_TO_DEG;   

    //   // _heading = motionType == 1 ? _heading + degrees : _heading - degrees;
    // }
    // else
    // {
    //   double average = leftMotorPositionDelta - rightMotorPositionDelta;
    //   double radians = average / ROTATION_CIRCUMFERENCE;
    //   double degrees = radians * RAD_TO_DEG;   

    //   // _heading = motionType == 1 ? _heading - degrees : _heading + degrees;
    // }
  }
  else
  {
    // Robot turns left
    if (motionType == 3)
    {
      double average = (rightMotorPositionDelta - leftMotorPositionDelta) / 2;
      double radians = average / ROTATION_RADIUS;
      double degrees = radians * RAD_TO_DEG;

      _heading += degrees;
    }
    else
    {
      double average = (leftMotorPositionDelta - rightMotorPositionDelta) / 2;
      double radians = average / ROTATION_RADIUS;
      double degrees = radians * RAD_TO_DEG;

      _heading -= degrees;
    }
  }
  _heading = _heading < 0 ? 360 + _heading : _heading;
  _heading = _heading > 360 ? _heading - 360 : _heading;
}
Example #17
0
	//void StartAutomaticCapture(std::shared_ptr<USBCamera>cam0);
	void TeleopPeriodic() {
//		ui.GetData(&wui);
//		m_tank.Drive(wui.LeftSpeed, wui.RightSpeed);
//
//		m_shooter.Rotate(wui.RotateSpeed*3); //70 degrees per second at full value
//		m_shooter.Lift(wui.LiftSpeed*1.193); //4 seconds for 180 degree revolution
//		if(wui.SpinUp) {
//			m_shooter.Spinup(1);
//		}
//		if(wui.Shoot) {
//			m_shooter.Shoot();
//		}
//		if(wui.Pickup) {
//			m_shooter.Pickup();
//		}
//
//		m_suspension.SetFrontLeft(wui.DropFL);
//		m_suspension.SetBackLeft(wui.DropBL);
//		m_suspension.SetFrontRight(wui.DropFR);
//		m_suspension.SetBackRight(wui.DropBR);

//		m_leddar.GetDetections();
//		m_shooter.Update();
		//float RTrigger = m_lStick->GetRawAxis(3);
		//float LTrigger = m_lStick->GetRawAxis(2);

		//if (m_PWMTalonLeftFrontTop == .5)
		//if (abs(RTrigger) < 0.2)
			//RTrigger = 0;
		//if (abs(LTrigger) < 0.2)
			//LTrigger = 0;
		float leftSpeed = m_lStick->GetRawAxis(1);
		float rightSpeed = m_lStick->GetRawAxis(5);
		if (abs(leftSpeed) < 0.2)
			leftSpeed = 0;
		if (abs(rightSpeed) < 0.2)
			rightSpeed = 0;
		//float LTrigger = m_lStick->GetRawAxis(3);
		//float RTrigger = m_lStick->GetRawAxis(2);
		SmartDashboard::PutNumber("Left Stick", leftSpeed);
		SmartDashboard::PutNumber("Right Stick", rightSpeed);
		//SmartDashboard::PutNumber("L Trigger", LTrigger);
		//SmartDashboard::PutNumber("R Trigger", RTrigger);
		SmartDashboard::PutNumber("Left Encoder", leftEncoder->Get());
		SmartDashboard::PutNumber("Right Encoder", rightEncoder->Get());
		drive->TankDrive(leftSpeed, rightSpeed, true);
		//drive->TankDrive(RTrigger, LTrigger, true);
		LEFTDRIVE1->Set(leftSpeed);
		LEFTDRIVE2->Set(leftSpeed);
		RIGHTDRIVE1->Set(rightSpeed);
		RIGHTDRIVE2->Set(rightSpeed);
		//m_PWMTalonLeftFrontTop->Set(RTrigger);
		//m_PWMTalonRightFrontTop->Set(RTrigger);
		//m_PWMTalonRightRearTop->Set(LTrigger);
		//m_PWMTalonLeftRearTop->Set(LTrigger);
	}
Example #18
0
static void encodeElement(Encoder& encoder, const FormDataElement& element)
{
    encoder.encodeUInt32(static_cast<uint32_t>(element.m_type));

    switch (element.m_type) {
    case FormDataElement::Type::Data:
        encoder.encodeBytes(reinterpret_cast<const uint8_t*>(element.m_data.data()), element.m_data.size());
        return;

    case FormDataElement::Type::EncodedFile:
        encoder.encodeString(element.m_filename);
        encoder.encodeString(element.m_generatedFilename);
        encoder.encodeBool(element.m_shouldGenerateFile);
        encoder.encodeInt64(element.m_fileStart);
        encoder.encodeInt64(element.m_fileLength);
        encoder.encodeDouble(element.m_expectedFileModificationTime);
        return;

    case FormDataElement::Type::EncodedBlob:
        encoder.encodeString(element.m_url.string());
        return;
    }

    ASSERT_NOT_REACHED();
}
Example #19
0
 static void encode(Encoder& e, kaa_configuration::_configuration_avsc_Union__0__ v) {
     e.encodeUnionIndex(v.idx());
     switch (v.idx()) {
     case 0:
         e.encodeNull();
         break;
     case 1:
         avro::encode(e, v.get_uuidT());
         break;
     }
 }
Example #20
0
static bool MFAAC_GetExtraData(void *data, uint8_t **extra_data, size_t *size)
{
	Encoder *enc = static_cast<Encoder *>(data);

	UINT32 length;
	if (enc->ExtraData(extra_data, &length)) {
		*size = length;
		return true;
	}
	return false;
}
Example #21
0
	PnumaticArmTest (void):
	stick(1)
	,up(7,7)
	,down(7,8)
	,enc(1,2)
	,pid(.045,.00000,.16)
	,low(.05)
	{
		enc.SetReverseDirection(true);
		enc.Start();
	}
Example #22
0
void print_encoder(Encoder& e, int ind)
{
	printf("%sEncoder Id %d type %s\n", width(ind, "").c_str(),
	       e.id(), e.get_encoder_type().c_str());

	if (opts.print_props)
		print_properties(e, ind+2);

	if (opts.recurse)
		for (auto cc : e.get_possible_crtcs())
			print_crtc(*cc, ind + 2);
}
Example #23
0
void MainWindow::on_actionDecode_Image_triggered()
{
    // extract image hidden in imageBefore:
    Encoder encoder;
    int d = ui->lineD->text().toInt(),
        n = ui->lineN->text().toInt();

    imageAfter = encoder.decodeImage(imageBefore,d,n);

    //and show it to the user
    showImageAfter();
}
Example #24
0
static bool
EncodeConst(Encoder& e, WasmAstConst& c)
{
    switch (c.val().type()) {
      case ValType::I32:
        return e.writeExpr(Expr::I32Const) &&
               e.writeVarU32(c.val().i32());
      default:
        break;
    }
    MOZ_CRASH("Bad value type");
}
Example #25
0
	void OperatorControl(void)
	{
		digEncoder.Start();
		const double ppsTOrpm = 60.0/250.0;	//This converts from Pos per Second to Rotations per Minute (See second number on back of encoder to replace 250 if you need it)
		
		while (IsOperatorControl())
		{
			SmartDashboard::PutNumber("Digital Encoder RPM", digEncoder.GetRate()*ppsTOrpm);
			Wait(0.1);
		}
		digEncoder.Stop();
	}
Example #26
0
void x265_encoder_close(x265_encoder *enc)
{
    if (enc)
    {
        Encoder *encoder = static_cast<Encoder*>(enc);

        encoder->stopJobs();
        encoder->printSummary();
        encoder->destroy();
        delete encoder;
        ATOMIC_DEC(&g_ctuSizeConfigured);
    }
}
Example #27
0
	/**
	 * Runs the motors with arcade steering.
	 */
	void OperatorControl(void)
	{
       encoder.Start();
		while (IsEnabled())
		{
			float controlv = control.GetVoltage();
			motor.Set(controlv/5); //get's voltage from control and divides it by 5
			double rate = encoder.GetRate();
			double distance = encoder.GetDistance();
			printf ("%f %f \n", rate, distance);

		}
	}
Example #28
0
	void TeleopInit(void) {
		printf("Robot teleop initializing...\n");

		GetWatchdog().Feed();
		
		compressor->Start();
		kicker->SafeReset();
		
		leftDrivetrainEncoder->Start();
		rightDrivetrainEncoder->Start();
		
		printf("Robot teleop initialization complete.\n");
	}
Example #29
0
	RobotSystem(void):
		robotInted(false)
		,stick(1)		// as they are declared above.
		,stick2(2)
		,line1(10)
		,line2(11)
		,line3(12)
		//,camera(AxisCamera::GetInstance())
		,updateCAN("CANUpdate",(FUNCPTR)UpdateCAN)
		,cameraTask("CAMERA", (FUNCPTR)CameraTask)
		,compressor(14,1)
		,EncArm(2,3)
		,EncClaw(5,6)
		,PIDArm(.04,0,0) // .002, .033
		,PIDClaw(.014,.0000014,0)
		,LowArm(.1)
		/*
		,MiniBot1(4)
		,MiniBot2(2)
		,ClawGrip(3)
		*/
		,MiniBot1a(8,1)
		,MiniBot1b(8,2)
		,MiniBot2a(8,3)
		,MiniBot2b(8,4)
		,ClawOpen(8, 8)
		,ClawClose(8,7)
		,LimitClaw(7)
		,LimitArm(13)
	{
	//	myRobot.SetExpiration(0.1);
		GetWatchdog().SetEnabled(false);
		GetWatchdog().SetExpiration(1);
		compressor.Start();
		debug("Waiting to init CAN");
		Wait(2);
		
		Dlf = new CANJaguar(6,CANJaguar::kSpeed);
		Dlb = new CANJaguar(3,CANJaguar::kSpeed);
		Drf = new CANJaguar(7,CANJaguar::kSpeed);
		Drb = new CANJaguar(2,CANJaguar::kSpeed);
		arm1 = new CANJaguar(5);
		arm1_sec = new CANJaguar(8);
		arm2 = new CANJaguar(4);
		
		
		EncArm.SetDistancePerPulse(.00025);
		EncClaw.SetDistancePerPulse(.00025);
		EncClaw.SetReverseDirection(false);
		EncArm.SetReverseDirection(true);
		EncArm.Reset();
		EncClaw.Reset();
		
		
		updateCAN.Start((int)this);
		//cameraTask.Start((int)this);
		EncArm.Start();
		EncClaw.Start();
		debug("done initing");
	}
Example #30
0
 static void encode(Encoder& e, _configuration_schema_Union__4__ v) {
     e.encodeUnionIndex(v.idx());
     switch (v.idx()) {
     case 0:
         avro::encode(e, v.get_strategyT());
         break;
     case 1:
         avro::encode(e, v.get_unchangedT());
         break;
     case 2:
         e.encodeNull();
         break;
     }
 }