Commit 07dd1ee1 authored by Timothy Stack's avatar Timothy Stack

ugh, fix whitespace

parent c480bdfe
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -17,12 +17,12 @@ faultCallback::~faultCallback()
}
faultDetection::faultDetection(acpGarcia &garcia, dashboard *db)
: fd_garcia(garcia),
fd_dashboard(db),
fd_callback(NULL),
fd_distance_limit(IDLE_DISTANCE_LIMIT),
fd_velocity_limit(IDLE_VELOCITY_LIMIT),
fd_fault_count(0)
: fd_garcia(garcia),
fd_dashboard(db),
fd_callback(NULL),
fd_distance_limit(IDLE_DISTANCE_LIMIT),
fd_velocity_limit(IDLE_VELOCITY_LIMIT),
fd_fault_count(0)
{
}
......@@ -32,86 +32,86 @@ faultDetection::~faultDetection()
bool faultDetection::update(unsigned long now)
{
struct mtp_garcia_telemetry *mgt;
unsigned long faults = 0;
bool retval = true;
float rv, lv;
acpValue av;
struct mtp_garcia_telemetry *mgt;
unsigned long faults = 0;
bool retval = true;
float rv, lv;
acpValue av;
mgt = this->fd_dashboard->getTelemetry();
if (fabsf(mgt->left_instant_odometer) > this->fd_distance_limit) {
fprintf(stderr,
"fault: left odometer has passed the distance limit"
"- %.3f > %.3f\n",
mgt->left_instant_odometer,
this->fd_distance_limit);
faults |= FDF_DISTANCE;
}
if (fabsf(mgt->right_instant_odometer) > this->fd_distance_limit) {
fprintf(stderr,
"fault: right odometer has passed the distance limit"
"- %.3f\n",
mgt->right_instant_odometer,
this->fd_distance_limit);
faults |= FDF_DISTANCE;
}
mgt = this->fd_dashboard->getTelemetry();
if (fabsf(mgt->left_instant_odometer) > this->fd_distance_limit) {
fprintf(stderr,
"fault: left odometer has passed the distance limit"
"- %.3f > %.3f\n",
mgt->left_instant_odometer,
this->fd_distance_limit);
faults |= FDF_DISTANCE;
}
if (fabsf(mgt->right_instant_odometer) > this->fd_distance_limit) {
fprintf(stderr,
"fault: right odometer has passed the distance limit"
"- %.3f\n",
mgt->right_instant_odometer,
this->fd_distance_limit);
faults |= FDF_DISTANCE;
}
if (fabsf(mgt->left_velocity) > this->fd_velocity_limit) {
fprintf(stderr,
"fault: left velocity has passed the limit - %.3f\n",
mgt->left_velocity);
faults |= FDF_VELOCITY;
}
if (fabsf(mgt->right_velocity) > this->fd_velocity_limit) {
fprintf(stderr,
"fault: right velocity has passed the limit - %.3f\n",
mgt->right_velocity);
faults |= FDF_VELOCITY;
}
if (fabsf(mgt->left_velocity) > this->fd_velocity_limit) {
fprintf(stderr,
"fault: left velocity has passed the limit - %.3f\n",
mgt->left_velocity);
faults |= FDF_VELOCITY;
}
if (fabsf(mgt->right_velocity) > this->fd_velocity_limit) {
fprintf(stderr,
"fault: right velocity has passed the limit - %.3f\n",
mgt->right_velocity);
faults |= FDF_VELOCITY;
}
/* XXX Remove the following when continuous motion is added. */
/* XXX Remove the following when continuous motion is added. */
#if 0
rv = fabsf(mgt->right_velocity);
lv = fabsf(mgt->left_velocity);
if ((rv < 0.020) && (lv < 0.020) && (fabsf(lv - rv) > 0.015)) {
fprintf(stderr,
"fault: velocity mismatch - %.3f %.3f\n",
mgt->left_velocity,
mgt->right_velocity);
faults |= FDF_VELOCITY_MISMATCH;
}
rv = fabsf(mgt->right_velocity);
lv = fabsf(mgt->left_velocity);
if ((rv < 0.020) && (lv < 0.020) && (fabsf(lv - rv) > 0.015)) {
fprintf(stderr,
"fault: velocity mismatch - %.3f %.3f\n",
mgt->left_velocity,
mgt->right_velocity);
faults |= FDF_VELOCITY_MISMATCH;
}
#endif
if (fabsf(mgt->front_ranger_threshold - FRONT_RANGER_THRESHOLD) > 0.01) {
fprintf(stderr,
"fault: front-ranger-threshold is invalid %f\n",
mgt->front_ranger_threshold);
if (fabsf(mgt->front_ranger_threshold - FRONT_RANGER_THRESHOLD) > 0.01) {
fprintf(stderr,
"fault: front-ranger-threshold is invalid %f\n",
mgt->front_ranger_threshold);
av.set(FRONT_RANGER_THRESHOLD);
this->fd_garcia.setNamedValue("front-ranger-threshold", &av);
av.set(1);
this->fd_garcia.setNamedValue("front-ranger-enable", &av);
}
av.set(FRONT_RANGER_THRESHOLD);
this->fd_garcia.setNamedValue("front-ranger-threshold", &av);
av.set(1);
this->fd_garcia.setNamedValue("front-ranger-enable", &av);
}
if (fabsf(mgt->rear_ranger_threshold - REAR_RANGER_THRESHOLD) > 0.01) {
fprintf(stderr,
"fault: rear-ranger-threshold is invalid %f\n",
mgt->rear_ranger_threshold);
if (fabsf(mgt->rear_ranger_threshold - REAR_RANGER_THRESHOLD) > 0.01) {
fprintf(stderr,
"fault: rear-ranger-threshold is invalid %f\n",
mgt->rear_ranger_threshold);
av.set(REAR_RANGER_THRESHOLD);
this->fd_garcia.setNamedValue("rear-ranger-threshold", &av);
av.set(1);
this->fd_garcia.setNamedValue("rear-ranger-enable", &av);
}
av.set(REAR_RANGER_THRESHOLD);
this->fd_garcia.setNamedValue("rear-ranger-threshold", &av);
av.set(1);
this->fd_garcia.setNamedValue("rear-ranger-enable", &av);
}
if (faults != 0) {
this->fd_callback->faultDetected(faults);
if (faults != 0) {
this->fd_callback->faultDetected(faults);
this->fd_fault_count += 1;
if (this->fd_fault_count >= MAX_FAULTS)
retval = false;
}
this->fd_fault_count += 1;
if (this->fd_fault_count >= MAX_FAULTS)
retval = false;
}
return retval;
return retval;
}
This diff is collapsed.
This diff is collapsed.
......@@ -30,106 +30,106 @@
class pilotClient
{
public:
/**
* Convenience typedef for a list of pointers to clients.
*/
typedef std::list<pilotClient *> list;
/**
* Convenience typedef for a list iterator.
*/
typedef std::list<pilotClient *>::iterator iterator;
/**
* Reference to the RMC client that is controlling the robot's body. Only
* one RMC client can be control at a time. This pointer will
* automatically be cleared by the destructor.
*/
static pilotClient *pc_rmc_client;
/**
* Construct a pilotClient with the given values.
*
* @param fd The file descriptor.
* @param wm The reference to the wheelManager that should be used to drive
* the robot.
*/
pilotClient(int fd, wheelManager &wm, dashboard &db);
/**
* Destruct a pilotClient object. This method will close the client
* connection and, if this was an RMC connection, it will stop any motion
* in progress and clear the pc_rmc_client field.
*/
virtual ~pilotClient();
/**
* @return A pointer to the mtp_handle that is connected to the peer.
*/
mtp_handle_t getHandle(void) { return this->pc_handle; };
/**
* @return The client's role, or zero if an initialization packet has not
* been received yet.
*/
mtp_role_t getRole(void) { return this->pc_role; };
/**
* Check an fd_set to see if the client's fd is set.
*
* @param readyfds The fd_set to check against.
* @return True if the client's fd is set, false otherwise.
*/
bool isFDSet(fd_set *readyfds)
{ return FD_ISSET(this->pc_handle->mh_fd, readyfds); }
/**
* Set the bit for the client's fd in the given fd_set.
*
* @param fds The fd_set to mutate.
*/
void setFD(fd_set *fds) { FD_SET(this->pc_handle->mh_fd, fds); }
/**
* Clear the bit for the client's fd in the given fd_set.
*
* @param fds The fd_set to mutate.
*/
void clearFD(fd_set *fds) { FD_CLR(this->pc_handle->mh_fd, fds); }
/**
* Handle a packet received from the client. Initially, an
* MTP_CONTROL_INIT packet is expected, so the server can determine the
* role of the client. After the init packet, an RMC client can send
* MTP_COMMAND_GOTO's, MTP_COMMAND_WHEELS and MTP_COMMAND_STOP's to move
* the robot. Any other packets are considered an error.
*
* @param mp The packet to dispatch.
* @return True if the packet was handled successfully, false otherwise.
*/
virtual bool handlePacket(mtp_packet_t *mp, list &notify_list);
public:
/**
* Convenience typedef for a list of pointers to clients.
*/
typedef std::list<pilotClient *> list;
/**
* Convenience typedef for a list iterator.
*/
typedef std::list<pilotClient *>::iterator iterator;
/**
* Reference to the RMC client that is controlling the robot's body. Only
* one RMC client can be control at a time. This pointer will
* automatically be cleared by the destructor.
*/
static pilotClient *pc_rmc_client;
/**
* Construct a pilotClient with the given values.
*
* @param fd The file descriptor.
* @param wm The reference to the wheelManager that should be used to drive
* the robot.
*/
pilotClient(int fd, wheelManager &wm, dashboard &db);
/**
* Destruct a pilotClient object. This method will close the client
* connection and, if this was an RMC connection, it will stop any motion
* in progress and clear the pc_rmc_client field.
*/
virtual ~pilotClient();
/**
* @return A pointer to the mtp_handle that is connected to the peer.
*/
mtp_handle_t getHandle(void) { return this->pc_handle; };
/**
* @return The client's role, or zero if an initialization packet has not
* been received yet.
*/
mtp_role_t getRole(void) { return this->pc_role; };
/**
* Check an fd_set to see if the client's fd is set.
*
* @param readyfds The fd_set to check against.
* @return True if the client's fd is set, false otherwise.
*/
bool isFDSet(fd_set *readyfds)
{ return FD_ISSET(this->pc_handle->mh_fd, readyfds); }
/**
* Set the bit for the client's fd in the given fd_set.
*
* @param fds The fd_set to mutate.
*/
void setFD(fd_set *fds) { FD_SET(this->pc_handle->mh_fd, fds); }
/**
* Clear the bit for the client's fd in the given fd_set.
*
* @param fds The fd_set to mutate.
*/
void clearFD(fd_set *fds) { FD_CLR(this->pc_handle->mh_fd, fds); }
/**
* Handle a packet received from the client. Initially, an
* MTP_CONTROL_INIT packet is expected, so the server can determine the
* role of the client. After the init packet, an RMC client can send
* MTP_COMMAND_GOTO's, MTP_COMMAND_WHEELS and MTP_COMMAND_STOP's to move
* the robot. Any other packets are considered an error.
*
* @param mp The packet to dispatch.
* @return True if the packet was handled successfully, false otherwise.
*/
virtual bool handlePacket(mtp_packet_t *mp, list &notify_list);
private:
private:
/**
* The MTP connection to the peer.
*/
mtp_handle_t pc_handle;
/**
* The MTP connection to the peer.
*/
mtp_handle_t pc_handle;
/**
* The role of the client, or zero if an initialization packet has not yet
* been received.
*/
mtp_role_t pc_role;
/**
* The role of the client, or zero if an initialization packet has not yet
* been received.
*/
mtp_role_t pc_role;
/**
* The wheelManager the RMC client will use to drive the robot.
*/
wheelManager &pc_wheel_manager;
/**
* The wheelManager the RMC client will use to drive the robot.
*/
wheelManager &pc_wheel_manager;
dashboard &pc_dashboard;
dashboard &pc_dashboard;
};
#endif
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment