1
0
mirror of https://gitlab.com/obbart/universal_robots_ros_driver.git synced 2026-04-10 01:50:46 +02:00

Parse unknown states to default RobotStates

This commit is contained in:
Felix Mauch
2019-04-10 10:01:17 +02:00
parent 4dc4cc0fb0
commit fcc1e62ab5
5 changed files with 37 additions and 12 deletions

View File

@@ -46,14 +46,17 @@ public:
/*!
* \brief Creates a new PrimaryPackage object.
*/
PrimaryPackage() = default;
PrimaryPackage() : buffer_length_(0)
{
}
virtual ~PrimaryPackage() = default;
virtual bool parseWith(comm::BinParser& bp);
virtual std::string toString() const;
private:
std::string buffer_;
protected:
std::unique_ptr<uint8_t> buffer_;
size_t buffer_length_;
};
} // namespace primary_interface

View File

@@ -144,9 +144,9 @@ private:
case robot_state_type::MASTERBOARD_DATA:
return new MBD;*/
case RobotStateType::KINEMATICS_INFO:
return new KinematicsInfo;
return new KinematicsInfo(type);
default:
return nullptr;
return new RobotState(type);
}
}

View File

@@ -53,25 +53,31 @@ enum class RobotStateType : uint8_t
};
/*!
* \brief Abstract class for a RobotState msg. This will never be instanciated, but the underlying
* data packages will be used directly.
* \brief Base class for a RobotState data packages will be used directly.
*/
class RobotState : public PrimaryPackage
{
public:
RobotState() = default;
RobotState() = delete;
RobotState(const RobotStateType type) : state_type_(type)
{
}
virtual ~RobotState() = default;
virtual bool parseWith(comm::BinParser& bp)
{
return true;
return PrimaryPackage::parseWith(bp);
}
virtual std::string toString() const
{
return std::string();
std::stringstream ss;
ss << "Type: " << static_cast<int>(state_type_) << std::endl;
ss << PrimaryPackage::toString();
return ss.str();
}
private:
RobotStateType state_type_;
};
} // namespace primary_interface