Skip to content

Commit 7e2d968

Browse files
Split mass and gravity_field
1 parent 6f19455 commit 7e2d968

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

control_toolbox/include/control_filters/gravity_compensation.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ class GravityCompensation : public filters::FilterBase<T>
5353
protected:
5454
void compute_internal_params()
5555
{
56-
cog_.vector.x = parameters_.CoG.pos[0];
57-
cog_.vector.y = parameters_.CoG.pos[1];
58-
cog_.vector.z = parameters_.CoG.pos[2];
59-
cst_ext_force_.vector.x = parameters_.CoG.force[0];
60-
cst_ext_force_.vector.y = parameters_.CoG.force[1];
61-
cst_ext_force_.vector.z = parameters_.CoG.force[2];
56+
cog_.vector.x = parameters_.tool.pos[0];
57+
cog_.vector.y = parameters_.tool.pos[1];
58+
cog_.vector.z = parameters_.tool.pos[2];
59+
cst_ext_force_.vector.x = parameters_.tool.gravity_field[0]*parameters_.tool.mass;
60+
cst_ext_force_.vector.y = parameters_.tool.gravity_field[1]*parameters_.tool.mass;
61+
cst_ext_force_.vector.z = parameters_.tool.gravity_field[2]*parameters_.tool.mass;
6262
};
6363

6464
private:

control_toolbox/src/control_filters/gravity_compensation_filter_parameters.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,23 @@ gravity_compensation_filter:
1515
not_empty<>: []
1616
},
1717
}
18-
CoG:
18+
tool:
1919
pos: {
2020
type: double_array,
2121
description: "Position of the CoG of tool attached to the FT sensor in the sensor frame.",
2222
validation: {
2323
fixed_size<>: 3
2424
},
2525
}
26-
force: {
26+
gravity_field: {
2727
type: double_array,
28-
description: "Specifies the constant field-induced force applied at the CoG of tool defined in fixed world frame, e.g [0, 0, -mass * 9.81].",
28+
description: "Specifies the gravity field defined in fixed world frame in m/s^2.",
29+
default_value: [0, 0, -9.81],
2930
validation: {
3031
fixed_size<>: 3
3132
},
3233
}
34+
mass: {
35+
type: double,
36+
description: "The mass of the tool in kg.",
37+
}

control_toolbox/test/control_filters/test_gravity_compensation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ TEST_F(GravityCompensationTest, TestGravityCompensationInvalidThenFixedParameter
4747
node_->get_node_logging_interface(), node_->get_node_parameters_interface()), std::exception);
4848

4949
// fixed wrong vector size
50-
node_->set_parameter(rclcpp::Parameter("CoG.pos", std::vector<double>({0.0, 0.0, 0.0})));
50+
node_->set_parameter(rclcpp::Parameter("tool.pos", std::vector<double>({0.0, 0.0, 0.0})));
5151
// all parameters correctly set AND second call to yet unconfigured filter
5252
ASSERT_TRUE(filter_->configure("", "TestGravityCompensation",
5353
node_->get_node_logging_interface(), node_->get_node_parameters_interface()));
5454

5555
// change a parameter
56-
node_->set_parameter(rclcpp::Parameter("CoG.pos", std::vector<double>({0.0, 0.0, 0.2})));
56+
node_->set_parameter(rclcpp::Parameter("tool.pos", std::vector<double>({0.0, 0.0, 0.2})));
5757
// accept second call to configure with valid parameters to already configured filter
5858
ASSERT_TRUE(filter_->configure("", "TestGravityCompensation",
5959
node_->get_node_logging_interface(), node_->get_node_parameters_interface()));

control_toolbox/test/control_filters/test_gravity_compensation_parameters.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ TestGravityCompensationAllParameters:
22
ros__parameters:
33
world_frame: world
44
sensor_frame: sensor
5-
CoG:
6-
force: [0.0, 0.0, -49.05]
5+
tool:
6+
gravity_field: [0.0, 0.0, -9.81]
7+
mass: 5.0
78
pos: [0.0, 0.0, 0.0]
89

910
TestGravityCompensationMissingParameters:
@@ -14,22 +15,25 @@ TestGravityCompensationInvalidThenFixedParameter:
1415
ros__parameters:
1516
world_frame: world
1617
sensor_frame: sensor
17-
CoG:
18-
force: [0.0, 0.0, -49.05]
18+
tool:
19+
gravity_field: [0.0, 0.0, -9.81]
20+
mass: 5.0
1921
pos: [0.0, 0.0]
2022

2123
TestGravityCompensationMissingTransform:
2224
ros__parameters:
2325
world_frame: world
2426
sensor_frame: sensor
25-
CoG:
26-
force: [0.0, 0.0, -49.05]
27+
tool:
28+
gravity_field: [0.0, 0.0, -9.81]
29+
mass: 5.0
2730
pos: [0.0, 0.0, 0.0]
2831

2932
TestGravityCompensationComputation:
3033
ros__parameters:
3134
world_frame: world
3235
sensor_frame: world
33-
CoG:
34-
force: [0.0, 0.0, -49.05]
36+
tool:
37+
gravity_field: [0.0, 0.0, -9.81]
38+
mass: 5.0
3539
pos: [0.0, 0.0, 0.0]

0 commit comments

Comments
 (0)