pacmod3_ros_msg_handler.cpp
Go to the documentation of this file.
00001 /*
00002 * Unpublished Copyright (c) 2009-2017 AutonomouStuff, LLC, All Rights Reserved.
00003 *
00004 * This file is part of the PACMod ROS 1.0 driver which is released under the MIT license.
00005 * See file LICENSE included with this software or go to https://opensource.org/licenses/MIT for full license details.
00006 */
00007 
00008 #include <pacmod3_ros_msg_handler.h>
00009 
00010 using namespace AS::Drivers::PACMod3;
00011 
00012 LockedData::LockedData() :
00013   _data(),
00014   _data_mut()
00015 {
00016 }
00017 
00018 std::vector<unsigned char> LockedData::getData() const
00019 {
00020   std::lock_guard<std::mutex> lck(_data_mut);
00021   return _data;
00022 }
00023 
00024 void LockedData::setData(std::vector<unsigned char> new_data)
00025 {
00026   std::lock_guard<std::mutex> lck(_data_mut);
00027   _data = new_data;
00028 }
00029 
00030 void Pacmod3TxRosMsgHandler::fillAndPublish(const int64_t& can_id,
00031                                             std::string frame_id,
00032                                             ros::Publisher& pub,
00033                                             std::shared_ptr<Pacmod3TxMsg>& parser_class)
00034 {
00035   if (can_id == HornRptMsg::CAN_ID ||
00036       can_id == ParkingBrakeRptMsg::CAN_ID)
00037   {
00038     pacmod_msgs::SystemRptBool new_msg;
00039     fillSystemRptBool(parser_class, new_msg, frame_id);
00040     pub.publish(new_msg);
00041   }
00042   else if (can_id == CruiseControlButtonsRptMsg::CAN_ID ||
00043       can_id == DashControlsLeftRptMsg::CAN_ID ||
00044       can_id == DashControlsRightRptMsg::CAN_ID ||
00045       can_id == TurnSignalRptMsg::CAN_ID ||
00046       can_id == ShiftRptMsg::CAN_ID ||
00047       can_id == HeadlightRptMsg::CAN_ID ||
00048       can_id == MediaControlsRptMsg::CAN_ID ||
00049       can_id == WiperRptMsg::CAN_ID)
00050   {
00051     pacmod_msgs::SystemRptInt new_msg;
00052     fillSystemRptInt(parser_class, new_msg, frame_id);
00053     pub.publish(new_msg);
00054   }
00055   else if (can_id == AccelRptMsg::CAN_ID ||
00056            can_id == BrakeRptMsg::CAN_ID ||
00057            can_id == SteerRptMsg::CAN_ID)
00058   {
00059     pacmod_msgs::SystemRptFloat new_msg;
00060     fillSystemRptFloat(parser_class, new_msg, frame_id);
00061     pub.publish(new_msg);
00062   }
00063   else if (can_id == GlobalRptMsg::CAN_ID)
00064   {
00065     pacmod_msgs::GlobalRpt new_msg;
00066     fillGlobalRpt(parser_class, new_msg, frame_id);
00067     pub.publish(new_msg);
00068   }
00069   else if (can_id == BrakeMotorRpt1Msg::CAN_ID ||
00070            can_id == SteerMotorRpt1Msg::CAN_ID)
00071   {
00072     pacmod_msgs::MotorRpt1 new_msg;
00073     fillMotorRpt1(parser_class, new_msg, frame_id);
00074     pub.publish(new_msg);
00075   }
00076   else if (can_id == BrakeMotorRpt2Msg::CAN_ID ||
00077            can_id == SteerMotorRpt2Msg::CAN_ID)
00078   {
00079     pacmod_msgs::MotorRpt2 new_msg;
00080     fillMotorRpt2(parser_class, new_msg, frame_id);
00081     pub.publish(new_msg);
00082   }
00083   else if (can_id == BrakeMotorRpt3Msg::CAN_ID ||
00084            can_id == SteerMotorRpt3Msg::CAN_ID)
00085   {
00086     pacmod_msgs::MotorRpt3 new_msg;
00087     fillMotorRpt3(parser_class, new_msg, frame_id);
00088     pub.publish(new_msg);
00089   }
00090   else if (can_id == AccelAuxRptMsg::CAN_ID)
00091   {
00092     pacmod_msgs::AccelAuxRpt new_msg;
00093     fillAccelAuxRpt(parser_class, new_msg, frame_id);
00094     pub.publish(new_msg);
00095   }
00096   else if (can_id == BrakeAuxRptMsg::CAN_ID)
00097   {
00098     pacmod_msgs::BrakeAuxRpt new_msg;
00099     fillBrakeAuxRpt(parser_class, new_msg, frame_id);
00100     pub.publish(new_msg);
00101   }
00102   else if (can_id == DateTimeRptMsg::CAN_ID)
00103   {
00104     pacmod_msgs::DateTimeRpt new_msg;
00105     fillDateTimeRpt(parser_class, new_msg, frame_id);
00106     pub.publish(new_msg);
00107   }
00108   else if (can_id == DoorRptMsg::CAN_ID)
00109   {
00110     pacmod_msgs::DoorRpt new_msg;
00111     fillDoorRpt(parser_class, new_msg, frame_id);
00112     pub.publish(new_msg);
00113   }
00114   else if (can_id == HeadlightAuxRptMsg::CAN_ID)
00115   {
00116     pacmod_msgs::HeadlightAuxRpt new_msg;
00117     fillHeadlightAuxRpt(parser_class, new_msg, frame_id);
00118     pub.publish(new_msg);
00119   }
00120   else if (can_id == InteriorLightsRptMsg::CAN_ID)
00121   {
00122     pacmod_msgs::InteriorLightsRpt new_msg;
00123     fillInteriorLightsRpt(parser_class, new_msg, frame_id);
00124     pub.publish(new_msg);
00125   }
00126   else if (can_id == LatLonHeadingRptMsg::CAN_ID)
00127   {
00128     pacmod_msgs::LatLonHeadingRpt new_msg;
00129     fillLatLonHeadingRpt(parser_class, new_msg, frame_id);
00130     pub.publish(new_msg);
00131   }
00132   else if (can_id == OccupancyRptMsg::CAN_ID)
00133   {
00134     pacmod_msgs::OccupancyRpt new_msg;
00135     fillOccupancyRpt(parser_class, new_msg, frame_id);
00136     pub.publish(new_msg);
00137   }
00138   else if (can_id == RearLightsRptMsg::CAN_ID)
00139   {
00140     pacmod_msgs::RearLightsRpt new_msg;
00141     fillRearLightsRpt(parser_class, new_msg, frame_id);
00142     pub.publish(new_msg);
00143   }
00144   else if (can_id == ShiftAuxRptMsg::CAN_ID)
00145   {
00146     pacmod_msgs::ShiftAuxRpt new_msg;
00147     fillShiftAuxRpt(parser_class, new_msg, frame_id);
00148     pub.publish(new_msg);
00149   }
00150   else if (can_id == SteerAuxRptMsg::CAN_ID)
00151   {
00152     pacmod_msgs::SteerAuxRpt new_msg;
00153     fillSteerAuxRpt(parser_class, new_msg, frame_id);
00154     pub.publish(new_msg);
00155   }
00156   else if (can_id == SteeringPIDRpt1Msg::CAN_ID)
00157   {
00158     pacmod_msgs::SteeringPIDRpt1 new_msg;
00159     fillSteeringPIDRpt1(parser_class, new_msg, frame_id);
00160     pub.publish(new_msg);
00161   }
00162   else if (can_id == SteeringPIDRpt2Msg::CAN_ID)
00163   {
00164     pacmod_msgs::SteeringPIDRpt2 new_msg;
00165     fillSteeringPIDRpt2(parser_class, new_msg, frame_id);
00166     pub.publish(new_msg);
00167   }
00168   else if (can_id == SteeringPIDRpt3Msg::CAN_ID)
00169   {
00170     pacmod_msgs::SteeringPIDRpt3 new_msg;
00171     fillSteeringPIDRpt3(parser_class, new_msg, frame_id);
00172     pub.publish(new_msg);
00173   }
00174   else if (can_id == SteeringPIDRpt4Msg::CAN_ID)
00175   {
00176     pacmod_msgs::SteeringPIDRpt4 new_msg;
00177     fillSteeringPIDRpt4(parser_class, new_msg, frame_id);
00178     pub.publish(new_msg);
00179   }
00180   else if (can_id == TurnAuxRptMsg::CAN_ID)
00181   {
00182     pacmod_msgs::TurnAuxRpt new_msg;
00183     fillTurnAuxRpt(parser_class, new_msg, frame_id);
00184     pub.publish(new_msg);
00185   }
00186   else if (can_id == YawRateRptMsg::CAN_ID)
00187   {
00188     pacmod_msgs::YawRateRpt new_msg;
00189     fillYawRateRpt(parser_class, new_msg, frame_id);
00190     pub.publish(new_msg);
00191   }
00192   else if (can_id == VehicleSpeedRptMsg::CAN_ID)
00193   {
00194     pacmod_msgs::VehicleSpeedRpt new_msg;
00195     fillVehicleSpeedRpt(parser_class, new_msg, frame_id);
00196     pub.publish(new_msg);
00197   }
00198   else if (can_id == VinRptMsg::CAN_ID)
00199   {
00200     pacmod_msgs::VinRpt new_msg;
00201     fillVinRpt(parser_class, new_msg, frame_id);
00202     pub.publish(new_msg);
00203   }
00204   else if (can_id == WheelSpeedRptMsg::CAN_ID)
00205   {
00206     pacmod_msgs::WheelSpeedRpt new_msg;
00207     fillWheelSpeedRpt(parser_class, new_msg, frame_id);
00208     pub.publish(new_msg);
00209   }
00210   else if (can_id == WiperAuxRptMsg::CAN_ID)
00211   {
00212     pacmod_msgs::WiperAuxRpt new_msg;
00213     fillWiperAuxRpt(parser_class, new_msg, frame_id);
00214     pub.publish(new_msg);
00215   }
00216   else if (can_id == DetectedObjectRptMsg::CAN_ID)
00217   {
00218     pacmod_msgs::DetectedObjectRpt new_msg;
00219     fillDetectedObjectRpt(parser_class, new_msg, frame_id);
00220     pub.publish(new_msg);
00221   }      
00222   else if (can_id == VehicleSpecificRpt1Msg::CAN_ID)
00223   {
00224     pacmod_msgs::VehicleSpecificRpt1 new_msg;
00225     fillVehicleSpecificRpt1(parser_class, new_msg, frame_id);
00226     pub.publish(new_msg);
00227   }  
00228   else if (can_id == VehicleDynamicsRptMsg::CAN_ID)
00229   {
00230     pacmod_msgs::VehicleDynamicsRpt new_msg;
00231     fillVehicleDynamicsRpt(parser_class, new_msg, frame_id);
00232     pub.publish(new_msg);
00233   }   
00234 }
00235 
00236 // Report messages
00237 void Pacmod3TxRosMsgHandler::fillSystemRptBool(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::SystemRptBool& new_msg, std::string frame_id)
00238 {
00239   auto dc_parser = std::dynamic_pointer_cast<SystemRptBoolMsg>(parser_class);
00240 
00241   new_msg.enabled = dc_parser->enabled;
00242   new_msg.override_active = dc_parser->override_active;
00243   new_msg.command_output_fault = dc_parser->command_output_fault;
00244   new_msg.input_output_fault = dc_parser->input_output_fault;
00245   new_msg.output_reported_fault = dc_parser->output_reported_fault;
00246   new_msg.pacmod_fault = dc_parser->pacmod_fault;
00247   new_msg.vehicle_fault = dc_parser->vehicle_fault;
00248 
00249   new_msg.manual_input = dc_parser->manual_input;
00250   new_msg.command = dc_parser->command;
00251   new_msg.output = dc_parser->output;
00252 
00253   new_msg.header.frame_id = frame_id;
00254   new_msg.header.stamp = ros::Time::now();
00255 }
00256 
00257 void Pacmod3TxRosMsgHandler::fillSystemRptInt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::SystemRptInt& new_msg, std::string frame_id)
00258 {
00259   auto dc_parser = std::dynamic_pointer_cast<SystemRptIntMsg>(parser_class);
00260 
00261   new_msg.enabled = dc_parser->enabled;
00262   new_msg.override_active = dc_parser->override_active;
00263   new_msg.command_output_fault = dc_parser->command_output_fault;
00264   new_msg.input_output_fault = dc_parser->input_output_fault;
00265   new_msg.output_reported_fault = dc_parser->output_reported_fault;
00266   new_msg.pacmod_fault = dc_parser->pacmod_fault;
00267   new_msg.vehicle_fault = dc_parser->vehicle_fault;
00268 
00269         new_msg.manual_input = dc_parser->manual_input;
00270         new_msg.command = dc_parser->command;
00271         new_msg.output = dc_parser->output;
00272 
00273   new_msg.header.frame_id = frame_id;
00274   new_msg.header.stamp = ros::Time::now();
00275 }
00276 
00277 void Pacmod3TxRosMsgHandler::fillSystemRptFloat(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::SystemRptFloat& new_msg, std::string frame_id)
00278 {
00279   auto dc_parser = std::dynamic_pointer_cast<SystemRptFloatMsg>(parser_class);
00280 
00281   new_msg.enabled = dc_parser->enabled;
00282   new_msg.override_active = dc_parser->override_active;
00283   new_msg.command_output_fault = dc_parser->command_output_fault;
00284   new_msg.input_output_fault = dc_parser->input_output_fault;
00285   new_msg.output_reported_fault = dc_parser->output_reported_fault;
00286   new_msg.pacmod_fault = dc_parser->pacmod_fault;
00287   new_msg.vehicle_fault = dc_parser->vehicle_fault;
00288 
00289   new_msg.manual_input = dc_parser->manual_input;
00290   new_msg.command = dc_parser->command;
00291   new_msg.output = dc_parser->output;
00292 
00293   new_msg.header.frame_id = frame_id;
00294   new_msg.header.stamp = ros::Time::now();
00295 }
00296 
00297 void Pacmod3TxRosMsgHandler::fillGlobalRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::GlobalRpt& new_msg, std::string frame_id)
00298 {
00299         auto dc_parser = std::dynamic_pointer_cast<GlobalRptMsg>(parser_class);
00300 
00301         new_msg.enabled = dc_parser->enabled;
00302         new_msg.override_active = dc_parser->override_active;
00303   new_msg.fault_active = dc_parser->fault_active;
00304   new_msg.config_fault_active = dc_parser->config_fault_active;
00305         new_msg.user_can_timeout = dc_parser->user_can_timeout;
00306         new_msg.steering_can_timeout = dc_parser->steering_can_timeout;
00307         new_msg.brake_can_timeout = dc_parser->brake_can_timeout;
00308   new_msg.subsystem_can_timeout = dc_parser->subsystem_can_timeout;
00309         new_msg.vehicle_can_timeout = dc_parser->vehicle_can_timeout;
00310         new_msg.user_can_read_errors = dc_parser->user_can_read_errors;
00311 
00312   new_msg.header.frame_id = frame_id;
00313         new_msg.header.stamp = ros::Time::now();
00314 }
00315 
00316 void Pacmod3TxRosMsgHandler::fillAccelAuxRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::AccelAuxRpt& new_msg, std::string frame_id)
00317 {
00318   auto dc_parser = std::dynamic_pointer_cast<AccelAuxRptMsg>(parser_class);
00319 
00320   new_msg.raw_pedal_pos = dc_parser->raw_pedal_pos;
00321   new_msg.raw_pedal_force = dc_parser->raw_pedal_force;
00322   new_msg.user_interaction = dc_parser->user_interaction;
00323   new_msg.raw_pedal_pos_is_valid = dc_parser->raw_pedal_pos_is_valid;
00324   new_msg.raw_pedal_force_is_valid = dc_parser->raw_pedal_force_is_valid;
00325   new_msg.user_interaction_is_valid = dc_parser->user_interaction_is_valid;
00326 
00327   new_msg.header.frame_id = frame_id;
00328   new_msg.header.stamp = ros::Time::now();
00329 }
00330 
00331 void Pacmod3TxRosMsgHandler::fillBrakeAuxRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::BrakeAuxRpt& new_msg, std::string frame_id)
00332 {
00333   auto dc_parser = std::dynamic_pointer_cast<BrakeAuxRptMsg>(parser_class);
00334 
00335   new_msg.raw_pedal_pos = dc_parser->raw_pedal_pos;
00336   new_msg.raw_pedal_force = dc_parser->raw_pedal_force;
00337   new_msg.raw_brake_pressure = dc_parser->raw_brake_pressure;
00338   new_msg.user_interaction = dc_parser->user_interaction;
00339   new_msg.brake_on_off = dc_parser->brake_on_off;
00340   new_msg.raw_pedal_pos_is_valid = dc_parser->raw_pedal_pos_is_valid;
00341   new_msg.raw_pedal_force_is_valid = dc_parser->raw_pedal_force_is_valid;
00342   new_msg.user_interaction_is_valid = dc_parser->user_interaction_is_valid;
00343   new_msg.brake_on_off_is_valid = dc_parser->brake_on_off_is_valid;
00344 
00345   new_msg.header.frame_id = frame_id;
00346   new_msg.header.stamp = ros::Time::now();
00347 }
00348 
00349 void Pacmod3TxRosMsgHandler::fillDateTimeRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::DateTimeRpt& new_msg, std::string frame_id)
00350 {
00351   auto dc_parser = std::dynamic_pointer_cast<DateTimeRptMsg>(parser_class);
00352 
00353         new_msg.year = dc_parser->year;
00354         new_msg.month = dc_parser->month;
00355         new_msg.day = dc_parser->day;
00356         new_msg.hour = dc_parser->hour;
00357         new_msg.minute = dc_parser->minute;
00358         new_msg.second = dc_parser->second;
00359 
00360   new_msg.header.frame_id = frame_id;
00361   new_msg.header.stamp = ros::Time::now();
00362 }
00363 
00364 void Pacmod3TxRosMsgHandler::fillDetectedObjectRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::DetectedObjectRpt& new_msg, std::string frame_id)
00365 {
00366   auto dc_parser = std::dynamic_pointer_cast<DetectedObjectRptMsg>(parser_class);
00367 
00368   new_msg.front_object_distance_low_res = dc_parser->front_object_distance_low_res;
00369   new_msg.front_object_distance_high_res = dc_parser->front_object_distance_high_res;
00370 
00371   new_msg.header.frame_id = frame_id;
00372   new_msg.header.stamp = ros::Time::now();
00373 }
00374 void Pacmod3TxRosMsgHandler::fillDoorRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::DoorRpt& new_msg, std::string frame_id)
00375 {
00376   auto dc_parser = std::dynamic_pointer_cast<DoorRptMsg>(parser_class);
00377 
00378   new_msg.driver_door_open = dc_parser->driver_door_open;
00379   new_msg.driver_door_open_is_valid = dc_parser->driver_door_open_is_valid;
00380   new_msg.passenger_door_open = dc_parser->passenger_door_open;
00381   new_msg.passenger_door_open_is_valid = dc_parser->passenger_door_open_is_valid;
00382   new_msg.rear_driver_door_open = dc_parser->rear_driver_door_open;
00383   new_msg.rear_driver_door_open_is_valid = dc_parser->rear_driver_door_open_is_valid;
00384   new_msg.rear_passenger_door_open = dc_parser->rear_passenger_door_open;
00385   new_msg.rear_passenger_door_open_is_valid = dc_parser->rear_passenger_door_open_is_valid;
00386   new_msg.hood_open = dc_parser->hood_open;
00387   new_msg.hood_open_is_valid = dc_parser->hood_open_is_valid;
00388   new_msg.trunk_open = dc_parser->trunk_open;
00389   new_msg.trunk_open_is_valid = dc_parser->trunk_open_is_valid;
00390   new_msg.fuel_door_open = dc_parser->fuel_door_open;
00391   new_msg.fuel_door_open_is_valid = dc_parser->fuel_door_open_is_valid;
00392 
00393   new_msg.header.frame_id = frame_id;
00394   new_msg.header.stamp = ros::Time::now();
00395 }
00396 
00397 void Pacmod3TxRosMsgHandler::fillHeadlightAuxRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::HeadlightAuxRpt& new_msg, std::string frame_id)
00398 {
00399   auto dc_parser = std::dynamic_pointer_cast<HeadlightAuxRptMsg>(parser_class);
00400 
00401   new_msg.headlights_on = dc_parser->headlights_on;
00402   new_msg.headlights_on_bright = dc_parser->headlights_on_bright;
00403   new_msg.fog_lights_on = dc_parser->fog_lights_on;
00404   new_msg.headlights_mode = dc_parser->headlights_mode;
00405   new_msg.headlights_on_is_valid = dc_parser->headlights_on_is_valid;
00406   new_msg.headlights_on_bright_is_valid = dc_parser->headlights_on_bright_is_valid;
00407   new_msg.fog_lights_on_is_valid = dc_parser->fog_lights_on_is_valid;
00408   new_msg.headlights_mode_is_valid = dc_parser->headlights_mode_is_valid;
00409 
00410   new_msg.header.frame_id = frame_id;
00411   new_msg.header.stamp = ros::Time::now();
00412 }
00413 
00414 void Pacmod3TxRosMsgHandler::fillInteriorLightsRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::InteriorLightsRpt& new_msg, std::string frame_id)
00415 {
00416   auto dc_parser = std::dynamic_pointer_cast<InteriorLightsRptMsg>(parser_class);
00417 
00418   new_msg.front_dome_lights_on = dc_parser->front_dome_lights_on;
00419   new_msg.front_dome_lights_on_is_valid = dc_parser->front_dome_lights_on_is_valid;
00420   new_msg.rear_dome_lights_on = dc_parser->rear_dome_lights_on;
00421   new_msg.rear_dome_lights_on_is_valid = dc_parser->rear_dome_lights_on_is_valid;
00422   new_msg.mood_lights_on = dc_parser->mood_lights_on;
00423   new_msg.mood_lights_on_is_valid = dc_parser->mood_lights_on_is_valid;
00424   new_msg.dim_level = dc_parser->dim_level;
00425   new_msg.dim_level_is_valid = dc_parser->dim_level_is_valid;
00426 
00427   new_msg.header.frame_id = frame_id;
00428   new_msg.header.stamp = ros::Time::now();
00429 }
00430 
00431 void Pacmod3TxRosMsgHandler::fillLatLonHeadingRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::LatLonHeadingRpt& new_msg, std::string frame_id)
00432 {
00433   auto dc_parser = std::dynamic_pointer_cast<LatLonHeadingRptMsg>(parser_class);
00434 
00435         new_msg.latitude_degrees = dc_parser->latitude_degrees;
00436         new_msg.latitude_minutes = dc_parser->latitude_minutes;
00437         new_msg.latitude_seconds = dc_parser->latitude_seconds;
00438         new_msg.longitude_degrees = dc_parser->longitude_degrees;
00439         new_msg.longitude_minutes = dc_parser->longitude_minutes;
00440         new_msg.longitude_seconds = dc_parser->longitude_seconds;
00441         new_msg.heading = dc_parser->heading;
00442 
00443   new_msg.header.frame_id = frame_id;
00444   new_msg.header.stamp = ros::Time::now();
00445 }
00446 
00447 void Pacmod3TxRosMsgHandler::fillMotorRpt1(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::MotorRpt1& new_msg, std::string frame_id)
00448 {
00449   auto dc_parser = std::dynamic_pointer_cast<MotorRpt1Msg>(parser_class);
00450 
00451         new_msg.current = dc_parser->current;
00452         new_msg.position = dc_parser->position;
00453 
00454   new_msg.header.frame_id = frame_id;
00455   new_msg.header.stamp = ros::Time::now();
00456 }
00457 
00458 void Pacmod3TxRosMsgHandler::fillMotorRpt2(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::MotorRpt2& new_msg, std::string frame_id)
00459 {
00460   auto dc_parser = std::dynamic_pointer_cast<MotorRpt2Msg>(parser_class);
00461 
00462         new_msg.encoder_temp = dc_parser->encoder_temp;
00463         new_msg.motor_temp = dc_parser->motor_temp;
00464         new_msg.angular_velocity = dc_parser->velocity;
00465 
00466   new_msg.header.frame_id = frame_id;
00467   new_msg.header.stamp = ros::Time::now();
00468 }
00469 
00470 void Pacmod3TxRosMsgHandler::fillMotorRpt3(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::MotorRpt3& new_msg, std::string frame_id)
00471 {
00472   auto dc_parser = std::dynamic_pointer_cast<MotorRpt3Msg>(parser_class);
00473 
00474         new_msg.torque_output = dc_parser->torque_output;
00475         new_msg.torque_input = dc_parser->torque_input;
00476 
00477   new_msg.header.frame_id = frame_id;
00478   new_msg.header.stamp = ros::Time::now();
00479 }
00480 
00481 void Pacmod3TxRosMsgHandler::fillOccupancyRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::OccupancyRpt& new_msg, std::string frame_id)
00482 {
00483   auto dc_parser = std::dynamic_pointer_cast<OccupancyRptMsg>(parser_class);
00484 
00485   new_msg.driver_seat_occupied = dc_parser->driver_seat_occupied;
00486   new_msg.driver_seat_occupied_is_valid = dc_parser->driver_seat_occupied_is_valid;
00487   new_msg.passenger_seat_occupied = dc_parser->passenger_seat_occupied;
00488   new_msg.passenger_seat_occupied_is_valid = dc_parser->passenger_seat_occupied_is_valid;
00489   new_msg.rear_seat_occupied = dc_parser->rear_seat_occupied;
00490   new_msg.rear_seat_occupied_is_valid = dc_parser->rear_seat_occupied_is_valid;
00491   new_msg.driver_seatbelt_buckled = dc_parser->driver_seatbelt_buckled;
00492   new_msg.driver_seatbelt_buckled_is_valid = dc_parser->driver_seatbelt_buckled_is_valid;
00493   new_msg.passenger_seatbelt_buckled = dc_parser->passenger_seatbelt_buckled;
00494   new_msg.passenger_seatbelt_buckled_is_valid = dc_parser->passenger_seatbelt_buckled_is_valid;
00495   new_msg.rear_seatbelt_buckled = dc_parser->rear_seatbelt_buckled;
00496   new_msg.rear_seatbelt_buckled_is_valid = dc_parser->rear_seatbelt_buckled_is_valid;
00497 
00498   new_msg.header.frame_id = frame_id;
00499   new_msg.header.stamp = ros::Time::now();
00500 }
00501 
00502 void Pacmod3TxRosMsgHandler::fillRearLightsRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::RearLightsRpt& new_msg, std::string frame_id)
00503 {
00504   auto dc_parser = std::dynamic_pointer_cast<RearLightsRptMsg>(parser_class);
00505 
00506   new_msg.brake_lights_on = dc_parser->brake_lights_on;
00507   new_msg.brake_lights_on_is_valid = dc_parser->brake_lights_on_is_valid;
00508   new_msg.reverse_lights_on = dc_parser->reverse_lights_on;
00509   new_msg.reverse_lights_on_is_valid = dc_parser->reverse_lights_on_is_valid;
00510 
00511   new_msg.header.frame_id = frame_id;
00512   new_msg.header.stamp = ros::Time::now();
00513 }
00514 
00515 void Pacmod3TxRosMsgHandler::fillShiftAuxRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::ShiftAuxRpt& new_msg, std::string frame_id)
00516 {
00517   auto dc_parser = std::dynamic_pointer_cast<ShiftAuxRptMsg>(parser_class);
00518 
00519   new_msg.between_gears = dc_parser->between_gears;
00520   new_msg.stay_in_neutral_mode = dc_parser->stay_in_neutral_mode;
00521   new_msg.brake_interlock_active = dc_parser->brake_interlock_active;
00522   new_msg.speed_interlock_active = dc_parser->speed_interlock_active;
00523   new_msg.between_gears_is_valid = dc_parser->between_gears_is_valid;
00524   new_msg.stay_in_neutral_mode_is_valid = dc_parser->stay_in_neutral_mode_is_valid;
00525   new_msg.brake_interlock_active_is_valid = dc_parser->brake_interlock_active_is_valid;
00526   new_msg.speed_interlock_active_is_valid = dc_parser->speed_interlock_active_is_valid;
00527 
00528   new_msg.header.frame_id = frame_id;
00529   new_msg.header.stamp = ros::Time::now();
00530 }
00531 
00532 void Pacmod3TxRosMsgHandler::fillSteerAuxRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::SteerAuxRpt& new_msg, std::string frame_id)
00533 {
00534   auto dc_parser = std::dynamic_pointer_cast<SteerAuxRptMsg>(parser_class);
00535 
00536   new_msg.raw_position = dc_parser->raw_position;
00537   new_msg.raw_torque = dc_parser->raw_torque;
00538   new_msg.rotation_rate = dc_parser->rotation_rate;
00539   new_msg.user_interaction = dc_parser->user_interaction;
00540   new_msg.raw_position_is_valid = dc_parser->raw_position_is_valid;
00541   new_msg.raw_torque_is_valid = dc_parser->raw_torque_is_valid;
00542   new_msg.rotation_rate_is_valid = dc_parser->rotation_rate_is_valid;
00543   new_msg.user_interaction_is_valid = dc_parser->user_interaction_is_valid;
00544 
00545   new_msg.header.frame_id = frame_id;
00546   new_msg.header.stamp = ros::Time::now();
00547 }
00548 
00549 void Pacmod3TxRosMsgHandler::fillSteeringPIDRpt1(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::SteeringPIDRpt1& new_msg, std::string frame_id)
00550 {
00551   auto dc_parser = std::dynamic_pointer_cast<SteeringPIDRpt1Msg>(parser_class);
00552 
00553         new_msg.dt = dc_parser->dt;
00554         new_msg.Kp = dc_parser->Kp;
00555         new_msg.Ki = dc_parser->Ki;
00556         new_msg.Kd = dc_parser->Kd;
00557 
00558   new_msg.header.frame_id = frame_id;
00559   new_msg.header.stamp = ros::Time::now();
00560 }
00561 
00562 void Pacmod3TxRosMsgHandler::fillSteeringPIDRpt2(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::SteeringPIDRpt2& new_msg, std::string frame_id)
00563 {
00564   auto dc_parser = std::dynamic_pointer_cast<SteeringPIDRpt2Msg>(parser_class);
00565 
00566         new_msg.P_term = dc_parser->P_term;
00567         new_msg.I_term = dc_parser->I_term;
00568         new_msg.D_term = dc_parser->D_term;
00569         new_msg.all_terms = dc_parser->all_terms;
00570 
00571   new_msg.header.frame_id = frame_id;
00572   new_msg.header.stamp = ros::Time::now();
00573 }
00574 
00575 void Pacmod3TxRosMsgHandler::fillSteeringPIDRpt3(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::SteeringPIDRpt3& new_msg, std::string frame_id)
00576 {
00577   auto dc_parser = std::dynamic_pointer_cast<SteeringPIDRpt3Msg>(parser_class);
00578 
00579         new_msg.new_torque = dc_parser->new_torque;
00580         new_msg.str_angle_desired = dc_parser->str_angle_desired;
00581         new_msg.str_angle_actual = dc_parser->str_angle_actual;
00582         new_msg.error = dc_parser->error;
00583 
00584   new_msg.header.frame_id = frame_id;
00585   new_msg.header.stamp = ros::Time::now();
00586 }
00587 
00588 void Pacmod3TxRosMsgHandler::fillSteeringPIDRpt4(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::SteeringPIDRpt4& new_msg, std::string frame_id)
00589 {
00590   auto dc_parser = std::dynamic_pointer_cast<SteeringPIDRpt4Msg>(parser_class);
00591 
00592         new_msg.angular_velocity = dc_parser->angular_velocity;
00593         new_msg.angular_acceleration = dc_parser->angular_acceleration;
00594 
00595   new_msg.header.frame_id = frame_id;
00596   new_msg.header.stamp = ros::Time::now();
00597 }
00598 
00599 void Pacmod3TxRosMsgHandler::fillTurnAuxRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::TurnAuxRpt& new_msg, std::string frame_id)
00600 {
00601   auto dc_parser = std::dynamic_pointer_cast<TurnAuxRptMsg>(parser_class);
00602 
00603   new_msg.driver_blinker_bulb_on = dc_parser->driver_blinker_bulb_on;
00604   new_msg.passenger_blinker_bulb_on = dc_parser->passenger_blinker_bulb_on;
00605   new_msg.driver_blinker_bulb_on_is_valid = dc_parser->driver_blinker_bulb_on_is_valid;
00606   new_msg.passenger_blinker_bulb_on_is_valid = dc_parser->passenger_blinker_bulb_on_is_valid;
00607 
00608   new_msg.header.frame_id = frame_id;
00609   new_msg.header.stamp = ros::Time::now();
00610 }
00611 
00612 void Pacmod3TxRosMsgHandler::fillVehicleDynamicsRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::VehicleDynamicsRpt& new_msg, std::string frame_id)
00613 {
00614   auto dc_parser = std::dynamic_pointer_cast<VehicleDynamicsRptMsg>(parser_class);
00615 
00616   new_msg.g_forces = dc_parser->g_forces;
00617   new_msg.brake_torque = dc_parser->brake_torque;
00618 
00619   new_msg.header.frame_id = frame_id;
00620   new_msg.header.stamp = ros::Time::now();
00621 }
00622 
00623 void Pacmod3TxRosMsgHandler::fillVehicleSpecificRpt1(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::VehicleSpecificRpt1& new_msg, std::string frame_id)
00624 {
00625   auto dc_parser = std::dynamic_pointer_cast<VehicleSpecificRpt1Msg>(parser_class);
00626 
00627   new_msg.shift_pos_1 = dc_parser->shift_pos_1;
00628   new_msg.shift_pos_2 = dc_parser->shift_pos_2;
00629 
00630   new_msg.header.frame_id = frame_id;
00631   new_msg.header.stamp = ros::Time::now();
00632 }
00633 
00634 void Pacmod3TxRosMsgHandler::fillVehicleSpeedRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::VehicleSpeedRpt& new_msg, std::string frame_id)
00635 {
00636   auto dc_parser = std::dynamic_pointer_cast<VehicleSpeedRptMsg>(parser_class);
00637 
00638         new_msg.vehicle_speed = dc_parser->vehicle_speed;
00639         new_msg.vehicle_speed_valid = dc_parser->vehicle_speed_valid;
00640         new_msg.vehicle_speed_raw[0] = dc_parser->vehicle_speed_raw[0];
00641         new_msg.vehicle_speed_raw[1] = dc_parser->vehicle_speed_raw[1];
00642 
00643   new_msg.header.frame_id = frame_id;
00644   new_msg.header.stamp = ros::Time::now();
00645 }
00646 
00647 void Pacmod3TxRosMsgHandler::fillVinRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::VinRpt& new_msg, std::string frame_id)
00648 {
00649   auto dc_parser = std::dynamic_pointer_cast<VinRptMsg>(parser_class);
00650 
00651         new_msg.mfg_code = dc_parser->mfg_code;
00652         new_msg.mfg = dc_parser->mfg;
00653         new_msg.model_year_code = dc_parser->model_year_code;
00654         new_msg.model_year = dc_parser->model_year;
00655         new_msg.serial = dc_parser->serial;
00656 
00657   new_msg.header.frame_id = frame_id;
00658   new_msg.header.stamp = ros::Time::now();
00659 }
00660 
00661 void Pacmod3TxRosMsgHandler::fillWheelSpeedRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::WheelSpeedRpt& new_msg, std::string frame_id)
00662 {
00663   auto dc_parser = std::dynamic_pointer_cast<WheelSpeedRptMsg>(parser_class);
00664 
00665         new_msg.front_left_wheel_speed = dc_parser->front_left_wheel_speed;
00666         new_msg.front_right_wheel_speed = dc_parser->front_right_wheel_speed;
00667         new_msg.rear_left_wheel_speed = dc_parser->rear_left_wheel_speed;
00668         new_msg.rear_right_wheel_speed = dc_parser->rear_right_wheel_speed;
00669 
00670   new_msg.header.frame_id = frame_id;
00671   new_msg.header.stamp = ros::Time::now();
00672 }
00673 
00674 void Pacmod3TxRosMsgHandler::fillWiperAuxRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::WiperAuxRpt& new_msg, std::string frame_id)
00675 {
00676   auto dc_parser = std::dynamic_pointer_cast<WiperAuxRptMsg>(parser_class);
00677 
00678   new_msg.front_wiping = dc_parser->front_wiping;
00679   new_msg.front_spraying = dc_parser->front_spraying;
00680   new_msg.rear_wiping = dc_parser->rear_wiping;
00681   new_msg.rear_spraying = dc_parser->rear_spraying;
00682   new_msg.spray_near_empty = dc_parser->spray_near_empty;
00683   new_msg.spray_empty = dc_parser->spray_empty;
00684   new_msg.front_wiping_is_valid = dc_parser->front_wiping_is_valid;
00685   new_msg.front_spraying_is_valid = dc_parser->front_spraying_is_valid;
00686   new_msg.rear_wiping_is_valid = dc_parser->rear_wiping_is_valid;
00687   new_msg.rear_spraying_is_valid = dc_parser->rear_spraying_is_valid;
00688   new_msg.spray_near_empty_is_valid = dc_parser->spray_near_empty_is_valid;
00689   new_msg.spray_empty_is_valid = dc_parser->spray_empty_is_valid;
00690 
00691   new_msg.header.frame_id = frame_id;
00692   new_msg.header.stamp = ros::Time::now();
00693 }
00694 
00695 void Pacmod3TxRosMsgHandler::fillYawRateRpt(std::shared_ptr<Pacmod3TxMsg>& parser_class, pacmod_msgs::YawRateRpt& new_msg, std::string frame_id)
00696 {
00697   auto dc_parser = std::dynamic_pointer_cast<YawRateRptMsg>(parser_class);
00698 
00699         new_msg.yaw_rate = dc_parser->yaw_rate;
00700 
00701   new_msg.header.frame_id = frame_id;
00702   new_msg.header.stamp = ros::Time::now();
00703 }
00704 
00705 
00706 // Command messages
00707 std::vector<uint8_t> Pacmod3RxRosMsgHandler::unpackAndEncode(const int64_t& can_id, const pacmod_msgs::SystemCmdBool::ConstPtr& msg)
00708 {
00709   if (can_id == HornCmdMsg::CAN_ID)
00710   {
00711     HornCmdMsg encoder;
00712     encoder.encode(msg->enable,
00713                    msg->ignore_overrides,
00714                    msg->clear_override,
00715                    msg->command);
00716     return encoder.data;
00717   }
00718   else if (can_id == ParkingBrakeCmdMsg::CAN_ID)
00719   {
00720     ParkingBrakeCmdMsg encoder;
00721     encoder.encode(msg->enable,
00722                    msg->ignore_overrides,
00723                    msg->clear_override,
00724                    msg->command);
00725     return encoder.data;
00726   }
00727   else
00728   {
00729     std::vector<uint8_t> bad_id;
00730     bad_id.assign(8, 0);
00731     ROS_ERROR("A bool system command matching the provided CAN ID could not be found.");
00732     return bad_id;
00733   }
00734 }
00735 
00736 std::vector<uint8_t> Pacmod3RxRosMsgHandler::unpackAndEncode(const int64_t& can_id, const pacmod_msgs::SystemCmdFloat::ConstPtr& msg)
00737 {
00738         if (can_id == AccelCmdMsg::CAN_ID)
00739         {
00740     AccelCmdMsg encoder;
00741     encoder.encode(msg->enable,
00742                    msg->ignore_overrides,
00743                    msg->clear_override,
00744                    msg->command);
00745     return encoder.data;
00746         }
00747         else if (can_id == BrakeCmdMsg::CAN_ID)
00748         {
00749     BrakeCmdMsg encoder;
00750     encoder.encode(msg->enable,
00751                    msg->ignore_overrides,
00752                    msg->clear_override,
00753                    msg->command);
00754     return encoder.data;
00755         }
00756   else
00757   {
00758     std::vector<uint8_t> bad_id;
00759     bad_id.assign(8, 0);
00760     ROS_ERROR("A float system command matching the provided CAN ID could not be found.");
00761     return bad_id;
00762   }
00763 }
00764 
00765 std::vector<uint8_t> Pacmod3RxRosMsgHandler::unpackAndEncode(const int64_t& can_id, const pacmod_msgs::SystemCmdInt::ConstPtr& msg)
00766 {
00767   if (can_id == CruiseControlButtonsCmdMsg::CAN_ID)
00768   {
00769     CruiseControlButtonsCmdMsg encoder;
00770     encoder.encode(msg->enable,
00771                    msg->ignore_overrides,
00772                    msg->clear_override,
00773                    msg->command);
00774     return encoder.data;
00775   }
00776   else if (can_id == DashControlsLeftCmdMsg::CAN_ID)
00777   {
00778     DashControlsLeftCmdMsg encoder;
00779     encoder.encode(msg->enable,
00780                    msg->ignore_overrides,
00781                    msg->clear_override,
00782                    msg->command);
00783     return encoder.data;
00784   }
00785   else if (can_id == DashControlsRightCmdMsg::CAN_ID)
00786   {
00787     DashControlsRightCmdMsg encoder;
00788     encoder.encode(msg->enable,
00789                    msg->ignore_overrides,
00790                    msg->clear_override,
00791                    msg->command);
00792     return encoder.data;
00793   }
00794   else if (can_id == HeadlightCmdMsg::CAN_ID)
00795         {
00796     HeadlightCmdMsg encoder;
00797     encoder.encode(msg->enable,
00798                    msg->ignore_overrides,
00799                    msg->clear_override,
00800                    msg->command);
00801     return encoder.data;
00802         }
00803   else if (can_id == MediaControlsCmdMsg::CAN_ID)
00804   {
00805     MediaControlsCmdMsg encoder;
00806     encoder.encode(msg->enable,
00807                    msg->ignore_overrides,
00808                    msg->clear_override,
00809                    msg->command);
00810     return encoder.data;
00811   }
00812         else if (can_id == ShiftCmdMsg::CAN_ID)
00813         {
00814     ShiftCmdMsg encoder;
00815     encoder.encode(msg->enable,
00816                    msg->ignore_overrides,
00817                    msg->clear_override,
00818                    msg->command);
00819     return encoder.data;
00820         }
00821   else if (can_id == TurnSignalCmdMsg::CAN_ID)
00822         {
00823     TurnSignalCmdMsg encoder;
00824     encoder.encode(msg->enable,
00825                    msg->ignore_overrides,
00826                    msg->clear_override,
00827                    msg->command);
00828     return encoder.data;
00829         }
00830         else if (can_id == WiperCmdMsg::CAN_ID)
00831         {
00832     WiperCmdMsg encoder;
00833     encoder.encode(msg->enable,
00834                    msg->ignore_overrides,
00835                    msg->clear_override,
00836                    msg->command);
00837     return encoder.data;
00838         }
00839   else
00840   {
00841     std::vector<uint8_t> bad_id;
00842     bad_id.assign(8, 0);
00843     ROS_ERROR("An enum system command matching the provided CAN ID could not be found.");
00844     return bad_id;
00845   }
00846 }
00847 
00848 std::vector<uint8_t> Pacmod3RxRosMsgHandler::unpackAndEncode(const int64_t& can_id, const pacmod_msgs::SteerSystemCmd::ConstPtr& msg)
00849 {
00850   if (can_id == SteerCmdMsg::CAN_ID)
00851   {
00852     SteerCmdMsg encoder;
00853     encoder.encode(msg->enable,
00854                    msg->ignore_overrides,
00855                    msg->clear_override,
00856                    msg->command,
00857                    msg->rotation_rate);
00858     return encoder.data;
00859   }
00860   else
00861   {
00862     std::vector<uint8_t> bad_id;
00863     bad_id.assign(8, 0);
00864     ROS_ERROR("A steering system command matching the provided CAN ID could not be found.");
00865     return bad_id;
00866   }
00867 }


pacmod3
Author(s): Joe Driscoll , Josh Whitley
autogenerated on Thu Jun 6 2019 17:34:14