Skip to content

Commit

Permalink
Move resolve_center_of_pressure into its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnimmer-tri committed Oct 29, 2017
1 parent f5186ca commit cb7db41
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 42 deletions.
10 changes: 10 additions & 0 deletions drake/multibody/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ drake_cc_library(
],
)

drake_cc_library(
name = "resolve_center_of_pressure",
srcs = ["resolve_center_of_pressure.cc"],
hdrs = ["resolve_center_of_pressure.h"],
deps = [
"@eigen",
],
)

drake_cc_library(
name = "rigid_body_constraint",
srcs = ["rigid_body_constraint.cc"],
Expand Down Expand Up @@ -176,6 +185,7 @@ drake_cc_library(
visibility = [],
deps = [
":kinematics_cache",
":resolve_center_of_pressure",
":rigid_body",
":rigid_body_actuator",
":rigid_body_frame",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,8 @@
/*
* drakeUtil.cpp
*
* Created on: Jun 19, 2013
* Author: russt
*/

#include "drake/util/drakeUtil.h"
#include "drake/multibody/resolve_center_of_pressure.h"

#include <limits>
#include <stdexcept>

#include <Eigen/Dense>

void baseZeroToBaseOne(std::vector<int>& vec) {
for (std::vector<int>::iterator iter = vec.begin(); iter != vec.end(); iter++)
(*iter)++;
}

double angleAverage(double theta1, double theta2) {
// Computes the average between two angles by averaging points on the unit
// circle and taking the arctan of the result.
// see: http://en.wikipedia.org/wiki/Mean_of_circular_quantities
// theta1 is a scalar or column vector of angles (rad)
// theta2 is a scalar or column vector of angles (rad)

double x_mean = 0.5 * (cos(theta1) + cos(theta2));
double y_mean = 0.5 * (sin(theta1) + sin(theta2));

double angle_mean = atan2(y_mean, x_mean);

return angle_mean;
}

template <typename DerivedTorque, typename DerivedForce, typename DerivedNormal,
typename DerivedPoint>
std::pair<Eigen::Vector3d, double> resolveCenterOfPressure(
Expand Down
15 changes: 15 additions & 0 deletions drake/multibody/resolve_center_of_pressure.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include <utility>

#include <Eigen/Dense>

// TODO(siyuan.feng): Cleanup the naming according to the style guide.

template <typename DerivedTorque, typename DerivedForce, typename DerivedNormal,
typename DerivedPoint>
std::pair<Eigen::Vector3d, double> resolveCenterOfPressure(
const Eigen::MatrixBase<DerivedTorque>& torque,
const Eigen::MatrixBase<DerivedForce>& force,
const Eigen::MatrixBase<DerivedNormal>& normal,
const Eigen::MatrixBase<DerivedPoint>& point_on_contact_plane);
2 changes: 1 addition & 1 deletion drake/multibody/rigid_body_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include "drake/multibody/joints/fixed_joint.h"
#include "drake/multibody/joints/floating_base_types.h"
#include "drake/multibody/kinematics_cache-inl.h"
#include "drake/multibody/resolve_center_of_pressure.h"
#include "drake/util/drakeGeometryUtil.h"
#include "drake/util/drakeUtil.h"

using Eigen::AutoDiffScalar;
using Eigen::Dynamic;
Expand Down
1 change: 1 addition & 0 deletions drake/systems/controllers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ drake_cc_library(
"//drake/math:autodiff",
"//drake/math:expmap",
"//drake/math:geometric_transform",
"//drake/multibody:resolve_center_of_pressure",
"//drake/multibody:rigid_body_tree",
"//drake/util",
],
Expand Down
1 change: 1 addition & 0 deletions drake/systems/controllers/controlUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "drake/math/expmap.h"
#include "drake/math/quaternion.h"
#include "drake/math/rotation_matrix.h"
#include "drake/multibody/resolve_center_of_pressure.h"
#include "drake/util/drakeGeometryUtil.h"
#include "drake/util/drakeUtil.h"

Expand Down
1 change: 0 additions & 1 deletion drake/util/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ drake_cc_library(
name = "util",
srcs = [
"drakeGeometryUtil.cpp",
"drakeUtil.cpp",
],
hdrs = [
"drakeGeometryUtil.h",
Expand Down
2 changes: 1 addition & 1 deletion drake/util/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_library(drakeUtil drakeUtil.cpp drakeUtil.h)
add_library(drakeUtil drakeUtil.h)
target_link_libraries(drakeUtil Eigen3::Eigen)
drake_install_libraries(drakeUtil)
drake_install_headers(drakeUtil.h)
Expand Down
9 changes: 0 additions & 9 deletions drake/util/drakeUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,3 @@ void addOffset(std::vector<T>& v, const T& offset) {
void baseZeroToBaseOne(std::vector<int>& vec);

double angleAverage(double theta1, double theta2);

template <typename DerivedTorque, typename DerivedForce, typename DerivedNormal,
typename DerivedPoint>
std::pair<Eigen::Vector3d, double> resolveCenterOfPressure(
const Eigen::MatrixBase<DerivedTorque>& torque,
const Eigen::MatrixBase<DerivedForce>& force,
const Eigen::MatrixBase<DerivedNormal>& normal,
const Eigen::MatrixBase<DerivedPoint>& point_on_contact_plane);

0 comments on commit cb7db41

Please sign in to comment.