• 大小: 223KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: 其他
  • 标签: Arduino  

资源简介

Arduino-smartcar_shield.zip,一个多用途和易用的汽车平台,用于业余爱好级项目火星车防护罩,Arduino是一家开源软硬件公司和制造商社区。Arduino始于21世纪初,深受电子制造商的欢迎,Arduino通过开源系统提供了很多灵活性。

资源截图

代码片段和文件信息

#include 
#include 

#include “../../utilities/Utilities.hpp“
#include “DistanceCar.hpp“

namespace
{
const unsigned long kStopAttemptInterval = 100;
const uint8_t kMaxStopAttempts           = 3;
} // namespace

using namespace smartcarlib::constants::car;
using namespace smartcarlib::constants::control;
using namespace smartcarlib::utils;

DistanceCar::DistanceCar(Control& control Odometer& odometer Runtime& runtime)
    : SimpleCar(control)
     mControl(control)
     mOdometerLeft(odometer)
     mOdometerRight(odometer)
     mRuntime(runtime)
     mCruiseControlEnabled{ false }
     mProportional{ 0 }
     mIntegral{ 0 }
     mDerivative{ 0 }
     mFrequency{ 0 }
     mPreviousUpdate{ 0 }
     mTargetSpeed{ 0 }
     mPreviousControlledSpeed{ 0 }
     mIntegratedError{ 0 }
     mPreviousError{ 0 }
{
}

DistanceCar::DistanceCar(Control& control
                         Odometer& odometerLeft
                         Odometer& odometerRight
                         Runtime& runtime)
    : SimpleCar(control)
     mControl(control)
     mOdometerLeft(odometerLeft)
     mOdometerRight(odometerRight)
     mRuntime(runtime)
     mCruiseControlEnabled{ false }
     mProportional{ 0 }
     mIntegral{ 0 }
     mDerivative{ 0 }
     mFrequency{ 0 }
     mPreviousUpdate{ 0 }
     mTargetSpeed{ 0 }
     mPreviousControlledSpeed{ 0 }
     mIntegratedError{ 0 }
     mPreviousError{ 0 }
{
}

long DistanceCar::getDistance()
{
    return areOdometersAttached() ? (mOdometerLeft.getDistance() + mOdometerRight.getDistance()) / 2
                                  : static_cast(kOdometersNotAttachedError);
}

void DistanceCar::setSpeed(float speed)
{
    if (!areOdometersAttached())
    {
        SimpleCar::setSpeed(speed);
        return;
    }
    speed = getConstrain(
        speed static_cast(kMinControlSpeed) static_cast(kMaxControlSpeed));
    // If odometers are directional and cruise control is enabled then we don‘t
    // need to do more since the speed controller will take care of the speed
    if (areOdometersDirectional() && mCruiseControlEnabled)
    {
        mTargetSpeed = speed;
        return;
    }
    // If we need to change direction of movement while the cruise control is
    // enabled then we need to stop the car before proceeding to a different
    // direction since the car cannot determine which direction it is actually
    // moving.
    auto newSpeedAtOppositeDirection         = mTargetSpeed * speed < 0;
    auto changeOfDirectionWhileCruiseControl = mCruiseControlEnabled && newSpeedAtOppositeDirection;
    // Alternatively we also need to stop the car if the supplied speed is ‘0‘
    // and the car is not already stopped.
    auto carIsAlreadyStopped = areAlmostEqual(mTargetSpeed static_cast(kIdleControlSpeed));
    auto carWantsToStop      = areAlmostEqual(speed static_cast(kIdleControlSpeed));
    auto carShouldStop       = carWantsToStop && !carI

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-09-17 22:29  smartcar_shield-master\
     文件          85  2019-09-17 22:29  smartcar_shield-master\.bettercodehub.yml
     文件        2634  2019-09-17 22:29  smartcar_shield-master\.clang-format
     文件          26  2019-09-17 22:29  smartcar_shield-master\.gitattributes
     文件         267  2019-09-17 22:29  smartcar_shield-master\.gitignore
     文件        1684  2019-09-17 22:29  smartcar_shield-master\.travis.yml
     文件        3365  2019-09-17 22:29  smartcar_shield-master\CODE_OF_CONDUCT.md
     文件         747  2019-09-17 22:29  smartcar_shield-master\CONTRIBUTING.md
     目录           0  2019-09-17 22:29  smartcar_shield-master\CmakeModules\
     文件        9212  2019-09-17 22:29  smartcar_shield-master\CmakeModules\CodeCoverage.cmake
     文件       12898  2019-09-17 22:29  smartcar_shield-master\Doxyfile
     文件          38  2019-09-17 22:29  smartcar_shield-master\ISSUE_TEMPLATE.md
     文件        1072  2019-09-17 22:29  smartcar_shield-master\LICENSE
     文件          35  2019-09-17 22:29  smartcar_shield-master\PULL_REQUEST_TEMPLATE.md
     文件        6465  2019-09-17 22:29  smartcar_shield-master\README.md
     目录           0  2019-09-17 22:29  smartcar_shield-master\docs\
     文件           0  2019-09-17 22:29  smartcar_shield-master\docs\.nojekyll
     文件        2319  2019-09-17 22:29  smartcar_shield-master\docs\README.md
     目录           0  2019-09-17 22:29  smartcar_shield-master\examples\
     目录           0  2019-09-17 22:29  smartcar_shield-master\examples\BareMinimum\
     文件         152  2019-09-17 22:29  smartcar_shield-master\examples\BareMinimum\BareMinimum.ino
     目录           0  2019-09-17 22:29  smartcar_shield-master\examples\Car\
     目录           0  2019-09-17 22:29  smartcar_shield-master\examples\Car\DistanceCar\
     文件         846  2019-09-17 22:29  smartcar_shield-master\examples\Car\DistanceCar\DistanceCar.ino
     目录           0  2019-09-17 22:29  smartcar_shield-master\examples\Car\FullSerialControl\
     文件         639  2019-09-17 22:29  smartcar_shield-master\examples\Car\FullSerialControl\FullSerialControl.ino
     目录           0  2019-09-17 22:29  smartcar_shield-master\examples\Car\HeadingCar\
     文件         612  2019-09-17 22:29  smartcar_shield-master\examples\Car\HeadingCar\HeadingCar.ino
     目录           0  2019-09-17 22:29  smartcar_shield-master\examples\Car\PidControllerMonitor\
     文件        1352  2019-09-17 22:29  smartcar_shield-master\examples\Car\PidControllerMonitor\PidControllerMonitor.ino
     目录           0  2019-09-17 22:29  smartcar_shield-master\examples\Car\SerialControlServoESC\
............此处省略169个文件信息

评论

共有 条评论