Woolfrey / software_robot_library

Custom classes for robot control.
GNU General Public License v3.0
2 stars 1 forks source link

Replace output arguments with data structures #98

Closed Woolfrey closed 9 months ago

Woolfrey commented 9 months ago

In the Joint class, declare a data structure:

struct Limits
{
         DataType lower;
         DataType upper;
}

In the TrajectoryBase class:

struct State
{
          Eigen::Vector<DataType,Eigen::Dynamic> position;
          Eigen::Vector<DataType,Eigen::Dynamic> velocity;
          Eigen::Vector<DataType,Eigen::Dynamic> acceleration;
}

In the CartesianTrajectory class:

struct CartesianState
{
          Pose pose;
          Eigen::Vector<DataType,6> twist;
          Eigen::Vector<DataType,6> acceleration;
}

Structured bindings can then be used to obtain the outputs:

auto[pose, twist, accel] = cartesianTrajectory.query_state(time);
Eigen::VectorXd jointControl = controller.resolve_endpoint_motion(pose,twist,accel);
Woolfrey commented 9 months ago

Data structures create in Joint.h, TrajectoryBase.h, and CartesianTrajectory.h respectively.

Might be a good idea in future to move data structures to a separate header file?