Skip to content

Commit

Permalink
Merge pull request #15 from mintar/add-precommit-checks
Browse files Browse the repository at this point in the history
Add pre-commit checks
  • Loading branch information
oscar-lima authored Apr 8, 2024
2 parents 3de57ad + 3eb7cfe commit a1f3ecf
Show file tree
Hide file tree
Showing 44 changed files with 1,281 additions and 648 deletions.
10 changes: 10 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[flake8]
# The line length here has to match the black config in pyproject.toml
max-line-length = 120
exclude =
.git,
__pycache__
extend-ignore =
# See https://github.com/PyCQA/pycodestyle/issues/373
E203,
E741,
26 changes: 26 additions & 0 deletions .mdl_style.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Style file for markdownlint

all

exclude_rule 'fenced-code-language' # Fenced code blocks should have a language specified
exclude_rule 'first-line-h1' # First line in file should be a top level header

exclude_rule 'ul-style'

exclude_rule 'no-multiple-blanks'

exclude_rule 'header-style'

exclude_rule 'no-bare-urls'

# Line lenght
rule 'MD013', :line_length => 120, :code_blocks => false, :tables => false

# Unordered list indentation
rule 'MD007', :indent => 2

# Ordered list item prefix
rule 'MD029', :style => 'ordered'

# Multiple headers with the same content
rule 'no-duplicate-header', :allow_different_nesting => true
2 changes: 2 additions & 0 deletions .mdlrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
git_recurse true
style ".mdl_style.rb"
73 changes: 73 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# To use:
#
# pre-commit run -a
#
# Or:
#
# pre-commit install # (runs every time you commit in git)
#
# To update this file:
#
# pre-commit autoupdate
#
# See https://github.com/pre-commit/pre-commit

repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-docstring-first
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-vcs-permalinks
- id: check-xml
- id: check-yaml
exclude: mobipick_description/config/joint_limits.yaml
- id: debug-statements
- id: end-of-file-fixer
exclude: &excludes |
(?x)^(
.*\.blend|
.*\.dae|
.*\.mtl|
.*\.obj|
.*\.pgm|
.*\.step|
.*\.stl
)$
- id: fix-byte-order-marker
- id: mixed-line-ending
exclude: *excludes
- id: trailing-whitespace
exclude: *excludes

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8.git
rev: 5.0.4
hooks:
- id: flake8

- repo: https://github.com/markdownlint/markdownlint
rev: v0.11.0
hooks:
- id: markdownlint

- repo: local
hooks:
- id: catkin_lint
name: catkin_lint
description: Check package.xml and cmake files
entry: catkin_lint .
language: system
always_run: true
pass_filenames: false
args: [ "--strict", "--ignore", "UNINSTALLED_SCRIPT" ]
46 changes: 40 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ catkin_python_setup()
## Generate actions in the 'action' folder
add_action_files(
FILES
PickObject.action
PlaceObject.action
InsertObject.action
InsertObject.action
PickObject.action
PlaceObject.action
)

## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
actionlib_msgs
geometry_msgs
std_msgs
actionlib_msgs
geometry_msgs
std_msgs
)

