00001 #include <ros/ros.h>
00002 #include <../include/neo_relayboard_node.h>
00003
00004
00005
00006 int neo_relayboard_node::init()
00007 {
00008 if (n.hasParam("ComPort"))
00009 {
00010 n.getParam("ComPort", sComPort);
00011 ROS_INFO("Loaded ComPort parameter from parameter server: %s",sComPort.c_str());
00012 }
00013
00014 n.param("message_timeout", relayboard_timeout_, 2.0);
00015 n.param("requestRate", requestRate, 25.0);
00016
00017 n.param("protocol_version", protocol_version_, 1);
00018
00019
00020 n.param("voltage_min", voltage_min_, 23.0);
00021 n.param("voltage_max", voltage_max_, 27.5);
00022 n.param("charge_nominal", charge_nominal_, 80.0);
00023 charge_nominal_ = charge_nominal_ * 360;
00024 n.param("voltage_nominal", voltage_nominal_, 24.0);
00025
00026 current_voltage = 0;
00027
00028 m_SerRelayBoard = new SerRelayBoard();
00029 readConfig(protocol_version_);
00030 m_SerRelayBoard->init();
00031 ROS_INFO("Opened Relayboard at ComPort = %s", sComPort.c_str());
00032
00033
00034 n.param("drive1/CANId", motorCanIdent[0], 1);
00035 n.param("drive2/CANId", motorCanIdent[1], 2);
00036 n.param("drive3/CANId", motorCanIdent[2], 3);
00037 n.param("drive4/CANId", motorCanIdent[3], 4);
00038 n.param<std::string>("drive1/joint_name", joint_names[0], "MotorRight");
00039 n.param<std::string>("drive2/joint_name", joint_names[1], "MotorLeft");
00040 n.param<std::string>("drive3/joint_name", joint_names[2], "MotorRearRight");
00041 n.param<std::string>("drive4/joint_name", joint_names[3], "MotorRearLeft");
00042
00043 n.getParam("hasMotorRight",activeModule[DRIVE1]);
00044 n.getParam("hasMotorLeft",activeModule[DRIVE2]);
00045 n.getParam("hasMotorRearRight",activeModule[DRIVE3]);
00046 n.getParam("hasMotorRearLeft",activeModule[DRIVE4]);
00047
00048 topicSub_SetRelayStates = n.subscribe("/srb_set_relay_states",1,&neo_relayboard_node::setRelayBoardDigOut, this);
00049 topicPub_SendRelayStates = n.advertise<std_msgs::Int16>("/srb_relay_states",1);
00050
00051 if(activeModule[DRIVE1] == 1 || activeModule[DRIVE2] == 1 || activeModule[DRIVE3] == 1 || activeModule[DRIVE4] == 1)
00052 {
00053 topicPub_drives = n.advertise<sensor_msgs::JointState>("/drive_states",1);
00054 topicSub_drives = n.subscribe("/cmd_drives",1,&neo_relayboard_node::getNewDriveStates, this);
00055 }
00056 n.getParam("hasIOBoard", activeModule[IO_BOARD]);
00057 n.getParam("hasLCDOut", hasLCDOut);
00058 if(hasLCDOut == 1) topicSub_lcdDisplay = n.subscribe("/srb_lcd_display",1,&neo_relayboard_node::getNewLCDOutput, this);
00059
00060 if(activeModule[IO_BOARD] == 1)
00061 {
00062 topicSub_setDigOut = n.subscribe("/srb_io_set_dig_out",1,&neo_relayboard_node::getIOBoardDigOut, this);
00063 topicPub_ioDigIn = n.advertise<std_msgs::Int16>("/srb_io_dig_in",1);
00064 topicPub_ioDigOut = n.advertise<std_msgs::Int16>("/srb_io_dig_out",1);
00065 topicPub_analogIn = n.advertise<neo_msgs::IOAnalogIn>("/srb_io_analog_in",1);
00066
00067 }
00068 n.getParam("hasUSBoard", activeModule[US_BOARD]);
00069 if(activeModule[US_BOARD] == 1)
00070 {
00071 topicPub_usBoard = n.advertise<neo_msgs::USBoard>("/srb_us_measurements",1);
00072 topicSub_startUSBoard = n.subscribe("/srb_start_us_board",1,&neo_relayboard_node::startUSBoard, this);
00073 topicSub_stopUSBoard = n.subscribe("/srb_stop_us_board",1,&neo_relayboard_node::stopUSBoard, this);
00074
00075 }
00076 n.getParam("hasRadarBoard", activeModule[RADAR_BOARD]);
00077 if(activeModule[RADAR_BOARD] == 1) topicPub_radarBoard = n.advertise<neo_msgs::RadarBoard>("/srb_radar_measurements",1);
00078
00079 n.getParam("hasGyroBoard", activeModule[GYRO_BOARD]);
00080 if(activeModule[GYRO_BOARD] == 1)
00081 {
00082 topicPub_gyroBoard = n.advertise<neo_msgs::GyroBoard>("/srb_gyro_measurements",1);
00083 topicSub_zeroGyro = n.subscribe("/srb_zero_gyro",1,&neo_relayboard_node::zeroGyro, this);
00084 }
00085
00086 n.getParam("hasKeyPad", hasKeyPad);
00087 if(hasKeyPad == 1) topicPub_keypad = n.advertise<neo_msgs::Keypad>("/srb_keypad",1);
00088 n.getParam("hasIRSensors", hasIRSensors);
00089 if(hasIRSensors == 1) topicPub_IRSensor = n.advertise<neo_msgs::IRSensors>("/srb_ir_measurements",1);
00090
00091
00092
00093 n.getParam("log", log);
00094 if(log == true)
00095 {
00096 ROS_INFO("Log enabled");
00097 m_SerRelayBoard->enable_logging();
00098 }
00099 else
00100 {
00101 ROS_INFO("Log disabled");
00102 m_SerRelayBoard->disable_logging();
00103 }
00104
00105
00106
00107 EM_stop_status_ = ST_EM_ACTIVE;
00108 duration_for_EM_free_ = ros::Duration(1);
00109 return 0;
00110 }
00111
00112 void neo_relayboard_node::readConfig(int protocol_version_)
00113 {
00114 std::string pathToConf = "";
00115 int iTypeLCD = protocol_version_;
00116 std::string sNumComPort;
00117 int hasMotorRight, hasMotorLeft, hasMotorRearRight, hasMotorRearLeft;
00118 int hasIOBoard;
00119
00120 int hasUSBoard;
00121 int hasRadarBoard;
00122 int hasGyroBoard;
00123 double quickfix1, quickfix2, quickfix3, quickfix4;
00124 DriveParam driveParamLeft, driveParamRight, driveParamRearLeft, driveParamRearRight;
00125
00126
00127 n.getParam("ComPort", sNumComPort);
00128 n.getParam("hasMotorRight", hasMotorRight);
00129 n.getParam("hasMotorLeft", hasMotorLeft);
00130 n.getParam("hasMotorRearRight", hasMotorRearRight);
00131 n.getParam("hasMotorRearLeft", hasMotorRearLeft);
00132 n.getParam("hasIOBoard", hasIOBoard);
00133 n.getParam("hasUSBoard", hasUSBoard);
00134 n.getParam("hasRadarBoard", hasRadarBoard);
00135 n.getParam("hasGyroBoard", hasGyroBoard);
00136
00137
00138 if(n.hasParam("drive1/quickFix")) n.getParam("drive1/quickFix", quickfix1);
00139 else quickfix1 = 1;
00140 if(n.hasParam("drive2/quickFix")) n.getParam("drive2/quickFix", quickfix2);
00141 else quickfix2 = 1;
00142 if(n.hasParam("drive3/quickFix")) n.getParam("drive3/quickFix", quickfix3);
00143 else quickfix3 = 1;
00144 if(n.hasParam("drive4/quickFix")) n.getParam("drive4/quickFix", quickfix4);
00145 else quickfix4 = 1;
00146
00147
00148 int iEncIncrPerRevMot;
00149 double dVelMeasFrqHz;
00150 double dGearRatio, dBeltRatio;
00151 int iSign;
00152 bool bHoming;
00153 double dHomePos, dHomeVel;
00154 int iHomeEvent, iHomeDigIn, iHomeTimeOut;
00155 double dVelMaxEncIncrS, dVelPModeEncIncrS;
00156 double dAccIncrS2, dDecIncrS2;
00157 int iCANId;
00158
00159 n.getParam("drive1/EncIncrPerRevMot", iEncIncrPerRevMot);
00160 n.getParam("drive1/VelMeasFrqHz", dVelMeasFrqHz);
00161 n.getParam("drive1/BeltRatio", dBeltRatio);
00162 n.getParam("drive1/GearRatio", dGearRatio);
00163 n.getParam("drive1/Sign", iSign);
00164 n.getParam("drive1/Homing", bHoming);
00165 n.getParam("drive1/HomePos", dHomePos);
00166 n.getParam("drive1/HomeVel", dHomeVel);
00167 n.getParam("drive1/HomeEvent", iHomeEvent);
00168 n.getParam("drive1/HomeDigIn", iHomeDigIn);
00169 n.getParam("drive1/HomeTimeOut", iHomeTimeOut);
00170 n.getParam("drive1/VelMaxEncIncrS", dVelMaxEncIncrS);
00171 n.getParam("drive1/VelPModeEncIncrS", dVelPModeEncIncrS);
00172 n.getParam("drive1/AccIncrS", dAccIncrS2);
00173 n.getParam("drive1/DecIncrS", dDecIncrS2);
00174 n.getParam("drive1/CANId", iCANId);
00175 driveParamLeft.set( 0,
00176 iEncIncrPerRevMot,
00177 dVelMeasFrqHz,
00178 dBeltRatio, dGearRatio,
00179 iSign,
00180 bHoming, dHomePos, dHomeVel, iHomeEvent, iHomeDigIn, iHomeTimeOut,
00181 dVelMaxEncIncrS, dVelPModeEncIncrS,
00182 dAccIncrS2, dDecIncrS2,
00183 DriveParam::ENCODER_INCREMENTAL,
00184 iCANId,
00185 false, true );
00186
00187 n.getParam("drive2/EncIncrPerRevMot", iEncIncrPerRevMot);
00188 n.getParam("drive2/VelMeasFrqHz", dVelMeasFrqHz);
00189 n.getParam("drive2/BeltRatio", dBeltRatio);
00190 n.getParam("drive2/GearRatio", dGearRatio);
00191 n.getParam("drive2/Sign", iSign);
00192 n.getParam("drive2/Homing", bHoming);
00193 n.getParam("drive2/HomePos", dHomePos);
00194 n.getParam("drive2/HomeVel", dHomeVel);
00195 n.getParam("drive2/HomeEvent", iHomeEvent);
00196 n.getParam("drive2/HomeDigIn", iHomeDigIn);
00197 n.getParam("drive2/HomeTimeOut", iHomeTimeOut);
00198 n.getParam("drive2/VelMaxEncIncrS", dVelMaxEncIncrS);
00199 n.getParam("drive2/VelPModeEncIncrS", dVelPModeEncIncrS);
00200 n.getParam("drive2/AccIncrS", dAccIncrS2);
00201 n.getParam("drive2/DecIncrS", dDecIncrS2);
00202 n.getParam("drive2/CANId", iCANId);
00203 driveParamRight.set( 1,
00204 iEncIncrPerRevMot,
00205 dVelMeasFrqHz,
00206 dBeltRatio, dGearRatio,
00207 iSign,
00208 bHoming, dHomePos, dHomeVel, iHomeEvent, iHomeDigIn, iHomeTimeOut,
00209 dVelMaxEncIncrS, dVelPModeEncIncrS,
00210 dAccIncrS2, dDecIncrS2,
00211 DriveParam::ENCODER_INCREMENTAL,
00212 iCANId,
00213 false, true );
00214
00215
00216 n.getParam("drive3/EncIncrPerRevMot", iEncIncrPerRevMot);
00217 n.getParam("drive3/VelMeasFrqHz", dVelMeasFrqHz);
00218 n.getParam("drive3/BeltRatio", dBeltRatio);
00219 n.getParam("drive3/GearRatio", dGearRatio);
00220 n.getParam("drive3/Sign", iSign);
00221 n.getParam("drive3/Homing", bHoming);
00222 n.getParam("drive3/HomePos", dHomePos);
00223 n.getParam("drive3/HomeVel", dHomeVel);
00224 n.getParam("drive3/HomeEvent", iHomeEvent);
00225 n.getParam("drive3/HomeDigIn", iHomeDigIn);
00226 n.getParam("drive3/HomeTimeOut", iHomeTimeOut);
00227 n.getParam("drive3/VelMaxEncIncrS", dVelMaxEncIncrS);
00228 n.getParam("drive3/VelPModeEncIncrS", dVelPModeEncIncrS);
00229 n.getParam("drive3/AccIncrS", dAccIncrS2);
00230 n.getParam("drive3/DecIncrS", dDecIncrS2);
00231 n.getParam("drive3/CANId", iCANId);
00232 driveParamRearLeft.set( 1,
00233 iEncIncrPerRevMot,
00234 dVelMeasFrqHz,
00235 dBeltRatio, dGearRatio,
00236 iSign,
00237 bHoming, dHomePos, dHomeVel, iHomeEvent, iHomeDigIn, iHomeTimeOut,
00238 dVelMaxEncIncrS, dVelPModeEncIncrS,
00239 dAccIncrS2, dDecIncrS2,
00240 DriveParam::ENCODER_INCREMENTAL,
00241 iCANId,
00242 false, true );
00243
00244
00245 n.getParam("drive4/EncIncrPerRevMot", iEncIncrPerRevMot);
00246 n.getParam("drive4/VelMeasFrqHz", dVelMeasFrqHz);
00247 n.getParam("drive4/BeltRatio", dBeltRatio);
00248 n.getParam("drive4/GearRatio", dGearRatio);
00249 n.getParam("drive4/Sign", iSign);
00250 n.getParam("drive4/Homing", bHoming);
00251 n.getParam("drive4/HomePos", dHomePos);
00252 n.getParam("drive4/HomeVel", dHomeVel);
00253 n.getParam("drive4/HomeEvent", iHomeEvent);
00254 n.getParam("drive4/HomeDigIn", iHomeDigIn);
00255 n.getParam("drive4/HomeTimeOut", iHomeTimeOut);
00256 n.getParam("drive4/VelMaxEncIncrS", dVelMaxEncIncrS);
00257 n.getParam("drive4/VelPModeEncIncrS", dVelPModeEncIncrS);
00258 n.getParam("drive4/AccIncrS", dAccIncrS2);
00259 n.getParam("drive4/DecIncrS", dDecIncrS2);
00260 n.getParam("drive4/CANId", iCANId);
00261 driveParamRearRight.set( 1,
00262 iEncIncrPerRevMot,
00263 dVelMeasFrqHz,
00264 dBeltRatio, dGearRatio,
00265 iSign,
00266 bHoming, dHomePos, dHomeVel, iHomeEvent, iHomeDigIn, iHomeTimeOut,
00267 dVelMaxEncIncrS, dVelPModeEncIncrS,
00268 dAccIncrS2, dDecIncrS2,
00269 DriveParam::ENCODER_INCREMENTAL,
00270 iCANId,
00271 false, true );
00272
00273
00274 m_SerRelayBoard->readConfig( iTypeLCD, pathToConf, sNumComPort, hasMotorRight,
00275 hasMotorLeft, hasMotorRearRight, hasMotorRearLeft,
00276 hasIOBoard, hasUSBoard, hasRadarBoard, hasGyroBoard,
00277 quickfix1, quickfix2, quickfix3, quickfix4, driveParamLeft, driveParamRight,
00278 driveParamRearLeft, driveParamRearRight
00279 );
00280 };
00281
00282 int neo_relayboard_node::requestBoardStatus() {
00283 int ret;
00284
00285
00286 ret = m_SerRelayBoard->sendRequest();
00287
00288 if(ret != SerRelayBoard::NO_ERROR) {
00289 ROS_ERROR("Error in sending message to Relayboard over SerialIO, lost bytes during writing");
00290 }
00291
00292 ret = m_SerRelayBoard->evalRxBuffer();
00293 if(ret==SerRelayBoard::NOT_INITIALIZED) {
00294 ROS_ERROR("Failed to read relayboard data over Serial, the device is not initialized");
00295 relayboard_online = false;
00296 } else if(ret==SerRelayBoard::NO_MESSAGES) {
00297 ROS_ERROR("For a long time, no messages from RelayBoard have been received, check com port!");
00298 if(time_last_message_received_.toSec() - ros::Time::now().toSec() > relayboard_timeout_) {relayboard_online = false;}
00299 } else if(ret==SerRelayBoard::TOO_LESS_BYTES_IN_QUEUE) {
00300
00301 } else if(ret==SerRelayBoard::CHECKSUM_ERROR) {
00302 ROS_ERROR("A checksum error occurred while reading from relayboard data");
00303 } else if(ret==SerRelayBoard::NO_ERROR) {
00304 relayboard_online = true;
00305 relayboard_available = true;
00306 time_last_message_received_ = ros::Time::now();
00307 }
00308
00309 return 0;
00310 }
00311
00312 double neo_relayboard_node::getRequestRate()
00313 {
00314 return requestRate;
00315 }
00316
00318
00319
00320 void neo_relayboard_node::sendEmergencyStopStates()
00321 {
00322
00323 if(!relayboard_available) return;
00324
00325
00326 bool EM_signal;
00327 ros::Duration duration_since_EM_confirmed;
00328 neo_msgs::EmergencyStopState EM_msg;
00329
00330
00331 EM_msg.emergency_button_stop = m_SerRelayBoard->isEMStop();
00332 EM_msg.scanner_stop = m_SerRelayBoard->isScannerStop();
00333
00334
00335 EM_signal = (EM_msg.emergency_button_stop || EM_msg.scanner_stop);
00336
00337 switch (EM_stop_status_)
00338 {
00339 case ST_EM_FREE:
00340 {
00341 if (EM_signal == true)
00342 {
00343 ROS_ERROR("Emergency stop was issued");
00344 EM_stop_status_ = EM_msg.EMSTOP;
00345 }
00346 break;
00347 }
00348 case ST_EM_ACTIVE:
00349 {
00350 if (EM_signal == false)
00351 {
00352 ROS_INFO("Emergency stop was confirmed");
00353 EM_stop_status_ = EM_msg.EMCONFIRMED;
00354 time_of_EM_confirmed_ = ros::Time::now();
00355 }
00356 break;
00357 }
00358 case ST_EM_CONFIRMED:
00359 {
00360 if (EM_signal == true)
00361 {
00362 ROS_ERROR("Emergency stop was issued");
00363 EM_stop_status_ = EM_msg.EMSTOP;
00364 }
00365 else
00366 {
00367 duration_since_EM_confirmed = ros::Time::now() - time_of_EM_confirmed_;
00368 if( duration_since_EM_confirmed.toSec() > duration_for_EM_free_.toSec() )
00369 {
00370 ROS_INFO("Emergency stop released");
00371 EM_stop_status_ = EM_msg.EMFREE;
00372 }
00373 }
00374 break;
00375 }
00376 };
00377
00378
00379 EM_msg.emergency_state = EM_stop_status_;
00380
00381
00382 if(relayboard_online == false) {
00383 EM_msg.emergency_state = EM_msg.EMSTOP;
00384 }
00385 topicPub_isEmergencyStop.publish(EM_msg);
00386
00387 neo_msgs::PowerBoardState pbs;
00388 pbs.header.stamp = ros::Time::now();
00389 if(EM_stop_status_ == ST_EM_FREE)
00390 pbs.run_stop = true;
00391 else
00392 pbs.run_stop = false;
00393 pbs.wireless_stop = true;
00394 pbs.input_voltage = current_voltage;
00395 topicPub_boardState.publish(pbs);
00396 }
00397
00398
00399 void neo_relayboard_node::sendAnalogIn()
00400 {
00401 if(!relayboard_available) return;
00402 int analogIn[8];
00403 m_SerRelayBoard->getRelayBoardAnalogIn(analogIn);
00404
00405 std_msgs::Int16 temp;
00406 temp.data = analogIn[2];
00407 topicPub_temperatur.publish(temp);
00408
00409 neo_msgs::PowerState bat;
00410 current_voltage = analogIn[1]/1000;
00411 bat.header.stamp = ros::Time::now();
00412 double percentage = ((analogIn[1] / 1000.0) - voltage_min_) * 100 / (voltage_max_ - voltage_min_);
00413
00414 bat.relative_capacity = percentage;
00415
00416 topicPub_batVoltage.publish(bat);
00417
00418 if(hasKeyPad == 1)
00419 {
00420 neo_msgs::Keypad pad;
00421 int mask = 1;
00422 for(int i = 0; i<4; i++)
00423 {
00424 if((analogIn[3] & mask) != 0)
00425 {
00426 pad.button[i] = true;
00427 } else {
00428 pad.button[i] = false;
00429 }
00430 mask = mask << 1;
00431 }
00432 topicPub_keypad.publish(pad);
00433 }
00434 if(hasIRSensors == 1)
00435 {
00436 neo_msgs::IRSensors irmsg;
00437 for(int i=0; i<4; i++) irmsg.measurement[i] = analogIn[4+i];
00438 topicPub_IRSensor.publish(irmsg);
00439 }
00440 }
00441 void neo_relayboard_node::setRelayBoardDigOut(const neo_msgs::IOOut& setOut)
00442 {
00443 if(!relayboard_available) return;
00444 m_SerRelayBoard->setRelayBoardDigOut(setOut.channel, setOut.active);
00445 }
00446
00447 void neo_relayboard_node::sendRelayBoardDigOut()
00448 {
00449 if(!relayboard_available) return;
00450 std_msgs::Int16 i;
00451 i.data = m_SerRelayBoard->getRelayBoardDigOut();
00452 topicPub_SendRelayStates.publish(i);
00453
00454 }
00456
00457
00458 void neo_relayboard_node::sendDriveStates()
00459 {
00460 int anz_drives = 2;
00461 if(!relayboard_available) return;
00462
00463 sensor_msgs::JointState state;
00464 if(activeModule[DRIVE3] == 1 && activeModule[DRIVE4] == 1)
00465 {
00466
00467 state.name.resize(4);
00468 state.position.resize(4);
00469 state.velocity.resize(4);
00470 anz_drives = 4;
00471 }
00472 else
00473 {
00474
00475 state.name.resize(2);
00476 state.position.resize(2);
00477 state.velocity.resize(2);
00478 anz_drives = 2;
00479 }
00480
00481
00482 for(int i = 0; i<anz_drives; i++) state.name[i] = joint_names[i];
00483 int temp;
00484
00485 if (activeModule[DRIVE1] == 1)
00486 {
00487 m_SerRelayBoard->getWheelPosVel(motorCanIdent[0],&(state.position[0]), &(state.velocity[0]));
00488
00489 }
00490
00491 if (activeModule[DRIVE2] == 1)
00492 {
00493 m_SerRelayBoard->getWheelPosVel(motorCanIdent[1],&(state.position[1]), &(state.velocity[1]));
00494
00495 }
00496
00497
00498 if (activeModule[DRIVE3] == 1)
00499 {
00500 m_SerRelayBoard->getWheelPosVel(motorCanIdent[2],&(state.position[2]), &(state.velocity[2]));
00501
00502 }
00503
00504 if (activeModule[DRIVE4] == 1)
00505 {
00506 m_SerRelayBoard->getWheelPosVel(motorCanIdent[3],&(state.position[3]), &(state.velocity[3]));
00507
00508 }
00509
00510 if(activeModule[DRIVE1] == 1 || activeModule[DRIVE2] == 1 || activeModule[DRIVE3] == 1 || activeModule[DRIVE4] == 1)
00511 {
00512
00513 topicPub_drives.publish(state);
00514
00515 }
00516 }
00517
00518 void neo_relayboard_node::getNewDriveStates(const trajectory_msgs::JointTrajectory jt)
00519 {
00520
00521 trajectory_msgs::JointTrajectoryPoint point = jt.points[0];
00522 if(!relayboard_available) return;
00523
00524 int anz_antriebe = 2;
00525 if(activeModule[DRIVE3] == 1 && activeModule[DRIVE4] == 1)
00526 {
00527
00528 anz_antriebe = 4;
00529 }
00530
00531 for(int i=0; i<anz_antriebe; i++)
00532 {
00533
00534 if(jt.joint_names[i] != ""){
00535
00536
00537
00538 m_SerRelayBoard->setWheelVel(motorCanIdent[i], point.velocities[i], false);
00539
00540 }
00541 }
00542 }
00543
00545
00546
00547 void neo_relayboard_node::sendGyroBoard()
00548 {
00549 if(!relayboard_available || activeModule[GYRO_BOARD] != 1) return;
00550 neo_msgs::GyroBoard gyro;
00551 m_SerRelayBoard->getGyroBoardAngBoost(&(gyro.orientation),gyro.acceleration);
00552 topicPub_gyroBoard.publish(gyro);
00553 }
00554
00555 void neo_relayboard_node::zeroGyro(const std_msgs::Bool& b)
00556 {
00557 if(!relayboard_available || activeModule[GYRO_BOARD] != 1) return;
00558 m_SerRelayBoard->zeroGyro(b.data);
00559 }
00560
00562
00563
00564 void neo_relayboard_node::sendRadarBoard()
00565 {
00566 if(!relayboard_available || activeModule[RADAR_BOARD] != 1) return;
00567 neo_msgs::RadarBoard radar;
00568 double radarState[4];
00569 m_SerRelayBoard->getRadarBoardData(radarState);
00570 for(int i=0; i<3;i++)
00571 {
00572 radar.velocity[i] = radarState[i];
00573 }
00574 radar.state = radarState[3];
00575 topicPub_radarBoard.publish(radar);
00576 }
00577
00579
00580
00581 void neo_relayboard_node::sendUSBoard()
00582 {
00583 if(!relayboard_available || activeModule[US_BOARD] != 1) return;
00584 int usSensors[8];
00585 int usAnalog[4];
00586 neo_msgs::USBoard usBoard;
00587 m_SerRelayBoard->getUSBoardData1To8(usSensors);
00588 for(int i=0; i<8; i++) usBoard.sensor[i] = usSensors[i];
00589 m_SerRelayBoard->getUSBoardData9To16(usSensors);
00590 for(int i=0; i<8; i++) usBoard.sensor[i+8] = usSensors[i];
00591 m_SerRelayBoard->getUSBoardAnalogIn(usAnalog);
00592 for(int i=0; i<4; i++) usBoard.analog[i] = usAnalog[i];
00593 topicPub_usBoard.publish(usBoard);
00594 }
00595
00596 void neo_relayboard_node::startUSBoard(const std_msgs::Int16& configuration)
00597 {
00598 if(!relayboard_available || activeModule[US_BOARD] != 1) return;
00599 m_SerRelayBoard->startUS(configuration.data);
00600 }
00601
00602 void neo_relayboard_node::stopUSBoard(const std_msgs::Empty& empty)
00603 {
00604 if(!relayboard_available || activeModule[US_BOARD] != 1) return;
00605 m_SerRelayBoard->stopUS();
00606 }
00607
00609
00610
00611 void neo_relayboard_node::getNewLCDOutput(const neo_msgs::LCDOutput& msg)
00612 {
00613 if(!relayboard_available || hasLCDOut != 1) return;
00614 m_SerRelayBoard->writeIOBoardLCD(0,0,msg.msg_line);
00615
00616 }
00617
00618 void neo_relayboard_node::getIOBoardDigOut(const neo_msgs::IOOut& setOut)
00619 {
00620 if(!relayboard_available || activeModule[IO_BOARD] != 1) return;
00621 m_SerRelayBoard->setIOBoardDigOut(setOut.channel, setOut.active);
00622 }
00623
00624 void neo_relayboard_node::sendIOBoardDigIn()
00625 {
00626 if(!relayboard_available || activeModule[IO_BOARD] != 1) return;
00627 std_msgs::Int16 i;
00628 i.data = m_SerRelayBoard->getIOBoardDigIn();
00629 topicPub_ioDigIn.publish(i);
00630
00631 }
00632
00633 void neo_relayboard_node::sendIOBoardDigOut()
00634 {
00635 if(!relayboard_available || activeModule[IO_BOARD] != 1) return;
00636 std_msgs::Int16 i;
00637 i.data = m_SerRelayBoard->getIOBoardDigOut();
00638 topicPub_ioDigOut.publish(i);
00639 }
00640
00641 void neo_relayboard_node::sendIOBoardAnalogIn()
00642 {
00643 if(!relayboard_available || activeModule[IO_BOARD] != 1) return;
00644 int analogIn[8];
00645 neo_msgs::IOAnalogIn in;
00646 m_SerRelayBoard->getIOBoardAnalogIn(analogIn);
00647 for(int i=0;i <8; i++) in.input[i] = analogIn[i];
00648 topicPub_analogIn.publish(in);
00649 }