Skip to content

Commit 7ac2ba0

Browse files
committed
Improve component validation
1 parent 0adf352 commit 7ac2ba0

2 files changed

Lines changed: 208 additions & 76 deletions

File tree

vesc_hardware/include/vesc_hardware/vesc_hardware.hpp

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,17 @@ class VescHardware : public hardware_interface::SystemInterface {
143143
write(const rclcpp::Time & time, const rclcpp::Duration & period) override;
144144

145145
private:
146-
enum class ControlGroup
146+
enum class ComponentGroup
147147
{
148-
ROTOR = 0,
149-
SERVO = 1,
148+
ROTOR,
149+
SERVO,
150+
IMU,
151+
};
152+
153+
enum class ComponentType
154+
{
155+
JOINT,
156+
SENSOR,
150157
};
151158

152159
// VESC callback handlers
@@ -174,25 +181,32 @@ class VescHardware : public hardware_interface::SystemInterface {
174181
void populate_command_definitions();
175182
std::unordered_set<std::string> get_state_interface_groups() const;
176183
hardware_interface::CallbackReturn validate_and_mark_requested_state_interfaces(
177-
const hardware_interface::ComponentInfo & joint);
184+
const hardware_interface::ComponentInfo & component);
178185
hardware_interface::CallbackReturn validate_and_mark_requested_command_interfaces(
179-
const hardware_interface::ComponentInfo & joint);
186+
const hardware_interface::ComponentInfo & component);
187+
hardware_interface::CallbackReturn validate_status_and_command_mix(
188+
const hardware_interface::ComponentInfo & component, ComponentType type);
180189

181-
// Helper function to convert ControlGroup enum to string
182-
const char * control_group_to_string(ControlGroup group);
190+
const char * component_group_to_string(ComponentGroup group) const;
191+
const char * component_type_to_string(ComponentType type) const;
183192

184193
// Interface data structures
185194
struct StateInterfaceData
186195
{
187196
bool requested; // Whether this interface was requested in URDF
188197
std::function<double()> get_value; // Functor to retrieve current state value
198+
199+
ComponentType component_type; // Control type for this interface
200+
ComponentGroup component_group; // Control group for this interface
189201
};
190202

191203
struct CommandInterfaceData
192204
{
193205
bool requested; // Whether this interface was requested in URDF
194-
ControlGroup control_group; // Control group for this interface (ROTOR or SERVO)
195206
std::function<void(double)> set_command; // Functor to send command to hardware
207+
208+
ComponentType component_type; // Control type for this interface
209+
ComponentGroup component_group; // Control group for this interface
196210
};
197211

198212
// Hardware parameters

0 commit comments

Comments
 (0)