Skip to content

Split Cricket into multiple files#9

Open
ShrutheeshIR wants to merge 1 commit into
masterfrom
split_up_cpp
Open

Split Cricket into multiple files#9
ShrutheeshIR wants to merge 1 commit into
masterfrom
split_up_cpp

Conversation

@ShrutheeshIR

Copy link
Copy Markdown

Some helpful splitting of cricket.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the fkcc_gen generator by extracting previously inlined helper types/utilities into separate headers to improve organization and reuse.

Changes:

  • Moved robot/geometry parsing and collision-sphere extraction logic into src/robot_info.hh.
  • Centralized AD/CppADCG type aliases and language helpers into src/housekeeping.hh.
  • Extracted tracing result utilities into src/tracer_utils.hh and updated fkcc_gen.cc to include the new headers.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/tracer_utils.hh New header for Traced and trace-to-JSON helpers.
src/robot_info.hh New header containing RobotInfo and sphere/collision extraction logic.
src/housekeeping.hh New header for AD/CppADCG-related aliases and language support includes.
src/fkcc_gen.cc Removes inlined definitions and switches to the new headers.
Comments suppressed due to low confidence (1)

src/fkcc_gen.cc:4

  • This translation unit now uses std::ifstream/std::ofstream, std::cout, std::ostringstream, exit(), and std::string but doesn’t include the corresponding standard headers. Relying on transitive includes from third-party headers is brittle and can break builds when those dependencies change.
#include <fmt/core.h>
#include <nlohmann/json.hpp>
#include <inja/inja.hpp>
#include <cxxopts.hpp>

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/housekeeping.hh
Comment on lines +1 to +17
#include "pinocchio_cppadcg.hh"
#include "lang_cpp.hh"
#include "lang_rust.hh"


using namespace pinocchio;
using namespace CppAD;
using namespace CppAD::cg;

// Typedef for AD types
using CGD = CG<double>;
using ADCG = AD<CGD>;

using ADModel = ModelTpl<ADCG>;
using ADData = DataTpl<ADCG>;
using ADVectorXs = Eigen::Matrix<ADCG, Eigen::Dynamic, 1>;
using ADMatrixXs = Eigen::Matrix<ADCG, Eigen::Dynamic, Eigen::Dynamic>; No newline at end of file
Comment thread src/tracer_utils.hh
Comment on lines +1 to +18
#pragma once

#include <fmt/core.h>
#include <nlohmann/json.hpp>

struct Traced
{
std::string code;
std::size_t temp_variables;
std::size_t outputs;
};

void add_to_trace(Traced tcode, std::string name, nlohmann::json &data)
{
data[name] = tcode.code;
data[fmt::format("{}_vars", name)] = tcode.temp_variables;
data[fmt::format("{}_output", name)] = tcode.outputs;
}
Comment thread src/robot_info.hh
Comment on lines +1 to +29
#pragma once

#include <pinocchio/parsers/urdf.hpp>
#include <pinocchio/parsers/srdf.hpp>
#include <pinocchio/algorithm/joint-configuration.hpp>
#include <pinocchio/algorithm/frames.hpp>
#include <pinocchio/algorithm/kinematics.hpp>
#include <pinocchio/algorithm/geometry.hpp>
#include <pinocchio/multibody/geometry.hpp>
#include <pinocchio/collision/collision.hpp>


// #include "pinocchio/multibody/model.hpp"
// #include "pinocchio/multibody/data.hpp"
// #include "pinocchio/algorithm/compute-all-terms.hpp"
#include "pinocchio/algorithm/center-of-mass.hpp"


#include <coal/shape/geometric_shapes.h>

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Min_sphere_of_spheres_d.h>
#include <CGAL/Min_sphere_of_spheres_d_traits_3.h>

#include <filesystem>
#include <stdexcept>
#include <vector>
#include <optional>

Comment thread src/robot_info.hh

if (srdf_file and not std::filesystem::exists(*srdf_file))
{
throw std::runtime_error(fmt::format("SRDF file () does not exist!", srdf_file->string()));
Comment thread src/robot_info.hh
SE3 relative;
};

auto min_sphere_of_spheres(const std::vector<SphereInfo> &info) -> std::array<float, 4>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants