资源简介
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个文件信息
相关资源
- ADNS-3080光流传感器测试程序Arduino
- EESkill NRF24L01 无线模块用户手册
- Arduino nano 工程文件
- Arduino教程 Lesson 之--自制风扇
- 基于Arduino的智能环境监控系统设计
- 基于Arduino和Machtalk的温棚环境监测系
- arduino pca9685多舵机同时控制案例
- arduino技术内幕
- Arduino电子设计实战指南.零基础篇_超
- 物联网智能家居平台DIY:ARDUINO 物联网
- 实验1.zip arduino跑马灯led灯实验,串口
- opencat所有资料.zip
- arduino主机,stm8从机。I2C测试 。每次
- DS18B20_Serial_println.ino
- ps2手柄arduino库文件
- 基于手机蓝牙的arduino遥控小车
- arduino中的can库函数
- 密码+指纹锁资料包.rar
- 贝壳物联arduino esp8266 demo版本
- HMC5883L罗盘指南针模块库文件及中英文
- arduino 小贱钟源码及教程
- Atom-TMC2208Pilot在Arduino上运行的应用程
- 写字机制作方案
- PID-增量式PID和位置式PID算法实现和
- Building Wireless Sensor Networks Using Arduin
- vc控制Arduino,实现串口通信
- Arduino入门经典
- Arduino所有库.zip
- 基于STM32和arduino的MPU9250九轴传感器代
- GY-9960模块Keil 和Arduino驱动程序
评论
共有 条评论