Skip to content

Commit

Permalink
Formatting Done #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Blebot0 committed Jun 7, 2023
1 parent 1fee529 commit acb2226
Show file tree
Hide file tree
Showing 22 changed files with 808 additions and 575 deletions.
12 changes: 12 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 100
AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
BreakBeforeBraces: Allman
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 2
DerivePointerAlignment: false
PointerAlignment: Middle
ReflowComments: false
IncludeBlocks: Preserve
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build/**
install/**
log/**
.vscode/c_cpp_properties.json
.vscode/settings.json
77 changes: 77 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

# 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.4.0
hooks:
- id: check-ast
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
exclude_types: [rst]
- id: fix-byte-order-marker


# Python hooks
- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
hooks:
- id: pyupgrade
args: [--py36-plus]

# PyDocStyle
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
args: ["--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404"]

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: ["--line-length=99"]

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
args: ["--extend-ignore=E501"]

# CPP hooks
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v16.0.3
hooks:
- id: clang-format

# Cmake hooks
- repo: local
hooks:
- id: ament_lint_cmake
name: ament_lint_cmake
description: Check format of CMakeLists.txt files.
stages: [commit]
entry: ament_lint_cmake
language: system
files: CMakeLists\.txt$
exclude: 'baghira_hardware_interface/xsens/.*'
4 changes: 2 additions & 2 deletions chaining_controller/config/tricycle_drive_controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ joint_state_broadcaster:
ros__parameters:
extra_joints: ["right_wheel_joint", "left_wheel_joint"]

tricycle_controller:
tricycle_controller:
ros__parameters:
# Model
traction_joint_name: traction_joint # Name of traction joint in URDF
Expand All @@ -31,7 +31,7 @@ tricycle_controller:
pose_covariance_diagonal: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] # Need to be set if fusing odom with other localization source
twist_covariance_diagonal: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] # Need to be set if fusing odom with other localization source
velocity_rolling_window_size: 10 # Rolling window size of rcppmath::RollingMeanAccumulator applied on linear and angular speeds published on odom

# Rate Limiting
traction: # All values should be positive
# min_velocity: 0.0
Expand Down
6 changes: 3 additions & 3 deletions chaining_controller/examples/example_diff_drive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ int main(int argc, char * argv[])
{
rclcpp::init(argc, argv);

std::shared_ptr<rclcpp::Node> node =
std::make_shared<rclcpp::Node>("diff_drive_test_node");
std::shared_ptr<rclcpp::Node> node = std::make_shared<rclcpp::Node>("diff_drive_test_node");

auto publisher = node->create_publisher<geometry_msgs::msg::Twist>(
"/diff_drive_base_controller/cmd_vel_unstamped", 10);
Expand All @@ -42,7 +41,8 @@ int main(int argc, char * argv[])
command.angular.y = 0.0;
command.angular.z = 0.1;

while (1) {
while (1)
{
publisher->publish(command);
std::this_thread::sleep_for(50ms);
rclcpp::spin_some(node);
Expand Down
4 changes: 2 additions & 2 deletions chaining_controller/examples/example_effort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ int main(int argc, char * argv[])

node = std::make_shared<rclcpp::Node>("effort_test_node");

auto publisher = node->create_publisher<std_msgs::msg::Float64MultiArray>(
"/effort_controllers/commands", 10);
auto publisher =
node->create_publisher<std_msgs::msg::Float64MultiArray>("/effort_controllers/commands", 10);

RCLCPP_INFO(node->get_logger(), "node created");

Expand Down
4 changes: 2 additions & 2 deletions chaining_controller/examples/example_gripper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ int main(int argc, char * argv[])

node = std::make_shared<rclcpp::Node>("gripper_test_node");

auto publisher = node->create_publisher<std_msgs::msg::Float64MultiArray>(
"/gripper_controller/commands", 10);
auto publisher =
node->create_publisher<std_msgs::msg::Float64MultiArray>("/gripper_controller/commands", 10);

RCLCPP_INFO(node->get_logger(), "node created");

Expand Down
49 changes: 26 additions & 23 deletions chaining_controller/examples/example_position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,31 @@ rclcpp_action::ResultCode common_resultcode = rclcpp_action::ResultCode::UNKNOWN
int common_action_result_code = control_msgs::action::FollowJointTrajectory_Result::SUCCESSFUL;

void common_goal_response(
rclcpp_action::ClientGoalHandle
<control_msgs::action::FollowJointTrajectory>::SharedPtr goal_handle)
rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>::SharedPtr
goal_handle)
{
RCLCPP_DEBUG(
node->get_logger(), "common_goal_response time: %f",
rclcpp::Clock().now().seconds());
if (!goal_handle) {
node->get_logger(), "common_goal_response time: %f", rclcpp::Clock().now().seconds());
if (!goal_handle)
{
common_goal_accepted = false;
printf("Goal rejected\n");
} else {
}
else
{
common_goal_accepted = true;
printf("Goal accepted\n");
}
}

void common_result_response(
const rclcpp_action::ClientGoalHandle
<control_msgs::action::FollowJointTrajectory>::WrappedResult & result)
void common_result_response(const rclcpp_action::ClientGoalHandle<
control_msgs::action::FollowJointTrajectory>::WrappedResult & result)
{
printf("common_result_response time: %f\n", rclcpp::Clock().now().seconds());
common_resultcode = result.code;
common_action_result_code = result.result->error_code;
switch (result.code) {
switch (result.code)
{
case rclcpp_action::ResultCode::SUCCEEDED:
printf("SUCCEEDED result code\n");
break;
Expand All @@ -70,12 +72,14 @@ void common_feedback(
const std::shared_ptr<const control_msgs::action::FollowJointTrajectory::Feedback> feedback)
{
std::cout << "feedback->desired.positions :";
for (auto & x : feedback->desired.positions) {
for (auto & x : feedback->desired.positions)
{
std::cout << x << "\t";
}
std::cout << std::endl;
std::cout << "feedback->desired.velocities :";
for (auto & x : feedback->desired.velocities) {
for (auto & x : feedback->desired.velocities)
{
std::cout << x << "\t";
}
std::cout << std::endl;
Expand All @@ -91,15 +95,13 @@ int main(int argc, char * argv[])

rclcpp_action::Client<control_msgs::action::FollowJointTrajectory>::SharedPtr action_client;
action_client = rclcpp_action::create_client<control_msgs::action::FollowJointTrajectory>(
node->get_node_base_interface(),
node->get_node_graph_interface(),
node->get_node_logging_interface(),
node->get_node_waitables_interface(),
node->get_node_base_interface(), node->get_node_graph_interface(),
node->get_node_logging_interface(), node->get_node_waitables_interface(),
"/joint_trajectory_controller/follow_joint_trajectory");

bool response =
action_client->wait_for_action_server(std::chrono::seconds(1));
if (!response) {
bool response = action_client->wait_for_action_server(std::chrono::seconds(1));
if (!response)
{
throw std::runtime_error("could not get action server");
}
std::cout << "Created action server" << std::endl;
Expand Down Expand Up @@ -145,7 +147,8 @@ int main(int argc, char * argv[])

auto goal_handle_future = action_client->async_send_goal(goal_msg, opt);

if (rclcpp::spin_until_future_complete(node, goal_handle_future) !=
if (
rclcpp::spin_until_future_complete(node, goal_handle_future) !=
rclcpp::FutureReturnCode::SUCCESS)
{
RCLCPP_ERROR(node->get_logger(), "send goal call failed :(");
Expand All @@ -157,7 +160,8 @@ int main(int argc, char * argv[])

rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>::SharedPtr
goal_handle = goal_handle_future.get();
if (!goal_handle) {
if (!goal_handle)
{
RCLCPP_ERROR(node->get_logger(), "Goal was rejected by server");
action_client.reset();
node.reset();
Expand All @@ -168,8 +172,7 @@ int main(int argc, char * argv[])
// Wait for the server to be done with the goal
auto result_future = action_client->async_get_result(goal_handle);
RCLCPP_INFO(node->get_logger(), "Waiting for result");
if (rclcpp::spin_until_future_complete(node, result_future) !=
rclcpp::FutureReturnCode::SUCCESS)
if (rclcpp::spin_until_future_complete(node, result_future) != rclcpp::FutureReturnCode::SUCCESS)
{
RCLCPP_ERROR(node->get_logger(), "get result call failed :(");
return 1;
Expand Down
10 changes: 5 additions & 5 deletions chaining_controller/examples/example_tricycle_drive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ int main(int argc, char * argv[])
{
rclcpp::init(argc, argv);

std::shared_ptr<rclcpp::Node> node =
std::make_shared<rclcpp::Node>("tricycle_drive_test_node");
std::shared_ptr<rclcpp::Node> node = std::make_shared<rclcpp::Node>("tricycle_drive_test_node");

auto publisher = node->create_publisher<geometry_msgs::msg::Twist>(
"/tricycle_controller/cmd_vel", 10);
auto publisher =
node->create_publisher<geometry_msgs::msg::Twist>("/tricycle_controller/cmd_vel", 10);

RCLCPP_INFO(node->get_logger(), "node created");

Expand All @@ -42,7 +41,8 @@ int main(int argc, char * argv[])
command.angular.y = 0.0;
command.angular.z = 0.1;

while (1) {
while (1)
{
publisher->publish(command);
std::this_thread::sleep_for(50ms);
rclcpp::spin_some(node);
Expand Down
4 changes: 2 additions & 2 deletions chaining_controller/examples/example_velocity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ int main(int argc, char * argv[])

node = std::make_shared<rclcpp::Node>("velocity_test_node");

auto publisher = node->create_publisher<std_msgs::msg::Float64MultiArray>(
"/velocity_controller/commands", 10);
auto publisher =
node->create_publisher<std_msgs::msg::Float64MultiArray>("/velocity_controller/commands", 10);

RCLCPP_INFO(node->get_logger(), "node created");

Expand Down
Empty file.
Empty file.
Loading

0 comments on commit acb2226

Please sign in to comment.