Control Seekur or Seekur Jr. accessory power switching from command line options. Run with -help for help on command line options. See robot manuals and notes on http://robots.mobilerobots.com for more information.
#include "Aria.h"
typedef struct {
const char *option;
int port;
const char *description;
int set;
} powerspec;
powerspec PowerSpecs[] = {
{"pc2", 1, "Turn onboard computer #2 on or off.", 0},
{"pc3", 13, "Turn onboard computer #3 on or off.", 0},
{"pc4", 14, "Turn onboard computer #4 on or off", 0},
{"pc5", 15, "Turn onboard computer #5 on or off.", 0},
{"lrf1", 9, "Turn laser rangefinder #1 on or off.", 0},
{"lrf2", 24, "Turn laser rangefinder #2 on or off.", 0},
{"lrf1heat", 11, "Turn laser rangefinder #1's heater on or off.", 0},
{"lrf2heat", 27, "Turn laser rangefinder #2's heater on or off.", 0},
{"gps", 6, "Turn GPS receeiver on or off.", 0},
{"poe", 4, "Turn 12V Power over Ethernet port on or off.", 0},
{"lan", 5, "Turn internal LAN ethernet switch on or off.", 0},
{"camera", 12, "Turn the 24V RVision camera on or off.", 0},
{"rvision", 12, "Turn the 24V RVision camera on or off.", 0},
{"ptu1", 9, "Turn pan/tilt unit #1 on or off.", 0},
{"ptu2", 22, "Turn pan/tilt unit #2 on or off.", 0},
{"ptu3", 23, "Turn pan/tilt unit #3 on or off.", 0},
{"arm", 29, "Turn the 24V manipulator arm on or off.", 0},
{"armcam", 7, "Turn the arm camera or other 12V arm accessories on or off.", 0}
};
int main(int argc, char **argv)
{
int numPowerSpecs = sizeof(PowerSpecs)/sizeof(powerspec);
{
}
{
ArLog::log(
ArLog::Terse,
"-<n> <on|off|reset>\t\tTurn port <n> on or off, or reset by turning off then on again. Refer to robot documentation or http://robots.mobilerobots.com/wiki/Seekur_Switched_Power_Outputs for list and notes.");
for(int i = 0; i < numPowerSpecs; ++i)
ArLog::log(
ArLog::Terse,
"-%s <on|off|reset>\t\t%s (port %d)", PowerSpecs[i].option, PowerSpecs[i].description, PowerSpecs[i].port);
}
{
for(int i = 5; i > 0; --i)
{
}
}
std::list<powerspec> todo;
for(int argi = 1; argi < nargs; ++argi)
{
const char *opt = parser.
getArg(argi);
if(opt[0] != '-')
{
}
++opt;
if(opt[0] == '-')
++opt;
bool found = false;
if(argi == nargs-1)
{
ArLog::log(
ArLog::Terse,
"seekurPower: Error: Missing argument to last option %s. Specify on, off or reset.", opt);
}
const char *val = parser.
getArg(++argi);
for(int pi = 0; pi < numPowerSpecs; ++pi)
{
powerspec ps = PowerSpecs[pi];
if(strcmp(opt, ps.option) == 0)
{
found = true;
if(strcmp(val, "on") == 0)
ps.set = 1;
else if(strcmp(val, "off") == 0)
ps.set = 0;
else if(strcmp(val, "reset") == 0)
ps.set = 2;
else
{
ArLog::log(
ArLog::Terse,
"seekurPower: Error: Invalid value '%s' for option %s. Use on, off or reset.", val, opt);
}
todo.push_back(ps);
break;
}
}
if(!found)
{
{
found = true;
powerspec ps;
ps.option = opt;
ps.description = NULL;
ps.port = atoi(opt);
if(strcmp(val, "on") == 0)
ps.set = 1;
else if(strcmp(val, "off") == 0)
ps.set = 0;
else if(strcmp(val, "reset") == 0)
ps.set = 2;
todo.push_back(ps);
}
}
if(!found)
{
ArLog::log(
ArLog::Terse,
"seekurPower: Warning: unrecognized option %s. Use -help for list of options.", opt);
}
}
for(std::list<powerspec>::const_iterator i = todo.begin(); i != todo.end(); ++i)
{
powerspec ps = *i;
if(ps.set == 2)
{
ArLog::log(
ArLog::Normal,
"seekurPower: Switching %s (port %d) off, waiting 2 seconds., then switching it back on again...", ps.option, ps.port);
}
else
{
}
}
}