Skip to content

Commit 7eb38ca

Browse files
committed
initialize generic system
1 parent 03207a8 commit 7eb38ca

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

.clang-format

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ DerivePointerAlignment: false
1212
PointerAlignment: Middle
1313
ReflowComments: true
1414
IncludeBlocks: Preserve
15-
InsertBraces: true
1615
...

mock_hardware/include/mock_components/generic_system.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef MOCK_COMPONENTS__GENERIC_SYSTEM_HPP_
1818
#define MOCK_COMPONENTS__GENERIC_SYSTEM_HPP_
1919

20+
#include <limits>
2021
#include <memory>
2122
#include <string>
2223
#include <vector>
@@ -105,13 +106,11 @@ class HARDWARE_INTERFACE_PUBLIC GenericSystem : public hardware_interface::Syste
105106
// And StateInterface(joint_interface.state_)
106107
struct InterfaceData
107108
{
108-
// TODO(Manuel) set initial to NaN and on_init initialize to given value in info or 0.0
109109
explicit InterfaceData(const std::string & name)
110110
: name_(name),
111-
command_(0.0), // command_(std::numeric_limits<double>::quiet_NaN()),
112-
state_(0.0), // state_(std::numeric_limits<double>::quiet_NaN()),
113-
transmission_passthrough_(
114-
0.0) // transmission_passthrough_(std::numeric_limits<double>::quiet_NaN())
111+
command_(std::numeric_limits<double>::quiet_NaN()),
112+
state_(std::numeric_limits<double>::quiet_NaN()),
113+
transmission_passthrough_(std::numeric_limits<double>::quiet_NaN())
115114
{
116115
}
117116

mock_hardware/src/generic_system.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,17 @@ CallbackReturn GenericSystem::on_init(const hardware_interface::HardwareInfo & i
309309
actuator_handles.push_back(actuator_handle);
310310
}
311311

312-
// TODO(Manuel) set initial to NaN and on_init initialize to given value in info or 0.0
312+
for (auto & joint_interface : joint_interfaces_)
313+
{
314+
joint_interface.state_ = 0.0;
315+
joint_interface.command_ = 0.0;
316+
}
317+
318+
for (auto & actuator_interface : actuator_interfaces_)
319+
{
320+
actuator_interface.state_ = 0.0;
321+
actuator_interface.command_ = 0.0;
322+
}
313323

314324
/// @note no need to store the joint and actuator handles, the transmission
315325
/// will keep whatever info it needs after is done with them

0 commit comments

Comments
 (0)