@@ -58,6 +58,15 @@ GenericHWInterface::GenericHWInterface(const ros::NodeHandle& nh, urdf::Model* u
58
58
nh_, " hardware_interface" ); // TODO(davetcoleman): change the namespace to "generic_hw_interface" aka name_
59
59
std::size_t error = 0 ;
60
60
error += !rosparam_shortcuts::get (name_, rpnh, " joints" , joint_names_);
61
+
62
+ if (rpnh.hasParam (" initial_state" ))
63
+ {
64
+ error += !rosparam_shortcuts::get (name_, rpnh, " initial_state" , initial_state_);
65
+
66
+ if (initial_state_.size () != joint_names_.size ())
67
+ ROS_WARN (" skipping initial_state, does not match joints size" );
68
+ }
69
+
61
70
rosparam_shortcuts::shutdownIfError (name_, error);
62
71
}
63
72
@@ -81,6 +90,13 @@ void GenericHWInterface::init()
81
90
joint_velocity_limits_.resize (num_joints_, 0.0 );
82
91
joint_effort_limits_.resize (num_joints_, 0.0 );
83
92
93
+ // Initialize robot state
94
+ if (initial_state_.size () != num_joints_)
95
+ initial_state_.resize (joint_names_.size (), 0.0 );
96
+
97
+ for (std::size_t i = 0 ; i < num_joints_; ++i)
98
+ joint_position_[i] = initial_state_[i];
99
+
84
100
// Initialize interfaces for each joint
85
101
for (std::size_t joint_id = 0 ; joint_id < num_joints_; ++joint_id)
86
102
{
0 commit comments