资源简介
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个文件信息
相关资源
- 基于arduino的温度检测和显示
- TFmini_Plus I²C版在Arduino上的例程及参考
- pid算法-arduino
- HidEmuKbd.bin
- arduino编程库函数合集
- arduino JSON数据格式库
- proteus arduino仿真库
- arduino 多个程序一起工作程序
- arduino蜂鸣器和光控灯实验报告
- Arduino自动浇花系统_一路继电器控制水
- Arduino小车控制程序含遥控+寻迹+避障
- TM1637显示器arduino库文件
- arduino rfid库函数
- 基于arduino的循迹小车不含有PID算法
- 基于arduino的循迹小车含有PID算法
- 基于arduino的无线温湿度传输系统
- Arduino多任务同时进行.rar
- arduino 机械臂 画圆程序 通过Arduino控制
- PS2+ arduino+接线图+源码
- CH340G-CH340通用驱动 支持win10/win7 64位驱
- 智能小车黑线循迹&超声波避障综合实
- arduino光电编码器程序
- Arduino智能鱼缸
- arduino pid循迹代码.zip
- Arduino红外传感器库文件
- DHT11库文件和
- arduino pid 调节 平衡小车代码
- Arduino全地形小车代码
- Arduino红外循迹小车
- 基于Arduino的温湿度系统设计
评论
共有 条评论