#[cfg(feature = "urdf")]
use crate::to_rdf::to_urdf::{ToURDF, URDFTarget};
#[cfg(feature = "xml")]
use quick_xml::events::BytesText;
#[non_exhaustive]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum TransmissionHardwareInterface {
JointCommandInterface,
EffortJointInterface,
VelocityJointInterface,
PositionJointInterface,
JointStateInterface,
ActuatorStateInterface,
EffortActuatorInterface,
VelocityActuatorInterface,
PositionActuatorInterface,
PosVelJointInterface,
PosVelAccJointInterface,
ForceTorqueSensorInterface,
IMUSensorInterface,
}
impl TransmissionHardwareInterface {
#[cfg(feature = "urdf")]
fn as_urdf_hardware_interface_type(&self, urdf_target: URDFTarget) -> String {
let mut result = String::from(match urdf_target {
URDFTarget::Standard => "hardware_interface/",
URDFTarget::Gazebo => "",
});
match self {
Self::JointCommandInterface => result.push_str("JointCommandInterface"),
Self::EffortJointInterface => result.push_str("EffortJointInterface"),
Self::VelocityJointInterface => result.push_str("VelocityJointInterface"),
Self::PositionJointInterface => result.push_str("PositionJointInterface"),
Self::JointStateInterface => result.push_str("JointStateInterface"),
Self::ActuatorStateInterface => result.push_str("ActuatorStateInterface"),
Self::EffortActuatorInterface => result.push_str("EffortActuatorInterface"),
Self::VelocityActuatorInterface => result.push_str("VelocityActuatorInterface"),
Self::PositionActuatorInterface => result.push_str("PositionActuatorInterface"),
Self::PosVelJointInterface => result.push_str("PosVelJointInterface"),
Self::PosVelAccJointInterface => result.push_str("PosVelAccJointInterface"),
Self::ForceTorqueSensorInterface => result.push_str("ForceTorqueSensorInterface"),
Self::IMUSensorInterface => result.push_str("IMUSensorInterface"),
};
result
}
}
#[cfg(feature = "urdf")]
impl ToURDF for TransmissionHardwareInterface {
fn to_urdf(
&self,
writer: &mut quick_xml::Writer<std::io::Cursor<Vec<u8>>>,
urdf_config: &crate::to_rdf::to_urdf::URDFConfig,
) -> Result<(), quick_xml::Error> {
writer
.create_element("hardwareInterface")
.write_text_content(BytesText::new(
self.as_urdf_hardware_interface_type(urdf_config.urdf_target)
.as_str(),
))?;
Ok(())
}
}