generate_dynamic_reconfigure_options(
Expand All @@ -43,7 +43,41 @@ generate_dynamic_reconfigure_options(
catkin_package(
CATKIN_DEPENDS
actionlib_msgs
dynamic_reconfigure
geometry_msgs
message_runtime
std_msgs
)

#############
## Install ##
#############

catkin_install_python(PROGRAMS
scripts/insert_obj_test_action_client
scripts/object_recognition_mockup.py
scripts/pick_obj_test_action_client
scripts/place_obj_test_action_client
scripts/publish_tf_world_to_robot
scripts/rqt_grasplan
scripts/rqt_planning_scene
scripts/set_rviz_logger_level.py
scripts/visualize_planning_scene_node
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

# Mark other files for installation (e.g. launch and bag files, etc.)
install(DIRECTORY
config
launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

install(FILES
plugin.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

#############
## Testing ##
#############

roslaunch_add_file_check(launch)
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# grasplan

Documentation can be found under: https://grasplan-documentation.readthedocs.io/en/latest/


pre-commit Formatting Checks
----------------------------

This repo has a [pre-commit](https://pre-commit.com/) check that runs in CI.
You can use this locally and set it up to run automatically before you commit
something. To install, use pip:

```bash
pip3 install --user pre-commit
```

To run over all the files in the repo manually:

```bash
pre-commit run -a
```

To run pre-commit automatically before committing in the local repo, install the git hooks:

```bash
pre-commit install
Empty file modified config/object_recognition_mockup/objBounds.cfg
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions launch/grasp_planning/pick_handcoded_grasp_planner.launch
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<node pkg="grasplan" type="pick.py" name="pick_object_node" output="screen" >
<param name="import_file" type="string" value="grasp_planner.handcoded_grasp_planner" />
<param name="import_class" type="string" value="HandcodedGraspPlanner" />
<rosparam file="$(find grasplan)/config/pick_params.yaml" command="load" />
<rosparam file="$(find grasplan)/config/grasp_planning_core_params.yaml" command="load" />
<rosparam file="$(find mobipick_pick_n_place)/config/grasplan/pick_params.yaml" command="load" />
<rosparam file="$(find mobipick_pick_n_place)/config/grasplan/grasp_planning_core_params.yaml" command="load" />
<!-- grasp planner parameters -->
<rosparam file="$(find grasplan)/config/grasp_planner/handcoded_grasp_planner/handcoded_grasp_planner_all_objecst.yaml"
command="load" ns="handcoded_grasp_planner_transforms" />
Expand Down
4 changes: 2 additions & 2 deletions launch/grasp_planning/pick_simple_pregrasp_planner.launch
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<node pkg="grasplan" type="pick.py" name="pick_object_node" output="screen" >
<param name="import_file" type="string" value="grasp_planner.simple_pregrasp_planner" />
<param name="import_class" type="string" value="SimpleGraspPlanner" />
<rosparam file="$(find grasplan)/config/pick_params.yaml" command="load" />
<rosparam file="$(find grasplan)/config/grasp_planning_core_params.yaml" command="load" />
<rosparam file="$(find mobipick_pick_n_place)/config/grasplan/pick_params.yaml" command="load" />
<rosparam file="$(find mobipick_pick_n_place)/config/grasplan/grasp_planning_core_params.yaml" command="load" />
<!-- pregrasp planner parameters -->
<rosparam file="$(find grasplan)/config/grasp_planner/simple_pregrasp_planner_params.yaml" command="load" />
</node>
Expand Down
2 changes: 1 addition & 1 deletion launch/visualization/rviz_gripper_visualizer.launch
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<!-- visualize a gripper in rviz -->
<node pkg="grasplan" type="rviz_gripper_visualizer.py" name="rviz_gripper_visualizer" output="screen" >
<rosparam file="$(find mobipick_pick_n_place)/config/gripper_open_transformations.yaml" command="load" ns="gripper_transformations"/>
<rosparam file="$(find mobipick_pick_n_place)/config/grasplan/gripper_open_transformations.yaml" command="load" ns="gripper_transformations"/>
</node>

</launch>
22 changes: 18 additions & 4 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,49 @@

<license>MIT</license>

<author email="[email protected]">Oscar Lima</author>
<author email="[email protected]">Oscar Lima</author>

<build_export_depend>actionlib_msgs</build_export_depend>
<build_export_depend>dynamic_reconfigure</build_export_depend>
<build_export_depend>geometry_msgs</build_export_depend>
<build_export_depend>rqt_gui</build_export_depend>
<build_export_depend>rqt_gui_py</build_export_depend>
<build_export_depend>dynamic_reconfigure</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>

<build_depend>actionlib_msgs</build_depend>
<build_depend>dynamic_reconfigure</build_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>message_generation</build_depend>
<build_depend>rqt_gui</build_depend>
<build_depend>rqt_gui_py</build_depend>
<build_depend>std_msgs</build_depend>

<exec_depend>actionlib</exec_depend>
<exec_depend>actionlib_msgs</exec_depend>
<exec_depend>dynamic_reconfigure</exec_depend>
<exec_depend>gazebo_ros</exec_depend>
<exec_depend>geometry_msgs</exec_depend>
<exec_depend>message_runtime</exec_depend>
<exec_depend>mobipick_description</exec_depend>
<exec_depend>mobipick_gazebo</exec_depend>
<exec_depend>mobipick_pick_n_place</exec_depend>
<exec_depend>moveit_commander</exec_depend>
<exec_depend>moveit_msgs</exec_depend>
<exec_depend>rostopic</exec_depend>
<exec_depend>rqt_gui</exec_depend>
<exec_depend>rqt_gui_py</exec_depend>
<exec_depend>rviz</exec_depend>
<exec_depend>spacenav_node</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>std_srvs</exec_depend>
<exec_depend>tables_demo_bringup</exec_depend>
<exec_depend>tf</exec_depend>
<exec_depend>trajectory_msgs</exec_depend>
<exec_depend>xacro</exec_depend>

<buildtool_depend>catkin</buildtool_depend>

<export>
<rqt_gui plugin="${prefix}/plugin.xml"/>
<rqt_gui plugin="${prefix}/plugin.xml"/>
</export>

</package>
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tool.black]
line-length = 120
target-version = ['py38']
skip-string-normalization = true
16 changes: 9 additions & 7 deletions scripts/insert_obj_test_action_client
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ if __name__ == '__main__':
elif myargv[2] == 'false' or myargv[2] == 'False':
observe_before_insert = False
else:
rospy.logwarn('you have run this node without arguments, at least the mobipick namespace is expected! ( __ns:=mobipick )')
timeout = 50.0 # in seconds, default: 50.0
rospy.logwarn(
'you have run this node without arguments, at least the mobipick namespace is expected! ( __ns:=mobipick )'
)
timeout = 50.0 # in seconds, default: 50.0
insert_object_server_name = 'insert_object'
action_client = actionlib.SimpleActionClient(insert_object_server_name, InsertObjectAction)
rospy.loginfo(f'waiting for {insert_object_server_name} action server')
Expand All @@ -38,11 +40,11 @@ if __name__ == '__main__':
if action_client.wait_for_result(rospy.Duration.from_sec(timeout)):
result = action_client.get_result()
rospy.loginfo(f'{insert_object_server_name} is done with execution, resuĺt was = "{result}"')
if result.success == True:
rospy.loginfo(f'Succesfully inserted object')
if result.success:
rospy.loginfo('Succesfully inserted object')
else:
rospy.logerr(f'Failed to insert object')
rospy.logerr('Failed to insert object')
else:
rospy.logerr(f'Failed to insert object, timeout?')
rospy.logerr('Failed to insert object, timeout?')
else:
rospy.logerr(f'action server {insert_object_server_name} not available')
rospy.logerr('action server {insert_object_server_name} not available')
Loading

0 comments on commit a1f3ecf

Please sign in to comment.