Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
BasedOnStyle: Google
ColumnLimit: 140
IndentWidth: 2
BreakBeforeBraces: Attach
DerivePointerAlignment: false
PointerAlignment: Left
AllowShortFunctionsOnASingleLine: Inline
IncludeBlocks: Preserve
BinPackParameters: false
76 changes: 76 additions & 0 deletions .github/workflows/format_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Code Format Check

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
format-check:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install Python formatters
run: |
python -m pip install --upgrade pip
pip install black

- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format

- name: Check clang-format version
run: clang-format --version

- name: Check Black version
run: black --version

- name: Check git status before formatting
run: git status --porcelain

- name: Run make format
run: make format

- name: Check for formatting changes
id: format-check
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
echo "❌ Files were modified by 'make format'"
echo ""
echo "Modified files:"
git status --porcelain
echo ""
echo "Diff:"
git diff
else
echo "changes=false" >> $GITHUB_OUTPUT
echo "✅ No formatting changes needed"
fi

- name: Display formatting instructions
if: steps.format-check.outputs.changes == 'true'
run: |
echo "❌ Code formatting check failed!"
echo ""
echo "To fix all formatting issues, run:"
echo ""
echo " make format"
echo ""
echo "Then commit and push your changes."

- name: Fail if formatting issues found
if: steps.format-check.outputs.changes == 'true'
run: |
echo "Code formatting issues detected. Please run 'make format' to fix them."
exit 1
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# clang
.clang-*

# Remove accidental build stuff put in here
build/
log/
Expand Down
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,8 @@ clean-cppad:
rm -rf cppad_code_gen

format:
lib/halodi-ros2-code-quality/Tools/fix_code_style.sh robot_models humanoid_nmpc

validate-format:
lib/halodi-ros2-code-quality/Tools/check_code_style.sh robot_models humanoid_nmpc

find . -name "lib" -prune -o \( -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) -print | xargs clang-format -i && \
black . --exclude="lib/"

launch-g1-dummy-sim:
cd ${build_dir} && \
Expand Down
1 change: 1 addition & 0 deletions dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ninja-build
ccache
python3-pygame
python3-tk
black

ros-${ROS_DISTRO}-ament-cmake-clang-format
ros-${ROS_DISTRO}-joint-state-publisher-gui
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class GaitScheduleUpdater : public SolverSynchronizedModule {
const vector_t& currentState,
const ReferenceManagerInterface& referenceManager) override;

void postSolverRun(const PrimalSolution&) override{};
void postSolverRun(const PrimalSolution&) override {};

// Override this function in case you need to e.g. access the received gait in a mutex protected way.
virtual ModeSequenceTemplate getReceivedGait() { return receivedGait_; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class ProceduralMpcMotionManager : public SolverSynchronizedModule {
*
* @param primalSolution : primalSolution
*/
void postSolverRun(const PrimalSolution& primalSolution) override{};
void postSolverRun(const PrimalSolution& primalSolution) override {};

virtual void setAndScaleVelocityCommand(const WalkingVelocityCommand& rawVelocityCommand);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void GaitSchedule::tileModeSequenceTemplate(scalar_t startTime, scalar_t finalTi
scalar_t deltaTime = templateTimes[i + 1] - templateTimes[i];
eventTimes.push_back(eventTimes.back() + deltaTime);
} // end of i loop
} // end of while loop
} // end of while loop

// default final phase
modeSequence.push_back(ModeNumber::STANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class MRTPolicySubscriber : public MRT_BASE {
*/
~MRTPolicySubscriber() override;

void resetMpcNode(const TargetTrajectories& initTargetTrajectories) override{};
void resetMpcNode(const TargetTrajectories& initTargetTrajectories) override {};

void setCurrentObservation(const SystemObservation& currentObservation) override{};
void setCurrentObservation(const SystemObservation& currentObservation) override {};

/**
* Shut down the ROS nodes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,8 @@ ad_vector_t PinocchioEndEffectorDynamicsCppAd::getOrientationCppAd(const ad_vect
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
auto PinocchioEndEffectorDynamicsCppAd::getOrientationError(const vector_t& state,
const std::vector<quaternion_t>& referenceOrientations) const
-> std::vector<vector3_t> {
auto PinocchioEndEffectorDynamicsCppAd::getOrientationError(
const vector_t& state, const std::vector<quaternion_t>& referenceOrientations) const -> std::vector<vector3_t> {
vector_t params(4 * endEffectorIds_.size());
for (size_t i = 0; i < endEffectorIds_.size(); i++) {
params.segment<4>(i * 4) = referenceOrientations[i].coeffs();
Expand Down Expand Up @@ -662,8 +661,8 @@ ad_vector_t PinocchioEndEffectorDynamicsCppAd::getLinearAccelerationCppAd(const
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
auto PinocchioEndEffectorDynamicsCppAd::getLinearAcceleration(const vector_t& state, const vector_t& input) const
-> std::vector<vector3_t> {
auto PinocchioEndEffectorDynamicsCppAd::getLinearAcceleration(const vector_t& state,
const vector_t& input) const -> std::vector<vector3_t> {
vector_t stateInput(state.rows() + input.rows());
stateInput << state, input;
const vector_t accelerationValues = linearAccelerationCppAdInterfacePtr_->getFunctionValue(stateInput);
Expand Down Expand Up @@ -721,8 +720,8 @@ ad_vector_t PinocchioEndEffectorDynamicsCppAd::getAngularAccelerationCppAd(const
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
auto PinocchioEndEffectorDynamicsCppAd::getAngularAcceleration(const vector_t& state, const vector_t& input) const
-> std::vector<vector3_t> {
auto PinocchioEndEffectorDynamicsCppAd::getAngularAcceleration(const vector_t& state,
const vector_t& input) const -> std::vector<vector3_t> {
vector_t stateInput(state.rows() + input.rows());
stateInput << state, input;
const vector_t accelerationValues = angularAccelerationCppAdInterfacePtr_->getFunctionValue(stateInput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def __init__(self):
def timer_callback(self):
if self.xbox_controller_interface.joystick_connected:
success, msg = self.xbox_controller_interface.get_walking_command_msg()
if success: self.publisher_.publish(msg)
if success:
self.publisher_.publish(msg)
else:
if self.counter >= (2 * self.publisher_rate):
self.xbox_controller_interface.get_joystick_connection()
Expand Down