@@ -72,7 +72,7 @@ std::unique_ptr<march::MarchRobot> HardwareBuilder::createMarchRobot()
72
72
auto pdo_interface = march::PdoInterfaceImpl::create ();
73
73
auto sdo_interface = march::SdoInterfaceImpl::create ();
74
74
75
- auto usb_master = march::UsbMaster ();
75
+ march::UsbMaster usb_master = march::UsbMaster ();
76
76
77
77
std::vector<march::Joint> joints = this ->createJoints (config[" joints" ], pdo_interface, sdo_interface, usb_master);
78
78
@@ -98,7 +98,7 @@ std::unique_ptr<march::MarchRobot> HardwareBuilder::createMarchRobot()
98
98
march::Joint HardwareBuilder::createJoint (const YAML::Node& joint_config, const std::string& joint_name,
99
99
const urdf::JointConstSharedPtr& urdf_joint,
100
100
march::PdoInterfacePtr pdo_interface, march::SdoInterfacePtr sdo_interface,
101
- march::UsbMaster usb_master)
101
+ march::UsbMaster& usb_master)
102
102
{
103
103
ROS_DEBUG (" Starting creation of joint %s" , joint_name.c_str ());
104
104
if (!urdf_joint)
@@ -152,7 +152,7 @@ march::Joint HardwareBuilder::createJoint(const YAML::Node& joint_config, const
152
152
std::unique_ptr<march::OdriveMotor> HardwareBuilder::createOdrive (const YAML::Node& odrive_config,
153
153
march::ActuationMode mode,
154
154
const urdf::JointConstSharedPtr& urdf_joint,
155
- march::UsbMaster usb_master)
155
+ march::UsbMaster& usb_master)
156
156
{
157
157
if (!odrive_config || !urdf_joint)
158
158
{
@@ -165,11 +165,25 @@ std::unique_ptr<march::OdriveMotor> HardwareBuilder::createOdrive(const YAML::No
165
165
YAML::Node absolute_encoder_config = odrive_config[" absoluteEncoder" ];
166
166
std::string axis = odrive_config[" axis" ].as <std::string>();
167
167
std::string serial_number = odrive_config[" serial_number" ].as <std::string>();
168
- std::string json_configuration_path = ros::package::getPath (" march_hardware" ).append (" /config/march_odrive.json" );
168
+
169
+ std::string configuration_path =
170
+ ros::package::getPath (" march_hardware" ).append (" /config/" + urdf_joint->name + " .json" );
171
+
172
+ std::ifstream file (configuration_path);
173
+
174
+ if (file.fail ())
175
+ {
176
+ throw std::runtime_error (" Could not open configuration file for the odrive" );
177
+ }
178
+
179
+ if (file.is_open ())
180
+ {
181
+ file.close ();
182
+ }
169
183
170
184
auto odrive_endpoint = usb_master.getSerialConnection (serial_number);
171
185
172
- return std::make_unique<march::OdriveMotor>(axis, odrive_endpoint, mode, json_configuration_path );
186
+ return std::make_unique<march::OdriveMotor>(axis, odrive_endpoint, mode, configuration_path );
173
187
}
174
188
175
189
std::unique_ptr<march::IMotionCube> HardwareBuilder::createIMotionCube (const YAML::Node& imc_config,
@@ -329,7 +343,7 @@ void HardwareBuilder::initUrdf()
329
343
std::vector<march::Joint> HardwareBuilder::createJoints (const YAML::Node& joints_config,
330
344
march::PdoInterfacePtr pdo_interface,
331
345
march::SdoInterfacePtr sdo_interface,
332
- march::UsbMaster usb_master) const
346
+ march::UsbMaster& usb_master) const
333
347
{
334
348
std::vector<march::Joint> joints;
335
349
for (const YAML::Node& joint_config : joints_config)
0 commit comments