Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify compilation flags based on os #2437

Merged
merged 14 commits into from
Oct 1, 2024
2 changes: 1 addition & 1 deletion .github/workflows/macos-linux-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
uses: actions/github-script@v7
with:
script: |
const script = require('./.github/workflows/scripts/get_label.js');
const script = require('./.github/workflows/scripts/get_compilation_flags.js');
await script({github, context, core})
result-encoding: string

Expand Down
40 changes: 15 additions & 25 deletions .github/workflows/scripts/check_label.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,25 @@ module.exports = async ({github, context, core}) => {
});
const labelNames = data.labels.map(label => label.name);

const labelFlags = {
build_all: [
' -DBUILD_WITH_COLLISION_SUPPORT=ON',
' -DBUILD_WITH_CASADI_SUPPORT=ON',
' -DBUILD_WITH_AUTODIFF_SUPPORT=ON',
' -DBUILD_WITH_CODEGEN_SUPPORT=ON',
' -DBUILD_WITH_EXTRA_SUPPORT=ON',
' -DBUILD_WITH_OPENMP_SUPPORT=ON',
' -DBUILD_PYTHON_BINDINGS_WITH_BOOST_MPFR_SUPPORT=ON',
' -DINSTALL_DOCUMENTATION=ON',
' -DGENERATE_PYTHON_STUBS=ON',
' -DBUILD_WITH_ACCELERATE_SUPPORT=ON'
],
build_collision: ' -DBUILD_WITH_COLLISION_SUPPORT=ON',
build_casadi: ' -DBUILD_WITH_CASADI_SUPPORT=ON',
build_autodiff: ' -DBUILD_WITH_AUTODIFF_SUPPORT=ON',
build_codegen: ' -DBUILD_WITH_CODEGEN_SUPPORT=ON',
build_extra: ' -DBUILD_WITH_EXTRA_SUPPORT=ON',
build_openmp: ' -DBUILD_WITH_OPENMP_SUPPORT=ON',
build_mpfr: ' -DBUILD_PYTHON_BINDINGS_WITH_BOOST_MPFR_SUPPORT=ON',
build_sdf: ' -DBUILD_WITH_SDF_SUPPORT=ON',
build_accelerate: ' -DBUILD_WITH_ACCELERATE_SUPPORT=ON'
};
const labelFlags= [
'build_all',
'build_collision',
'build_casadi',
'build_autodiff',
'build_codegen',
'build_extra',
'build_openmp',
'build_mpfr',
'build_sdf',
'build_accelerate'
];

var hasLabel = false;
labelNames.forEach(label => {
if (labelFlags[label]) {
if (labelFlags.includes(label)) {
hasLabel = true;
}
});
});

