Skip to content

Commit

Permalink
Add print to waypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mpowelson authored and Levi-Armstrong committed Oct 6, 2020
1 parent 93004b1 commit feb3687
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ class CartesianWaypoint

int getType() const { return static_cast<int>(WaypointType::CARTESIAN_WAYPOINT); }

void print(const std::string& prefix = "") const
{
std::cout << prefix << "Cart WP: xyz=" << this->translation().x() << ", " << this->translation().y() << ", "
<< this->translation().z() << std::endl;
// TODO: Add rotation
};

tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const
{
Eigen::IOFormat eigen_format(Eigen::StreamPrecision, Eigen::DontAlignCols, " ", " ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ struct WaypointInnerBase

virtual int getType() const = 0;

virtual void print(const std::string& prefix) const = 0;

virtual tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const = 0;

// This is not required for user defined implementation
Expand Down Expand Up @@ -74,6 +76,8 @@ struct WaypointInner final : WaypointInnerBase

int getType() const final { return waypoint_.getType(); }

void print(const std::string& prefix) const final { waypoint_.print(prefix); }

tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const final { return waypoint_.toXML(doc); }

void* recover() final { return &waypoint_; }
Expand Down Expand Up @@ -134,6 +138,8 @@ class Waypoint

int getType() const { return waypoint_->getType(); }

void print(const std::string& prefix = "") const { waypoint_->print(prefix); }

tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const { return waypoint_->toXML(doc); }

template <typename T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ class JointWaypoint

int getType() const { return static_cast<int>(WaypointType::JOINT_WAYPOINT); }

void print(const std::string& prefix = "") const
{
std::cout << prefix << "Joint WP: " << this->transpose() << std::endl;
};

tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const
{
Eigen::IOFormat eigen_format(Eigen::StreamPrecision, Eigen::DontAlignCols, " ", " ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class NullWaypoint

int getType() const;

void print(const std::string& prefix = "") const;

tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const;
};
} // namespace tesseract_planning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class StateWaypoint

int getType() const;

void print(const std::string& prefix = "") const;

tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const;

/** @brief The joint corresponding to the position vector. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ void MoveInstruction::setDescription(const std::string& description) { descripti
void MoveInstruction::print(std::string prefix) const
{
std::cout << prefix + "Move Instruction, Type: " << getType() << ", Plan Type: " << static_cast<int>(move_type_)
<< ", Waypoint Type:" << getWaypoint().getType() << ", Description: " << getDescription() << std::endl;
<< ", ";
getWaypoint().print();
std::cout << ", Description: " << getDescription() << std::endl;
}

void MoveInstruction::setMoveType(MoveInstructionType move_type) { move_type_ = move_type; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
* limitations under the License.
*/

#include <tesseract_common/macros.h>
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#include <iostream>
TESSERACT_COMMON_IGNORE_WARNINGS_POP

#include <tesseract_command_language/null_waypoint.h>
#include <tesseract_command_language/waypoint_type.h>

Expand All @@ -33,6 +38,8 @@ NullWaypoint::NullWaypoint(const tinyxml2::XMLElement& /*xml_element*/) {}

int NullWaypoint::getType() const { return static_cast<int>(WaypointType::NULL_WAYPOINT); }

void NullWaypoint::print(const std::string& prefix) const { std::cout << prefix << "Null WP"; };

tinyxml2::XMLElement* NullWaypoint::toXML(tinyxml2::XMLDocument& doc) const
{
tinyxml2::XMLElement* xml_waypoint = doc.NewElement("Waypoint");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ void PlanInstruction::setDescription(const std::string& description) { descripti
void PlanInstruction::print(std::string prefix) const
{
std::cout << prefix + "Plan Instruction, Type: " << getType() << ", Plan Type: " << static_cast<int>(plan_type_)
<< ", Waypoint Type:" << getWaypoint().getType() << ", Description: " << getDescription() << std::endl;
<< ", ";
getWaypoint().print();
std::cout << ", Description: " << getDescription() << std::endl;
}

PlanInstructionType PlanInstruction::getPlanType() const { return plan_type_; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ StateWaypoint::StateWaypoint(const tinyxml2::XMLElement& xml_element)

int StateWaypoint::getType() const { return static_cast<int>(WaypointType::STATE_WAYPOINT); }

void StateWaypoint::print(const std::string& prefix) const
{
std::cout << prefix << "State WP: Pos=" << position.transpose() << std::endl;
}

tinyxml2::XMLElement* StateWaypoint::toXML(tinyxml2::XMLDocument& doc) const
{
Eigen::IOFormat eigen_format(Eigen::StreamPrecision, Eigen::DontAlignCols, " ", " ");
Expand Down

0 comments on commit feb3687

Please sign in to comment.