Skip to content

Commit

Permalink
Merge remote-tracking branch 'issue/servo-monitor'
Browse files Browse the repository at this point in the history
  • Loading branch information
paulosousadias committed Sep 24, 2024
2 parents 240160c + 0289ea5 commit 67773fd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/DUNE/Monitors/ServoPositionMonitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ namespace DUNE
return false;
}

//! Reset the values
void
reset()
{
m_valid_last = false;
}

private:
//! DelayedTrigger object for position fault detection
DelayedTrigger<T>* m_pos_trigger;
Expand Down
16 changes: 16 additions & 0 deletions src/Monitors/Servos/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ namespace Monitors
static const unsigned c_servo_count = 4;
//! Error timeout
static const float c_error_timeout = 5.0;
//! Valid SetServoPosition timeout
static const float c_valid_set_servo_position_timeout = 0.01;

enum FaultBits
{
Expand Down Expand Up @@ -114,6 +116,8 @@ namespace Monitors
uint8_t m_on_fault[c_servo_count];
//! Timer for error timeout
Time::Counter<float> m_timer;
//! Timer for servo position fault detection timeout
Time::Counter<float> m_timer_set_servo;
//! Queue for error reports.
std::queue<double> m_queue[c_servo_count];
//! Major failure in one of the servos.
Expand Down Expand Up @@ -287,6 +291,7 @@ namespace Monitors
m_set_servo[i] = 0.0;
m_on_fault[i] = FT_NONE;
m_timer.setTop(c_error_timeout);
m_timer_set_servo.setTop(c_valid_set_servo_position_timeout);
}

if (m_args.pos_fault_detect || m_args.curr_fault_detect)
Expand All @@ -301,6 +306,16 @@ namespace Monitors

if (m_args.pos_fault_detect)
{
if (m_timer_set_servo.overflow())
{
int id = msg->id;
if (m_pos_monitor[id] != NULL)
{
m_pos_monitor[id]->reset();
}
return;
}

testPositionFaults(msg);
m_timer.reset();
}
Expand All @@ -313,6 +328,7 @@ namespace Monitors
return;

m_set_servo[msg->id] = msg->value;
m_timer_set_servo.reset();
}

void
Expand Down

0 comments on commit 67773fd

Please sign in to comment.