YouBotJointParameterReadOnly.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #include "youbot/YouBotJointParameterReadOnly.hpp"
00052 namespace youbot {
00053
00054 YouBotJointParameterReadOnly::YouBotJointParameterReadOnly() {
00055
00056
00057 }
00058
00059 YouBotJointParameterReadOnly::~YouBotJointParameterReadOnly() {
00060
00061
00062 }
00063
00064 ActualMotorVoltage::ActualMotorVoltage() {
00065
00066 this->name = "ActualMotorVoltage";
00067 this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00068
00069 }
00070
00071 ActualMotorVoltage::~ActualMotorVoltage() {
00072
00073
00074 }
00075
00076 void ActualMotorVoltage::getParameter(quantity<electric_potential>& parameter) const {
00077
00078 parameter = this->value;
00079
00080 }
00081
00082 void ActualMotorVoltage::toString(std::string& value) {
00083
00084 std::stringstream ss;
00085 ss << this->name << ": " << this->value;
00086 value = ss.str();
00087
00088 }
00089
00090 void ActualMotorVoltage::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00091
00092 message.stctOutput.commandNumber = msgType;
00093 message.stctOutput.moduleAddress = DRIVE;
00094 message.stctOutput.typeNumber = 151;
00095
00096
00097
00098 }
00099
00100 void ActualMotorVoltage::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00101
00102 if (message.stctOutput.commandNumber == message.stctInput.commandNumber && message.stctInput.status == NO_ERROR) {
00103 double temp = message.stctInput.value;
00104 this->value = temp/100.0 * volt;
00105 }
00106
00107 }
00108
00109 ErrorAndStatus::ErrorAndStatus() {
00110
00111 this->name = "ErrorAndStatus";
00112 this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00113
00114 }
00115
00116 ErrorAndStatus::~ErrorAndStatus() {
00117
00118
00119 }
00120
00121 void ErrorAndStatus::getParameter(unsigned int& parameter) const {
00122
00123 parameter = this->value;
00124 this->parseYouBotErrorFlags();
00125
00126 }
00127
00128 void ErrorAndStatus::toString(std::string& value) {
00129
00130 std::stringstream ss;
00131 ss << this->name << ": " << this->value;
00132 value = ss.str();
00133
00134 }
00135
00136 void ErrorAndStatus::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00137
00138 message.stctOutput.commandNumber = msgType;
00139 message.stctOutput.moduleAddress = DRIVE;
00140 message.stctOutput.typeNumber = 156;
00141
00142
00143
00144 }
00145
00146 void ErrorAndStatus::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00147
00148 if (message.stctOutput.commandNumber == message.stctInput.commandNumber && message.stctInput.status == NO_ERROR) {
00149 this->value = message.stctInput.value;
00150 }
00151
00152 }
00153
00154 void ErrorAndStatus::parseYouBotErrorFlags() const {
00155
00156
00157
00158 std::string errorMessage;
00159
00160
00161
00162 if (value & OVER_CURRENT) {
00163 LOG(warning) << errorMessage << "over current";
00164
00165 }
00166
00167 if (value & UNDER_VOLTAGE) {
00168 LOG(warning) << errorMessage << "under voltage";
00169
00170 }
00171
00172 if (value & OVER_VOLTAGE) {
00173 LOG(warning) << errorMessage << "over voltage";
00174
00175 }
00176
00177 if (value & OVER_TEMPERATURE) {
00178 LOG(warning) << errorMessage << "over temperature";
00179
00180 }
00181
00182 if (value & MOTOR_HALTED) {
00183 LOG(info) << errorMessage << "is halted";
00184
00185 }
00186
00187 if (value & HALL_SENSOR_ERROR) {
00188 LOG(warning) << errorMessage << "hall sensor problem";
00189
00190 }
00191
00192
00193
00194
00195
00196
00197 if (value & VELOCITY_MODE) {
00198 LOG(info) << errorMessage << "velocity mode active";
00199
00200 }
00201
00202 if (value & POSITION_MODE) {
00203 LOG(info) << errorMessage << "position mode active";
00204
00205 }
00206
00207 if (value & TORQUE_MODE) {
00208 LOG(info) << errorMessage << "torque mode active";
00209
00210 }
00211
00212 if (value & POSITION_REACHED) {
00213 LOG(info) << errorMessage << "position reached";
00214
00215 }
00216
00217 if (value & INITIALIZED) {
00218 LOG(info) << errorMessage << "is initialized";
00219
00220 }
00221
00222 if (value & TIMEOUT) {
00223 LOG(warning) << errorMessage << "timeout";
00224
00225 }
00226
00227 if (value & I2T_EXCEEDED) {
00228 LOG(warning) << errorMessage << "I2t exceeded";
00229
00230 }
00231
00232
00233 }
00234
00235 PositionError::PositionError() {
00236
00237 this->name = "PositionError";
00238 this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00239
00240 }
00241
00242 PositionError::~PositionError() {
00243
00244
00245 }
00246
00247 void PositionError::getParameter(quantity<plane_angle>& parameter) const {
00248
00249 parameter = this->value;
00250
00251 }
00252
00253 void PositionError::toString(std::string& value) {
00254
00255 std::stringstream ss;
00256 ss << this->name << ": " << this->value;
00257 value = ss.str();
00258
00259 }
00260
00261 void PositionError::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00262
00263 message.stctOutput.commandNumber = msgType;
00264 message.stctOutput.moduleAddress = DRIVE;
00265 message.stctOutput.typeNumber = 226;
00266
00267
00268 }
00269
00270 void PositionError::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00271
00272 double temp = (int)message.stctInput.value;
00273 value = (temp / storage.encoderTicksPerRound) * storage.gearRatio * (2.0 * M_PI) * radian;
00274
00275 }
00276
00277 PositionErrorSum::PositionErrorSum() {
00278
00279 this->name = "PositionErrorSum";
00280 this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00281
00282 }
00283
00284 PositionErrorSum::~PositionErrorSum() {
00285
00286
00287 }
00288
00289 void PositionErrorSum::getParameter(quantity<plane_angle>& parameter) const {
00290
00291 parameter = this->value;
00292
00293 }
00294
00295 void PositionErrorSum::toString(std::string& value) {
00296
00297 std::stringstream ss;
00298 ss << this->name << ": " << this->value;
00299 value = ss.str();
00300
00301 }
00302
00303 void PositionErrorSum::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00304
00305
00306 message.stctOutput.commandNumber = msgType;
00307 message.stctOutput.moduleAddress = DRIVE;
00308 message.stctOutput.typeNumber = 227;
00309
00310
00311
00312 }
00313
00314 void PositionErrorSum::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00315
00316 double temp = (int)message.stctInput.value;
00317 value = (temp / storage.encoderTicksPerRound) * storage.gearRatio * (2.0 * M_PI) * radian;
00318
00319 }
00320
00321 VelocityError::VelocityError() {
00322
00323 this->name = "VelocityError";
00324 this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00325
00326 }
00327
00328 VelocityError::~VelocityError() {
00329
00330
00331 }
00332
00333 void VelocityError::getParameter(quantity<si::angular_velocity>& parameter) const {
00334
00335 parameter = this->value;
00336
00337 }
00338
00339 void VelocityError::toString(std::string& value) {
00340
00341 std::stringstream ss;
00342 ss << this->name << ": " << this->value;
00343 value = ss.str();
00344
00345 }
00346
00347 void VelocityError::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00348
00349
00350 message.stctOutput.commandNumber = msgType;
00351 message.stctOutput.moduleAddress = DRIVE;
00352 message.stctOutput.typeNumber = 228;
00353
00354
00355
00356 }
00357
00358 void VelocityError::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00359
00360 double temp = (int)message.stctInput.value;
00361 this->value = ((temp / 60.0) * storage.gearRatio * 2.0 * M_PI) * radian_per_second;
00362
00363 }
00364
00365 VelocityErrorSum::VelocityErrorSum() {
00366
00367 this->name = "VelocityErrorSum";
00368 this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00369
00370 }
00371
00372 VelocityErrorSum::~VelocityErrorSum() {
00373
00374
00375 }
00376
00377 void VelocityErrorSum::getParameter(quantity<si::angular_velocity>& parameter) const {
00378
00379 parameter = this->value;
00380
00381 }
00382
00383 void VelocityErrorSum::toString(std::string& value) {
00384
00385 std::stringstream ss;
00386 ss << this->name << ": " << this->value;
00387 value = ss.str();
00388
00389 }
00390
00391 void VelocityErrorSum::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00392
00393
00394 message.stctOutput.commandNumber = msgType;
00395 message.stctOutput.moduleAddress = DRIVE;
00396 message.stctOutput.typeNumber = 229;
00397
00398
00399
00400 }
00401
00402 void VelocityErrorSum::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00403
00404 double temp = (int32)message.stctInput.value;
00405 this->value = ((temp / 60.0) * storage.gearRatio * 2.0 * M_PI) * radian_per_second;
00406
00407
00408 }
00409
00410 CurrentError::CurrentError() {
00411
00412 this->name = "CurrentError";
00413 this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00414
00415 }
00416
00417 CurrentError::~CurrentError() {
00418
00419
00420 }
00421
00422 void CurrentError::getParameter(quantity<si::current>& parameter) const {
00423
00424 parameter = this->value;
00425
00426 }
00427
00428 void CurrentError::toString(std::string& value) {
00429
00430 std::stringstream ss;
00431 ss << this->name << ": " << this->value;
00432 value = ss.str();
00433
00434 }
00435
00436 void CurrentError::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00437
00438 message.stctOutput.commandNumber = msgType;
00439 message.stctOutput.moduleAddress = DRIVE;
00440 message.stctOutput.typeNumber = 200;
00441
00442
00443
00444 }
00445
00446 void CurrentError::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00447
00448 if (message.stctOutput.commandNumber == message.stctInput.commandNumber && message.stctInput.status == NO_ERROR) {
00449 double temp = (int)message.stctInput.value;
00450 this->value = temp /1000.0 * ampere;
00451 }
00452
00453 }
00454
00455 CurrentErrorSum::CurrentErrorSum() {
00456
00457 this->name = "CurrentErrorSum";
00458 this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00459
00460 }
00461
00462 CurrentErrorSum::~CurrentErrorSum() {
00463
00464
00465 }
00466
00467 void CurrentErrorSum::getParameter(quantity<si::current>& parameter) const {
00468
00469 parameter = this->value;
00470
00471 }
00472
00473 void CurrentErrorSum::toString(std::string& value) {
00474
00475 std::stringstream ss;
00476 ss << this->name << ": " << this->value;
00477 value = ss.str();
00478
00479 }
00480
00481 void CurrentErrorSum::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00482
00483 message.stctOutput.commandNumber = msgType;
00484 message.stctOutput.moduleAddress = DRIVE;
00485 message.stctOutput.typeNumber = 201;
00486
00487
00488
00489 }
00490
00491 void CurrentErrorSum::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00492
00493 if (message.stctOutput.commandNumber == message.stctInput.commandNumber && message.stctInput.status == NO_ERROR) {
00494 double temp = (int)message.stctInput.value;
00495 this->value = temp /1000.0 * ampere;
00496 }
00497
00498 }
00499
00500 RampGeneratorSpeed::RampGeneratorSpeed() {
00501
00502 this->name = "RampGeneratorSpeed";
00503 this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00504
00505 }
00506
00507 RampGeneratorSpeed::~RampGeneratorSpeed() {
00508
00509
00510 }
00511
00512 void RampGeneratorSpeed::getParameter(quantity<si::angular_velocity>& parameter) const {
00513
00514 parameter = this->value;
00515
00516 }
00517
00518 void RampGeneratorSpeed::toString(std::string& value) {
00519
00520 std::stringstream ss;
00521 ss << this->name << ": " << this->value;
00522 value = ss.str();
00523
00524 }
00525
00526 void RampGeneratorSpeed::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00527
00528
00529 message.stctOutput.commandNumber = msgType;
00530 message.stctOutput.moduleAddress = DRIVE;
00531 message.stctOutput.typeNumber = 13;
00532
00533
00534
00535 }
00536
00537 void RampGeneratorSpeed::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00538
00539 double temp = (int)message.stctInput.value;
00540 this->value = ((temp / 60.0) * storage.gearRatio * 2.0 * M_PI) * radian_per_second;
00541
00542 }
00543
00544 I2tSum::I2tSum() {
00545
00546 this->name = "I2tSum";
00547 this->lowerLimit = 0;
00548 this->upperLimit = INT_MAX;
00549 this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00550
00551 }
00552
00553 I2tSum::~I2tSum() {
00554
00555
00556 }
00557
00558 void I2tSum::getParameter(unsigned int& parameter) const {
00559
00560 parameter = this->value;
00561
00562 }
00563
00564 void I2tSum::setParameter(const unsigned int parameter) {
00565
00566 if (this->lowerLimit > parameter) {
00567 throw std::out_of_range("The parameter exceeds the lower limit");
00568 }
00569 if (this->upperLimit < parameter) {
00570 throw std::out_of_range("The parameter exceeds the upper limit");
00571 }
00572 this->value = parameter;
00573
00574 }
00575
00576 void I2tSum::toString(std::string& value) {
00577
00578 std::stringstream ss;
00579 ss << this->name << ": " << this->value;
00580 value = ss.str();
00581
00582 }
00583
00584 void I2tSum::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00585
00586 message.stctOutput.commandNumber = msgType;
00587 message.stctOutput.moduleAddress = DRIVE;
00588 message.stctOutput.typeNumber = 27;
00589 message.stctOutput.value = value;
00590
00591 }
00592
00593 void I2tSum::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00594
00595 if (message.stctOutput.commandNumber == message.stctInput.commandNumber && message.stctInput.status == NO_ERROR) {
00596 this->value = message.stctInput.value;
00597 }
00598
00599 }
00600
00601 ActualMotorDriverTemperature::ActualMotorDriverTemperature() {
00602
00603 this->name = "ActualMotorDriverTemperature";
00604 this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00605
00606 }
00607
00608 ActualMotorDriverTemperature::~ActualMotorDriverTemperature() {
00609
00610
00611 }
00612
00613 void ActualMotorDriverTemperature::getParameter(quantity<celsius::temperature>& parameter) const {
00614
00615 parameter = this->value;
00616
00617 }
00618
00619 void ActualMotorDriverTemperature::toString(std::string& value) {
00620
00621 std::stringstream ss;
00622 ss << this->name << ": " << this->value;
00623 value = ss.str();
00624
00625 }
00626
00627 void ActualMotorDriverTemperature::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00628
00629 message.stctOutput.commandNumber = msgType;
00630 message.stctOutput.moduleAddress = DRIVE;
00631 message.stctOutput.typeNumber = 152;
00632
00633
00634
00635 }
00636
00637 void ActualMotorDriverTemperature::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00638
00639 if (message.stctOutput.commandNumber == message.stctInput.commandNumber && message.stctInput.status == NO_ERROR) {
00640 double materialConstant = 3434;
00641 double R_NTC = ((double)9011.2/message.stctInput.value) - 2.2;
00642 double nominator = materialConstant * 298.16;
00643 double denominator = materialConstant + (log(R_NTC/10.0) * 298.16);
00644 this->value = ((nominator/denominator) - 273.16) * celsius::degree;
00645 }
00646
00647 }
00648
00649 ActualModuleSupplyCurrent::ActualModuleSupplyCurrent() {
00650
00651 this->name = "ActualModuleSupplyCurrent";
00652 this->parameterType = MOTOR_CONTOLLER_PARAMETER;
00653
00654 }
00655
00656 ActualModuleSupplyCurrent::~ActualModuleSupplyCurrent() {
00657
00658
00659 }
00660
00661 void ActualModuleSupplyCurrent::getParameter(quantity<si::current>& parameter) const {
00662
00663 parameter = this->value;
00664
00665 }
00666
00667 void ActualModuleSupplyCurrent::toString(std::string& value) {
00668
00669 std::stringstream ss;
00670 ss << this->name << ": " << this->value;
00671 value = ss.str();
00672
00673 }
00674
00675 void ActualModuleSupplyCurrent::getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const {
00676
00677 message.stctOutput.commandNumber = msgType;
00678 message.stctOutput.moduleAddress = DRIVE;
00679 message.stctOutput.typeNumber = 157;
00680
00681
00682
00683 }
00684
00685 void ActualModuleSupplyCurrent::setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) {
00686
00687 if (message.stctOutput.commandNumber == message.stctInput.commandNumber && message.stctInput.status == NO_ERROR) {
00688 this->value = (double)message.stctInput.value /1000.0 * ampere;
00689 }
00690
00691 }
00692
00693
00694 }