Skip to content

Commit 0cfd678

Browse files
committed
Re-add getCSetting fix
1 parent d26e68a commit 0cfd678

File tree

7 files changed

+31
-8
lines changed

7 files changed

+31
-8
lines changed

Diff for: include/barrett/cdlbt/interp.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ enum bt_interp_type {
7575

7676
/** This is the GSL interpolator type object to be used with
7777
* gsl_interp_alloc() when a bt_interp type is to be used. */
78-
const gsl_interp_type * bt_interp;
78+
extern const gsl_interp_type * bt_interp;
7979

8080

8181
/** This function is used to set the types of the two endpoints before the

Diff for: include/barrett/detail/libconfig_utils.h

+18
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,24 @@ inline double numericToDouble(const libconfig::Setting& setting)
6060

6161
}
6262

63+
// Access private config_setting_t* in libconfig::Setting
64+
// See:
65+
// https://stackoverflow.com/questions/424104/can-i-access-private-members-from-outside-the-class-without-using-friends
66+
template <typename Tag, typename Tag::type M> struct PrivateAccess {
67+
friend typename Tag::type get(Tag) { return M; }
68+
};
69+
70+
// tag used to access A::member
71+
struct Settings_Access {
72+
typedef config_setting_t *libconfig::Setting::*type;
73+
friend type get(Settings_Access);
74+
};
75+
76+
template struct PrivateAccess<Settings_Access, &libconfig::Setting::_setting>;
77+
78+
inline config_setting_t *getCSetting(const libconfig::Setting &setting) {
79+
return setting.*get(Settings_Access());
80+
}
6381

6482
}
6583
}

Diff for: include/barrett/math/detail/dynamics-inl.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <barrett/units.h>
1111
#include <barrett/cdlbt/dynamics.h>
12+
#include <barrett/detail/libconfig_utils.h>
1213

1314

1415
namespace barrett {
@@ -18,7 +19,7 @@ namespace math {
1819
template<size_t DOF>
1920
Dynamics<DOF>::Dynamics(const libconfig::Setting& setting)
2021
{
21-
if (bt_dynamics_create(&impl, setting.getCSetting(), DOF)) {
22+
if (bt_dynamics_create(&impl, barrett::detail::getCSetting(setting), DOF)) {
2223
throw(std::runtime_error("(math::Dynamics::Dynamics): Couldn't initialize Dynamics struct."));
2324
}
2425
}

Diff for: include/barrett/math/detail/kinematics-inl.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <barrett/units.h>
1111
#include <barrett/cdlbt/kinematics.h>
12+
#include <barrett/detail/libconfig_utils.h>
1213

1314

1415
namespace barrett {
@@ -18,7 +19,7 @@ namespace math {
1819
template<size_t DOF>
1920
Kinematics<DOF>::Kinematics(const libconfig::Setting& setting)
2021
{
21-
if (bt_kinematics_create(&impl, setting.getCSetting(), DOF)) {
22+
if (bt_kinematics_create(&impl, barrett::detail::getCSetting(setting), DOF)) {
2223
throw(std::runtime_error("(math::Kinematics::Kinematics): Couldn't initialize Kinematics struct."));
2324
}
2425
}

Diff for: include/barrett/systems/gravity_compensator.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@
3535
#include <Eigen/Core>
3636
#include <libconfig.h++>
3737

38+
#include <barrett/cdlbt/calgrav.h>
3839
#include <barrett/detail/ca_macro.h>
40+
#include <barrett/detail/libconfig_utils.h>
3941
#include <barrett/units.h>
40-
#include <barrett/cdlbt/calgrav.h>
4142

4243
#include <barrett/systems/abstract/system.h>
4344
#include <barrett/systems/abstract/single_io.h>
@@ -60,7 +61,7 @@ class GravityCompensator : public System,
6061
const std::string& sysName = "GravityCompensator") :
6162
System(sysName), KinematicsInput<DOF>(this), SingleOutput<jt_type>(this), impl(NULL), data()
6263
{
63-
bt_calgrav_create(&impl, setting.getCSetting(), DOF);
64+
bt_calgrav_create(&impl, barrett::detail::getCSetting(setting), DOF);
6465
}
6566

6667
bool setGravity(double new_grav) {

Diff for: programs/gravitycal.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include <barrett/cdlbt/gsl.h>
5050
#include <barrett/cdlbt/kinematics.h>
5151
#include <barrett/cdlbt/calgrav.h>
52+
#include <barrett/detail/libconfig_utils.h>
5253

5354
#include <barrett/config.h>
5455

@@ -491,8 +492,8 @@ int wam_main(int argc, char** argv, ProductManager& pm, systems::Wam<DOF>& wam)
491492
* in torques[] and positions[] */
492493

493494
libconfig::Setting& setting = pm.getConfig().lookup(pm.getWamDefaultConfigPath());
494-
bt_kinematics_create(&kin, setting["kinematics"].getCSetting(), n);
495-
bt_calgrav_create(&grav, setting["gravity_compensation"].getCSetting(), n);
495+
bt_kinematics_create(&kin, barrett::detail::getCSetting(setting["kinematics"]), n);
496+
bt_calgrav_create(&grav, barrett::detail::getCSetting(setting["gravity_compensation"]), n);
496497

497498
/* Make the nLL matrix */
498499
nLL = gsl_matrix_calloc(3 * num_poses, 3 + 2 * num_poses);

Diff for: tests/systems/tool_orientation.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <barrett/systems/tool_orientation_controller.h>
2020
#include <barrett/cdlbt/dynamics.h>
2121
#include <barrett/cdlbt/control_cartesian_xyz_q.h>
22+
#include <barrett/detail/libconfig_utils.h>
2223
#include "exposed_io_system.h"
2324

2425

@@ -74,7 +75,7 @@ TEST(ToolOrientationTest, Blah2) {
7475

7576
struct bt_control_cartesian_xyz_q * con = NULL;
7677
bt_control_cartesian_xyz_q_create(&con,
77-
config.lookup("wam.control_cartesian_xyz_q").getCSetting(),
78+
barrett::detail::getCSetting(config.lookup("wam.control_cartesian_xyz_q")),
7879
kin.impl, NULL);
7980
ASSERT_TRUE(con != NULL);
8081

0 commit comments

Comments
 (0)