Go to the documentation of this file.00001 #include "asterx1_driver_node.h"
00002
00003 Asterx1DriverNode::Asterx1DriverNode(ros::NodeHandle &nh) :
00004 iri_base_driver::IriBaseNodeDriver<Asterx1Driver>(nh),
00005 is_auto_home_position_set_(0)
00006 {
00007
00008
00009 std::string port_name;
00010
00011
00012 this->loop_rate_ = 10;
00013
00014
00015 port_name = ros::names::append(ros::this_node::getName(), "gpsStandard");
00016 this->gpsStandard = this->public_node_handle_.advertise<sensor_msgs::NavSatFix>(port_name, 100);
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 }
00031
00032 void Asterx1DriverNode::mainNodeThread(void)
00033 {
00034
00035 ros::Time driverTS;
00036
00037
00038 this->driver_.lock();
00039
00040
00041 driver_.readDataFromDevice();
00042
00043
00044 driverTS.fromSec( driver_.getTimeStamp() );
00045 gpsStandardMsg.header.stamp = driverTS;
00046 gpsStandardMsg.header.frame_id = driver_.config_.frame_id;
00047
00048
00049 if (driver_.getStatus() == ALL_OK)
00050 {
00051 gpsStandardMsg.status.status = sensor_msgs::NavSatStatus::STATUS_FIX;
00052 if((driver_.config_.autoHome && !is_auto_home_position_set_) || (driver_.config_.autoHome && driver_.config_.resetHome))
00053 {
00054 driver_.setMapOrigin(driver_.getLat(inDEGREES),driver_.getLon(inDEGREES),driver_.getAlt(),0);
00055 is_auto_home_position_set_ = true;
00056 driver_.config_.resetHome = false;
00057 ROS_INFO("Map origin has been set to: %f %f %f",driver_.getLat(inDEGREES),driver_.getLon(inDEGREES),driver_.getAlt());
00058 }
00059 }
00060 else
00061 {
00062 gpsStandardMsg.status.status = sensor_msgs::NavSatStatus::STATUS_NO_FIX;
00063 ROS_DEBUG("Status: %d",driver_.getStatus());
00064 }
00065 gpsStandardMsg.status.service = sensor_msgs::NavSatStatus::SERVICE_GPS;
00066
00067
00068 gpsStandardMsg.latitude = driver_.getLat(inDEGREES);
00069 gpsStandardMsg.longitude = driver_.getLon(inDEGREES);
00070 gpsStandardMsg.altitude = driver_.getAlt();
00071
00072
00073 gpsStandardMsg.position_covariance[0] = driver_.getCxxEnu();
00074 gpsStandardMsg.position_covariance[1] = driver_.getCxyEnu();
00075 gpsStandardMsg.position_covariance[2] = driver_.getCxzEnu();
00076 gpsStandardMsg.position_covariance[3] = driver_.getCxyEnu();
00077 gpsStandardMsg.position_covariance[4] = driver_.getCyyEnu();
00078 gpsStandardMsg.position_covariance[5] = driver_.getCyzEnu();
00079 gpsStandardMsg.position_covariance[6] = driver_.getCxzEnu();
00080 gpsStandardMsg.position_covariance[7] = driver_.getCyzEnu();
00081 gpsStandardMsg.position_covariance[8] = driver_.getCzzEnu();
00082 gpsStandardMsg.position_covariance_type = gpsStandardMsg.COVARIANCE_TYPE_KNOWN;
00083
00084 ROS_DEBUG("T: %f N: %u",driver_.getTimeStamp(),driver_.getNumSatellites());
00085 if(driver_.getStatus() == ALL_OK)
00086 {
00087 ROS_DEBUG("WGS: pos %f %f %f vel: %f %f %f",driver_.getXWgs(),driver_.getYWgs(),driver_.getZWgs(),driver_.getVxWgs(),driver_.getVyWgs(),driver_.getVzWgs());
00088 ROS_DEBUG("Map: pos %f %f %f vel: %f %f %f",driver_.getXMap(),driver_.getYMap(),driver_.getZMap(),driver_.getVxMap(),driver_.getVyMap(),driver_.getVzMap());
00089 }
00090
00091
00092
00093
00094
00095
00096 gpsStandard.publish(gpsStandardMsg);
00097
00098
00099 this->driver_.unlock();
00100 }
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 void Asterx1DriverNode::postNodeOpenHook(void)
00111 {
00112 }
00113
00114 void Asterx1DriverNode::addNodeDiagnostics(void)
00115 {
00116 }
00117
00118 void Asterx1DriverNode::addNodeOpenedTests(void)
00119 {
00120 }
00121
00122 void Asterx1DriverNode::addNodeStoppedTests(void)
00123 {
00124 }
00125
00126 void Asterx1DriverNode::addNodeRunningTests(void)
00127 {
00128 }
00129
00130 void Asterx1DriverNode::reconfigureNodeHook(int level)
00131 {
00132 }
00133
00134 Asterx1DriverNode::~Asterx1DriverNode()
00135 {
00136
00137 }
00138
00139
00140 int main(int argc,char *argv[])
00141 {
00142 return driver_base::main<Asterx1DriverNode>(argc,argv,"asterx1_driver_node");
00143 }