try
{
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/scripts/get_compilation_flags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Inspired by https://github.com/emmenko/action-verify-pr-labels/tree/master
module.exports = async ({github, context, core}) => {
const getPullRequestNumber = (ref) => {
core.debug(`Parsing ref: ${ref}`);
// This assumes that the ref is in the form of `refs/pull/:prNumber/merge`
const prNumber = ref.replace(/refs\/pull\/(\d+)\/merge/, '$1');
return parseInt(prNumber, 10);
};

const prNumber = context.issue.number || getPullRequestNumber(context.ref);

let cmakeFlags = '';
if(isNaN(prNumber))
{
core.setOutput("cmakeFlags", cmakeFlags);
return;
}

const { data } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
const labelNames = data.labels.map(label => label.name);

const os = process.env.RUNNER_OS;

var labelFlags;
if(os == "Windows")
{
labelFlags = {
build_all: [
' -DBUILD_WITH_COLLISION_SUPPORT=ON',
' -DBUILD_WITH_CASADI_SUPPORT=ON',
' -DBUILD_WITH_AUTODIFF_SUPPORT=ON',
' -DBUILD_WITH_EXTRA_SUPPORT=ON',
' -DBUILD_PYTHON_BINDINGS_WITH_BOOST_MPFR_SUPPORT=ON',
' -DINSTALL_DOCUMENTATION=ON',
' -DGENERATE_PYTHON_STUBS=ON',
' -DBUILD_WITH_ACCELERATE_SUPPORT=OFF',
' -DBUILD_WITH_SDF_SUPPORT=ON'
],
build_collision: ' -DBUILD_WITH_COLLISION_SUPPORT=ON',
build_casadi: ' -DBUILD_WITH_CASADI_SUPPORT=ON',
build_autodiff: ' -DBUILD_WITH_AUTODIFF_SUPPORT=ON',
build_extra: ' -DBUILD_WITH_EXTRA_SUPPORT=ON',
build_mpfr: ' -DBUILD_PYTHON_BINDINGS_WITH_BOOST_MPFR_SUPPORT=ON',
build_sdf: ' -DBUILD_WITH_SDF_SUPPORT=ON',
build_accelerate: ' -DBUILD_WITH_ACCELERATE_SUPPORT=ON'
};
}
else
{
labelFlags = {
build_all: [
' -DBUILD_WITH_COLLISION_SUPPORT=ON',
' -DBUILD_WITH_CASADI_SUPPORT=ON',
' -DBUILD_WITH_AUTODIFF_SUPPORT=ON',
' -DBUILD_WITH_EXTRA_SUPPORT=ON',
' -DBUILD_WITH_OPENMP_SUPPORT=ON',
' -DBUILD_PYTHON_BINDINGS_WITH_BOOST_MPFR_SUPPORT=ON',
' -DINSTALL_DOCUMENTATION=ON',
' -DBUILD_WITH_CODEGEN_SUPPORT=ON',
' -DGENERATE_PYTHON_STUBS=ON',
' -DBUILD_WITH_ACCELERATE_SUPPORT=OFF',
' -DBUILD_WITH_SDF_SUPPORT=ON'
],
build_collision: ' -DBUILD_WITH_COLLISION_SUPPORT=ON',
build_casadi: ' -DBUILD_WITH_CASADI_SUPPORT=ON',
build_autodiff: ' -DBUILD_WITH_AUTODIFF_SUPPORT=ON',
build_codegen: ' -DBUILD_WITH_CODEGEN_SUPPORT=ON',
build_extra: ' -DBUILD_WITH_EXTRA_SUPPORT=ON',
build_openmp: ' -DBUILD_WITH_OPENMP_SUPPORT=ON',
build_mpfr: ' -DBUILD_PYTHON_BINDINGS_WITH_BOOST_MPFR_SUPPORT=ON',
build_sdf: ' -DBUILD_WITH_SDF_SUPPORT=ON',
build_accelerate: ' -DBUILD_WITH_ACCELERATE_SUPPORT=ON'
};
}

labelNames.forEach(label => {
if (labelFlags[label]) {
if (Array.isArray(labelFlags[label])) {
cmakeFlags += labelFlags[label].join(' ');
} else {
cmakeFlags += labelFlags[label];
}
}
});
console.log(cmakeFlags);
core.setOutput("cmakeFlags", cmakeFlags);
return;
}
62 changes: 0 additions & 62 deletions .github/workflows/scripts/get_label.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/windows-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
uses: actions/github-script@v7
with:
script: |
const script = require('./.github/workflows/scripts/get_label.js');
const script = require('./.github/workflows/scripts/get_compilation_flags.js');
await script({github, context, core})
result-encoding: string

Expand Down
12 changes: 5 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add more Python and C++ examples related to inverse kinematics with 3d tasks ([#2428](https://github.com/stack-of-tasks/pinocchio/pull/2428))
- Add parsing of equality/connect tag for closed-loop chains for MJCF format ([#2413](https://github.com/stack-of-tasks/pinocchio/pull/2413))
- Add compatibility with NumPy 2 `__array__` API ([#2436](https://github.com/stack-of-tasks/pinocchio/pull/2436))
- Added argument to let users decide of root joint name when parsing models (urdf, mjcf, sdf) ([#2402](https://github.com/stack-of-tasks/pinocchio/pull/2402))

### Fixed
- Fix linkage of Boost.Serialization on Windows ([#2400](https://github.com/stack-of-tasks/pinocchio/pull/2400))
- Fix mjcf parser appending of inertias at root joint ([#2403](https://github.com/stack-of-tasks/pinocchio/pull/2403))
- Fix unit tests with GCC 13.3 ([#2406](https://github.com/stack-of-tasks/pinocchio/pull/2416)
- Fix class abtract error for Rviz viewer ([#2425](https://github.com/stack-of-tasks/pinocchio/pull/2425))
- Fix class abstract error for Rviz viewer ([#2425](https://github.com/stack-of-tasks/pinocchio/pull/2425))
- Fix compilation issue with MSCV and C++17 ([#2437](https://github.com/stack-of-tasks/pinocchio/pull/2437))
- Fix `pinocchio-test-py-robot_wrapper` when building with SDF and collision support ([#2437](https://github.com/stack-of-tasks/pinocchio/pull/2437))

### Changed

- Modernize python code base with ruff ([#2418](https://github.com/stack-of-tasks/pinocchio/pull/2418))

### Changed
- Does not create a root_joint frame from parsed models (urdf, mjcf and sdf) when no root joint is provided ([#2402](https://github.com/stack-of-tasks/pinocchio/pull/2402))

### Added
- Added argument to let users decide of root joint name when parsing models (urdf, mjcf, sdf) ([#2402](https://github.com/stack-of-tasks/pinocchio/pull/2402))
- Does not create a root_joint frame from parsed models (urdf, mjcf and sdf) when no root joint is provided ([#2402](https://github.com/stack-of-tasks/pinocchio/pull/2402))

## [3.2.0] - 2024-08-27

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ The following people have been involved in the development of **Pinocchio** and
- [Joris Vaillant](https://github.com/jorisv) (Inria): core developer and manager of the project
- [Sebastian Castro](https://roboticseabass.com) (The AI Institute): MeshCat viewer feature extension
- [Lev Kozlov](https://github.com/lvjonok): Kinetic and potential energy regressors
- [Megane Millan](https://github.com/MegMll) (Inria): Features extension and core developper

If you have participated in the development of **Pinocchio**, please add your name and contribution to this list.

Expand Down
44 changes: 44 additions & 0 deletions include/pinocchio/serialization/eigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,50 @@ namespace Eigen
#endif
#endif

// Similar workaround but for MSVC when C++17 is enabled.
// TODO Find _MSC_VER range.
#if (defined(_MSVC_LANG) && _MSVC_LANG >= 201703)
namespace boost
{
namespace archive
{
class binary_iarchive;
class xml_iarchive;
class text_iarchive;
} // namespace archive
} // namespace boost
namespace Eigen
{
namespace internal
{
template<>
struct traits<boost::archive::binary_iarchive>
{
enum
{
Flags = 0
};
};
template<>
struct traits<boost::archive::xml_iarchive>
{
enum
{
Flags = 0
};
};
template<>
struct traits<boost::archive::text_iarchive>
{
enum
{
Flags = 0
};
};
} // namespace internal
} // namespace Eigen
#endif // MSVC with C++17

namespace boost
{
namespace serialization
Expand Down
8 changes: 6 additions & 2 deletions unittest/python/robot_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,21 @@ def test_sdf_with_root_joint(self):
model_path = os.path.abspath(
os.path.join(self.current_file, "../../models/simple_humanoid.sdf")
)
robot = pin.RobotWrapper.BuildFromSDF(model_path, [], pin.JointModelFreeFlyer())
mesh_path = os.path.abspath(os.path.join(self.current_file, "../../models/"))
robot = pin.RobotWrapper.BuildFromSDF(
model_path, [mesh_path], pin.JointModelFreeFlyer(), verbose=True
)
self.assertEqual(robot.model.names[1], "root_joint")

@unittest.skipUnless(pin.WITH_SDFORMAT, "Needs SDFORMAT")
def test_sdf_with_root_joint_and_root_joint_name(self):
model_path = os.path.abspath(
os.path.join(self.current_file, "../../models/simple_humanoid.sdf")
)
mesh_path = os.path.abspath(os.path.join(self.current_file, "../../models/"))
name_ = "freeflyer_joint"
robot = pin.RobotWrapper.BuildFromSDF(
model_path, [], pin.JointModelFreeFlyer(), root_joint_name=name_
model_path, [mesh_path], pin.JointModelFreeFlyer(), root_joint_name=name_
)
self.assertEqual(robot.model.names[1], name_)

Expand Down
Loading