Skip to content

Commit

Permalink
Implemented consuming for all primary types
Browse files Browse the repository at this point in the history
Also removed unused datatypes
  • Loading branch information
fmauch committed May 1, 2020
1 parent 5ffbe23 commit 0eae79d
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 246 deletions.
1 change: 1 addition & 0 deletions ur_robot_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ add_library(ur_robot_driver
#src/ur/robot_mode.cpp
src/primary/primary_package.cpp
src/primary/robot_message.cpp
src/primary/robot_state.cpp
src/primary/robot_message/version_message.cpp
src/primary/robot_state/kinematics_info.cpp
src/rtde/control_package_pause.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class AbstractPrimaryConsumer : public comm::IConsumer<PrimaryPackage>
}

// To be implemented in specific consumers
virtual bool consume(PrimaryPackage& pkg) = 0;
virtual bool consume(RobotMessage& pkg) = 0;
virtual bool consume(RobotState& pkg) = 0;
virtual bool consume(VersionMessage& pkg) = 0;
virtual bool consume(KinematicsInfo& pkg) = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class PrimaryPackage : public comm::URPackage<PackageHeader>
*
* \returns true on success
*/
virtual bool consumeWith(AbstractPrimaryConsumer& consumer);
virtual bool consumeWith(AbstractPrimaryConsumer& consumer) = 0;

/*!
* \brief Produces a human readable representation of the package object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
#include "ur_robot_driver/primary/package_header.h"
#include "ur_robot_driver/primary/robot_state.h"
#include "ur_robot_driver/primary/robot_message.h"
//#include "ur_robot_driver/primary/robot_state/robot_mode_data.h"
#include "ur_robot_driver/primary/robot_state/kinematics_info.h"
//#include "ur_robot_driver/primary/robot_state/master_board.h"
#include "ur_robot_driver/primary/robot_message/version_message.h"

namespace ur_driver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ class RobotMessage : public PrimaryPackage
*/
virtual bool parseWith(comm::BinParser& bp);

/*!
* \brief Consume this package with a specific consumer.
*
* \param consumer Placeholder for the consumer calling this
*
* \returns true on success
*/
virtual bool consumeWith(AbstractPrimaryConsumer& consumer);

/*!
* \brief Produces a human readable representation of the package object.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ class VersionMessage : public RobotMessage
*/
virtual bool parseWith(comm::BinParser& bp);

/*!
* \brief Consume this package with a specific consumer.
*
* \param consumer Placeholder for the consumer calling this
*
* \returns true on success
*/
virtual bool consumeWith(AbstractPrimaryConsumer& consumer);

/*!
* \brief Produces a human readable representation of the package object.
*
Expand Down
22 changes: 11 additions & 11 deletions ur_robot_driver/include/ur_robot_driver/primary/robot_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,23 @@ class RobotState : public PrimaryPackage
*
* \returns True, if the package was parsed successfully, false otherwise
*/
virtual bool parseWith(comm::BinParser& bp)
{
return PrimaryPackage::parseWith(bp);
}
virtual bool parseWith(comm::BinParser& bp);

/*!
* \brief Consume this specific package with a specific consumer.
*
* \param consumer Placeholder for the consumer calling this
*
* \returns true on success
*/
virtual bool consumeWith(AbstractPrimaryConsumer& consumer);

/*!
* \brief Produces a human readable representation of the package object.
*
* \returns A string representing the object
*/
virtual std::string toString() const
{
std::stringstream ss;
ss << "Type: " << static_cast<int>(state_type_) << std::endl;
ss << PrimaryPackage::toString();
return ss.str();
}
virtual std::string toString() const;

private:
RobotStateType state_type_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ class KinematicsInfo : public RobotState
*/
virtual bool parseWith(comm::BinParser& bp);

/*!
* \brief Consume this specific package with a specific consumer.
*
* \param consumer Placeholder for the consumer calling this
*
* \returns true on success
*/
virtual bool consumeWith(AbstractPrimaryConsumer& consumer);

/*!
* \brief Produces a human readable representation of the package object.
*
Expand Down

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions ur_robot_driver/src/primary/primary_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ bool PrimaryPackage::parseWith(comm::BinParser& bp)
return true;
}


bool PrimaryPackage ::consumeWith(AbstractPrimaryConsumer& consumer)
{
return consumer.consume(*this);
}

std::string PrimaryPackage::toString() const
{
std::stringstream ss;
Expand Down
6 changes: 6 additions & 0 deletions ur_robot_driver/src/primary/robot_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
//----------------------------------------------------------------------
#include "ur_robot_driver/primary/robot_message.h"
#include "ur_robot_driver/primary/abstract_primary_consumer.h"

namespace ur_driver
{
Expand All @@ -35,6 +36,11 @@ bool RobotMessage::parseWith(comm::BinParser& bp)
return true;
}

bool RobotMessage::consumeWith(AbstractPrimaryConsumer& consumer)
{
return consumer.consume(*this);
}

std::string RobotMessage::toString() const
{
std::stringstream ss;
Expand Down
6 changes: 6 additions & 0 deletions ur_robot_driver/src/primary/robot_message/version_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "ur_robot_driver/log.h"
#include "ur_robot_driver/primary/robot_message/version_message.h"
#include "ur_robot_driver/primary/abstract_primary_consumer.h"

namespace ur_driver
{
Expand All @@ -48,6 +49,11 @@ bool VersionMessage::parseWith(comm::BinParser& bp)
return true; // not really possible to check dynamic size packets
}

bool VersionMessage ::consumeWith(AbstractPrimaryConsumer& consumer)
{
return consumer.consume(*this);
}

std::string VersionMessage::toString() const
{
std::stringstream ss;
Expand Down
Loading

0 comments on commit 0eae79d

Please sign in to comment.