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

[Code Style] [merge after #565] add pre-commit tool #566

Merged
merged 10 commits into from
Oct 28, 2023
Merged
63 changes: 63 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
BasedOnStyle: Google
AccessModifierOffset: -2
ConstructorInitializerIndentWidth: 2
AlignEscapedNewlinesLeft: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: true
BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: true
BinPackParameters: true
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: true
DerivePointerBinding: false
PointerBindsToType: true
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 60
PenaltyBreakString: 1
PenaltyBreakFirstLessLess: 1000
PenaltyExcessCharacter: 1000
PenaltyReturnTypeOnItsOwnLine: 90
SpacesBeforeTrailingComments: 2
Cpp11BracedListStyle: false
Standard: Auto
IndentWidth: 2
TabWidth: 2
UseTab: Never
IndentFunctionDeclarationAfterType: false
SpacesInParentheses: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterControlStatementKeyword: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
SortIncludes: false
SpaceAfterCStyleCast: false

# Configure each individual brace in BraceWrapping
BreakBeforeBraces: Custom

# Control of individual brace wrapping cases
BraceWrapping:
AfterClass: true
AfterControlStatement: 'true'
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
19 changes: 19 additions & 0 deletions .github/workflows/uml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: generate plantuml
on: push
jobs:
generate_plantuml:
runs-on: ubuntu-latest
name: plantuml
steps:
- name: checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: plantuml
id: plantuml
uses: grassedge/[email protected]
with:
path: docs/UMLs
message: "Render PlantUML files"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
.LSOverride

# Icon must end with two \r
Icon
Icon


# Thumbnails
._*
Expand Down Expand Up @@ -101,4 +102,8 @@ tags


# python
*.pyc
*.pyc

# Jetbrains
.idea/
*cmake-build-debug/
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: check-xml
- id: check-json
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-added-large-files

# Python
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
language: python
args: [--line-length=120]

# C++
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.3
hooks:
- id: clang-format

# # YAML - still bad support for comments in YAML files
# - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
# rev: 0.2.1 # or other specific tag
# hooks:
# - id: yamlfmt
# args: [--mapping, '2', --sequence, '4', --offset, '2', --width, '120']
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ catkin build

## Demo
Please check instruction in [wiki](https://github.com/JSKAerialRobot/aerial_robot/wiki).


Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace aerial_robot_navigation
/* control frame */
enum control_frame
{
WORLD_FRAME, /* global frame, e.g. NEU, mocap */
WORLD_FRAME, /* global frame, e.g. ENU, mocap */
LOCAL_FRAME /* head frame which is identical with imu head direction */
};

Expand Down
2 changes: 1 addition & 1 deletion aerial_robot_estimation/src/sensor/plane_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace sensor_plugin
/* initialization */
if (getStatus() == Status::INACTIVE) {

// 1. check altmeter is initialized, and check the height
// 1. check altimeter is initialized, and check the height
bool alt_initialized = false;
for (const auto& handler: estimator_->getAltHandlers()) {
if (handler->getStatus() == Status::ACTIVE) {
Expand Down
2 changes: 1 addition & 1 deletion aerial_robot_simulation/scripts/gazebo_control_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def init(self):
init_values[group_name] = subgroup_init_values
self.actuator_command_pubs[group_name] = actuator_command_pubs

# setup the control subcriber
# setup the control subscriber
group_ctrl_topic_name = rospy.get_param("actuator_controller/" + group_name + "/ctrl_topic_name", group_name + "_ctrl")
self.joint_ctrl_sub_ = rospy.Subscriber(group_ctrl_topic_name, JointState, self.actuatorSubGroupCtrlCallback, group_name)

Expand Down
102 changes: 102 additions & 0 deletions docs/UMLs/classes.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
@startuml
'https://plantuml.com/class-diagram

set namespaceSeparator ::

abstract class aerial_robot_control::ControlBase {
+ ControlBase()
+ ~ControlBase()
+ initialize()
+ update()
+ activate()
+ reset()
}

abstract class aerial_robot_control::PoseLinearController extends aerial_robot_control::ControlBase {
+ PoseLinearController()
+ ~PoseLinearController()
+ initialize()
+ update()
+ reset()
}

class aerial_robot_control::FullyActuatedController extends aerial_robot_control::PoseLinearController {
+ FullyActuatedController()
+ ~FullyActuatedController()
+ initialize()
+ reset()
+ controlCore()
+ sendCmd()
}

class aerial_robot_control::UnderActuatedController extends aerial_robot_control::PoseLinearController {
+ UnderActuatedController()
+ ~UnderActuatedController()
+ initialize()
+ reset()
}

class aerial_robot_control::UnderActuatedLQIController extends aerial_robot_control::PoseLinearController {
+ UnderActuatedLQIController()
+ ~UnderActuatedLQIController()
+ initialize()
+ activate()
}

class aerial_robot_control::UnderActuatedTiltedLQIController extends aerial_robot_control::UnderActuatedLQIController {
+ UnderActuatedTiltedLQIController()
+ ~UnderActuatedTiltedLQIController()
+ initialize()
+ activate()
}

class aerial_robot_control::HydrusLQIController extends aerial_robot_control::UnderActuatedLQIController {
+ HydrusLQIController()
+ initialize()
+ checkRobotModel()
}

class aerial_robot_control::HydrusTiltedLQIController extends aerial_robot_control::UnderActuatedTiltedLQIController {
+ HydrusTiltedLQIController()
+ initialize()
+ checkRobotModel()
}

class aerial_robot_control::DragonLQIGimbalController extends aerial_robot_control::HydrusLQIController {
+ DragonLQIGimbalController()
+ ~DragonLQIGimbalController()
+ initialize()
+ update()
+ reset()
}

class aerial_robot_control::DragonFullVectoringController extends aerial_robot_control::PoseLinearController {
+ DragonFullVectoringController()
+ ~DragonFullVectoringController()
+ initialize()
}

namespace aerial_robot_control {
note "under-actuated multi-rotor (quad-rotor)" as ud_mr
note "hydrus (option)" as hy
note "fully-actuated multi-rotor (tilted hex-rotor)" as fu_mr
note "hydrus_xi (hex type)" as hy_xi
note "hydrus (non tilted)" as hy_nt
note "dragon" as dragon
note "hydrus (non tilted/ tilted)" as hy_all
}
UnderActuatedController .. ud_mr
UnderActuatedController .. hy
FullyActuatedController .. fu_mr
FullyActuatedController .. hy_xi
HydrusLQIController .. hy_nt
HydrusLQIController .. ud_mr
HydrusTiltedLQIController .. hy_all
DragonLQIGimbalController .. dragon
DragonFullVectoringController .. dragon



'TODO: give a unique namespace to robot specific controllers

@enduml
1 change: 1 addition & 0 deletions docs/UMLs/classes.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
123 changes: 123 additions & 0 deletions docs/UMLs/folder_structure.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
@startuml
'https://plantuml.com/component-diagram

'Legend
' - Blue: common packages
' - Orange: only for simulation
' - Green: only for real machine

package "jsk_aerial_robot" {

[aerial_robot_base] #LightBlue
note right of aerial_robot_base
* standalone core
- execute functions from following blocks
end note

[aerial_robot_model] #LightBlue
note right of [aerial_robot_model]
* joint based modelling
- kinematics, statics, stability
- jacobian
- derive model class as ros plugin
- servo motor interface (bridge)
end note

[aerial_robot_estimation] #LightBlue
note right of [aerial_robot_estimation]
* sensor fusion
- cog motion estimation
- sensor interface as ros plugin
- kalman filter as ros plugin
end note

[aerial_robot_control] #LightBlue
note right of [aerial_robot_control]
* flight control / navigation
- control based on cog motion
- navigation for cog and joint motion
- derive control/navigation class as ros plugin
end note

[aerial_robot_msgs] #LightBlue
note right of [aerial_robot_msgs]
* ros messages
- aerial_robot_msgs/XXXXX
end note

[aerial_robot_base] -[hidden]-> [aerial_robot_model]
[aerial_robot_model] -[hidden]-> [aerial_robot_estimation]
[aerial_robot_estimation] -[hidden]-> [aerial_robot_control]
[aerial_robot_control] -[hidden]-> [aerial_robot_msgs]

package "robots" {

note right of "robots"
* derive class as plugin for:
- model from aerial_robot_model
- control from aerial_robot_control
- navigation from aerial_robot_control (option)
end note

[hydrus] #LightBlue
note right of [hydrus]
- two dimensional multilinked type
- vertical thrust
end note

[hydrus_xi] #LightBlue
note right of [hydrus_xi]
- two dimensional multilinked type
- 1D vectorable thrust
end note

[dragon] #LightBlue
note right of [dragon]
- three dimensional multilinked type
- 2D vectorable thrust
end note

[hydrus] -[hidden]-> [hydrus_xi]
[hydrus_xi] -[hidden]-> [dragon]
}

[aerial_robot_simulation] #Orange
note right of [aerial_robot_simulation]
* interface for gazebo
- hardware interface
- controller interface as plugin
end note

[aerial_robot_msgs] -[hidden]-> [aerial_robot_simulation]


package "aerial_robot_nerve" {
[spinal_ros_bridge] #LightGreen
note right of [spinal_ros_bridge]
* uart between ros and spinal
- rosserial based
end note

[spinal] #LightGreen
note right of [spinal]
* project for stm32 mcu
- attitude estimation
- attitude control
- CAN comm with neuron
end note

[neuron] #LightGreen
note right of [neuron]
* project for stm32 mcu
- sensor interface via GPIO
- actuator interface via GPIO
- CAN comm with spinal
end note

[spinal_ros_bridge] -[hidden]-> [spinal]
[spinal] -[hidden]-> [neuron]
}

}

@enduml
1 change: 1 addition & 0 deletions docs/UMLs/folder_structure.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading