cmvr-es/cmvr-es/algorithms/planner/joint/joint_path_planner.h
lgv 37a62fb3e3 feat(arm): add collision-aware planning and refactor motion control
Integrate OMPL RRTConnect and quintic B-spline smoothing into moveP, reuse
the B-spline trajectory generator for moveJ, and remove the TOPPRA paths
and dependencies. Separate joint and Cartesian planners, smoothers, and
the standalone curve math library.

Move speedL execution into SpeedLExecutor, tighten velocity QP feasibility,
and add adaptive speed reduction, braking recovery, feedback-derived TCP
velocity, and grouped cyclic velocity submission. Improve MuJoCo control
cycle synchronization and camera streaming.

Centralize kinematics and collision geometry in RobotModel, expose box
obstacles through CollisionChecker, and extract SelfCollisionMonitor for
protective stops and recovery. Add cancellable moveP pre-approach and
configurable failure recovery to the touch workflow, with updated configs,
documentation, and regression coverage.

Validation: recorded -j8 build and 133 passing tests on 2026-10-08, including
headless MuJoCo checks for eight target poses and seven moveJ returns.
Static scene configuration removal passed 27 follow-up tests and six arm
configuration parses. Staged diff and shell syntax checks pass; no new
hardware tests were run for this commit.
2026-10-13 09:18:06 +08:00

63 lines
1.8 KiB
C++

#ifndef CMVR_ES_JOINT_PATH_PLANNER_H
#define CMVR_ES_JOINT_PATH_PLANNER_H
#include <cstddef>
#include <functional>
#include <string>
#include <vector>
namespace cmvr {
using JointPath = std::vector<std::vector<double>>;
struct JointPathRequest {
// All vectors use the same joint order and radians. Bounded revolute joints
// only; continuous joints require a different state space.
std::vector<double> start;
std::vector<double> goal;
std::vector<double> lower_bounds;
std::vector<double> upper_bounds;
// Required: return true only for a valid configuration. Capture a stable
// collision scene for the entire request. Callbacks run on the calling
// thread; concurrent requests must not share a mutable collision checker.
std::function<bool(const std::vector<double>&)> is_state_valid;
std::function<bool()> is_cancelled;
};
enum class JointPathStatus {
Success,
InvalidRequest,
InvalidStart,
InvalidGoal,
TimedOut,
Cancelled,
ValidationError,
PlanningFailed,
};
struct JointPathResult {
JointPathStatus status{JointPathStatus::InvalidRequest};
// Empty on failure. Success contains both exact endpoints, without timing,
// smoothing, or motor commands. An unchanged target contains one point.
JointPath waypoints;
std::string message;
double planning_time_s{0.0};
std::size_t validity_checks{0};
bool ok() const { return status == JointPathStatus::Success; }
};
class JointPathPlanner {
public:
virtual ~JointPathPlanner() = default;
// Synchronous planning. Cancellation is cooperative: callbacks must return
// promptly and cannot be forcibly interrupted.
virtual JointPathResult plan(const JointPathRequest& request) const = 0;
};
} // namespace cmvr
#endif // CMVR_ES_JOINT_PATH_PLANNER_H