.. _program_listing_file_include_ruckig_output_parameter.hpp: Program Listing for File output_parameter.hpp ============================================= |exhale_lsh| :ref:`Return to documentation for file ` (``include/ruckig/output_parameter.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include #include #include #include #include namespace ruckig { template class CustomVector = StandardVector> class OutputParameter { template using Vector = CustomVector; void resize(size_t dofs) { new_position.resize(dofs); new_velocity.resize(dofs); new_acceleration.resize(dofs); new_jerk.resize(dofs); } public: size_t degrees_of_freedom; Trajectory trajectory; // Current kinematic state Vector new_position, new_velocity, new_acceleration, new_jerk; double time {0.0}; size_t new_section {0}; bool did_section_change {false}; bool new_calculation {false}; bool was_calculation_interrupted {false}; double calculation_duration; // [µs] template= 1), int>::type = 0> OutputParameter(): degrees_of_freedom(DOFs) { } template::type = 0> OutputParameter(size_t dofs): degrees_of_freedom(dofs), trajectory(Trajectory<0, CustomVector>(dofs)) { resize(dofs); } #if defined WITH_CLOUD_CLIENT template= 1), int>::type = 0> OutputParameter(size_t max_number_of_waypoints): degrees_of_freedom(DOFs), trajectory(Trajectory(max_number_of_waypoints)) { } template::type = 0> OutputParameter(size_t dofs, size_t max_number_of_waypoints): degrees_of_freedom(dofs), trajectory(Trajectory<0, CustomVector>(dofs, max_number_of_waypoints)) { resize(dofs); } #endif void pass_to_input(InputParameter& input) const { input.current_position = new_position; input.current_velocity = new_velocity; input.current_acceleration = new_acceleration; // Remove first intermediate waypoint if section did change if (did_section_change && !input.intermediate_positions.empty()) { input.intermediate_positions.erase(input.intermediate_positions.begin()); } } std::string to_string() const { std::stringstream ss; ss << "\nout.new_position = [" << join(new_position, true) << "]\n"; ss << "out.new_velocity = [" << join(new_velocity, true) << "]\n"; ss << "out.new_acceleration = [" << join(new_acceleration, true) << "]\n"; ss << "out.new_jerk = [" << join(new_jerk, true) << "]\n"; ss << "out.time = [" << std::setprecision(16) << time << "]\n"; ss << "out.calculation_duration = [" << std::setprecision(16) << calculation_duration << "]\n"; return ss.str(); } }; } // namespace ruckig