当前位置: 首页>>代码示例>>C++>>正文


C++ PID::getKi方法代码示例

本文整理汇总了C++中PID::getKi方法的典型用法代码示例。如果您正苦于以下问题:C++ PID::getKi方法的具体用法?C++ PID::getKi怎么用?C++ PID::getKi使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PID的用法示例。


在下文中一共展示了PID::getKi方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dispatch

void Calibration::dispatch(FramedSerialMessage* request) {
	uint8_t cmd = request->getCommand();
	
	if (cmd == MESSAGE_SAVE_CALIBRATION){
		chiindii->saveConfig();
	}
	else if (cmd == MESSAGE_LOAD_CALIBRATION){
		chiindii->loadConfig();
	}
	else if (cmd == MESSAGE_CALIBRATE_IMU){
		wdt_enable(WDTO_8S);	//This takes a bit of time... we need to make sure the WDT doesn't reset.
		chiindii->getMpu6050()->calibrate();
		wdt_enable(WDTO_120MS);
	}
#if defined MAHONY
	//TODO Add support for Mahoney tuning
#elif defined MADGWICK
	else if (cmd == MESSAGE_MADGWICK_TUNING){
		Madgwick* m = chiindii->getImu();
		if (request->getLength() == 0){
			double data[] = { m->getBeta() };
			FramedSerialMessage response(MESSAGE_MADGWICK_TUNING, (uint8_t*) data, 4);
			chiindii->sendMessage(&response);
		}
		else {
			double* data = (double*) request->getData();
			m->setBeta(data[0]);
		}
	}
#endif
	else if (cmd == MESSAGE_RATE_PID_TUNING){
		PID* x = chiindii->getRateX();
		PID* y = chiindii->getRateY();
		PID* z = chiindii->getRateZ();
		if (request->getLength() == 0){
			double data[] = { 
				x->getKp(), x->getKi(), x->getKd(),
				y->getKp(), y->getKi(), y->getKd(),
				z->getKp(), z->getKi(), z->getKd()
			};
			FramedSerialMessage response(MESSAGE_RATE_PID_TUNING, (uint8_t*) data, 36);
			chiindii->sendMessage(&response);
		}
		else {
			double* data = (double*) request->getData();
			x->setTunings(data[0], data[1], data[2]);
			y->setTunings(data[3], data[4], data[5]);
			z->setTunings(data[6], data[7], data[8]);
		}
	}
	else if (cmd == MESSAGE_ANGLE_PID_TUNING){
		PID* x = chiindii->getAngleX();
		PID* y = chiindii->getAngleY();
		PID* z = chiindii->getAngleZ();
		if (request->getLength() == 0){
			double data[] = { 
				x->getKp(), x->getKi(), x->getKd(),
				y->getKp(), y->getKi(), y->getKd(),
				z->getKp(), z->getKi(), z->getKd()
			};
			FramedSerialMessage response(MESSAGE_ANGLE_PID_TUNING, (uint8_t*) data, 36);
			chiindii->sendMessage(&response);
		}
		else {
			double* data = (double*) request->getData();
			x->setTunings(data[0], data[1], data[2]);
			y->setTunings(data[3], data[4], data[5]);
			z->setTunings(data[6], data[7], data[8]);
		}
	}
	else if (cmd == MESSAGE_THROTTLE_PID_TUNING){
		PID* t = chiindii->getGforce();
		if (request->getLength() == 0){
			double data[] = { 
				t->getKp(), t->getKi(), t->getKd()
			};
			FramedSerialMessage response(MESSAGE_THROTTLE_PID_TUNING, (uint8_t*) data, 12);
			chiindii->sendMessage(&response);
		}
		else {
			double* data = (double*) request->getData();
			t->setTunings(data[0], data[1], data[2]);
		}
	}
}
开发者ID:TAGood827,项目名称:microcontroller-projects,代码行数:85,代码来源:Calibration.cpp


注:本文中的PID::getKi方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。