46 int main(
int argc,
char **argv)
48 ros::init(argc, argv,
"kvh_geo_fog_3d_driver");
52 std::set<int> baudRates = {
53 1200, 1800, 2400, 4800, 9600,
54 19200, 57600, 115200, 230400,
55 460800, 500000, 576000, 921600, 1000000};
57 std::string kvhPort(
"/dev/ttyUSB0");
58 int startingBaud = 1200;
66 ROS_WARN(
"No port specified by param, defaulting to USB0!");
69 if (node.
getParam(
"starting_baud", startingBaud))
75 ROS_WARN(
"No starting baud specified. Defaulting to 1200.");
85 std::string possibleRates =
"";
87 for(
int rate : baudRates)
89 possibleRates += std::to_string(rate) +
"\n";
94 printf(
"If you wish to modify the baud rate, please input a new rate.\n%s", possibleRates.c_str());
95 printf(
"********************************\n");
96 printf(
"Keep in mind that if your port runs on hyper mode, divide your baud rate\n");
97 printf(
"by a factor of 8. Example, if you wish to enter 921600, enter 115200 (921600/115200)\n");
98 printf(
"********************************\n");
99 printf(
"If you wish to exit, please enter a negative number.\n");
102 std::cin >> newBaudRate;
104 if (baudRates.count(newBaudRate) > 0)
108 printf(
"Unable to set baud rate, please try again or exit.\n");
113 printf(
"Baud Rate successfully set. Exiting.\n");
118 else if (newBaudRate > 0)
120 printf(
"Please enter a value from the list provided.\n");
124 printf(
"Exiting program.\n");
131 printf(
"Unable to find baud rate. Try a different port.");
134 printf(
"Reached the end successfully.\n");
static int SetBaudRate(std::string _port, int _curBaudRate, int _primaryBaudRate, int _gpioBaudRate=115200, int _auxBaudRate=115200)
This function can be used to set the buad rate independent of the other functions of the driver...
KVH Geo Fog 3D driver class header.
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
Helper functions for configuring the hardware.
static int FindCurrentBaudRate(std::string, int)
This function tries each possible setting of baudrates until it either finds one that is receiving pa...
#define ROS_INFO_STREAM(args)
int main(int argc, char **argv)
bool getParam(const std::string &key, std::string &s) const