Skip to content

Commit

Permalink
Move lowpass filter code to header and fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmout committed Aug 1, 2018
1 parent db8094a commit 888cb3d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 17 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ add_library(franka SHARED
src/load_calculations.cpp
src/log.cpp
src/logger.cpp
src/lowpass_filter.cpp
src/model.cpp
src/model_library.cpp
src/network.cpp
Expand Down
7 changes: 6 additions & 1 deletion include/franka/lowpass_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by the Apache-2.0 license, see LICENSE
#pragma once

#include <cmath>

/**
* @file lowpass_filter.h
* Contains functions for filtering signals with a low-pass filter.
Expand All @@ -26,6 +28,9 @@ constexpr double kDefaultCutoffFrequency = 100.0;
*
* @return Filtered value.
*/
double lowpassFilter(double sample_time, double y, double y_last, double cutoff_frequency);
inline double lowpassFilter(double sample_time, double y, double y_last, double cutoff_frequency) {
double gain = sample_time / (sample_time + (1.0 / (2.0 * M_PI * cutoff_frequency)));
return gain * y + (1 - gain) * y_last;
}

} // namespace franka
1 change: 1 addition & 0 deletions include/franka/robot.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class Robot {
* This could distort your motion!
* @param[in] cutoff_frequency Cutoff frequency for a first order lowpass filter applied on
* the user commanded signal.
*
* @throw ControlException if an error related to torque control or motion generation occurred.
* @throw InvalidOperationException if a conflicting operation is already running.
* @throw NetworkException if the connection is lost, e.g. after a timeout.
Expand Down
14 changes: 0 additions & 14 deletions src/lowpass_filter.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion test/control_loop_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include <gmock/gmock.h>

#include <franka/lowpass_filter.h>
#include "control_loop.h"
#include "franka/lowpass_filter.h"
#include "motion_generator_traits.h"

#include "helpers.h"
Expand Down

0 comments on commit 888cb3d

Please sign in to comment.