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

Add clang format file #101

Merged
merged 2 commits into from
Jan 30, 2025
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
79 changes: 79 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
BasedOnStyle: Google
ColumnLimit: 120
MaxEmptyLinesToKeep: 1

# Allow us to adhere to https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes
IncludeBlocks: Preserve
SortIncludes: true

Standard: Auto
IndentWidth: 2
TabWidth: 2
UseTab: Never
AccessModifierOffset: -2
ConstructorInitializerIndentWidth: 2
NamespaceIndentation: None
ContinuationIndentWidth: 4
IndentCaseLabels: true
IndentFunctionDeclarationAfterType: false

AlignEscapedNewlinesLeft: false
AlignTrailingComments: true

AllowAllParametersOfDeclarationOnNextLine: false
ExperimentalAutoDetectBinPacking: false
ObjCSpaceBeforeProtocolList: true
Cpp11BracedListStyle: false

AllowShortBlocksOnASingleLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortCaseLabelsOnASingleLine: false

AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: true

BinPackParameters: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
DerivePointerBinding: false
PointerBindsToType: true

PenaltyExcessCharacter: 50
PenaltyBreakBeforeFirstCallParameter: 30
PenaltyBreakComment: 1000
PenaltyBreakFirstLessLess: 10
PenaltyBreakString: 100
PenaltyReturnTypeOnItsOwnLine: 50

SpacesBeforeTrailingComments: 2
SpacesInParentheses: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterCStyleCast: false
SpaceAfterControlStatementKeyword: true
SpaceBeforeAssignmentOperators: true

# Configure each individual brace in BraceWrapping
BreakBeforeBraces: Custom

# Control of individual brace wrapping cases
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
IncludeBlocks: Preserve
...
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <moveit_studio_behavior_interface/service_client_behavior_base.hpp>
#include <example_interfaces/srv/add_two_ints.hpp>
#include <moveit_studio_behavior_interface/service_client_behavior_base.hpp>

using moveit_studio::behaviors::BehaviorContext;
using moveit_studio::behaviors::ServiceClientBehaviorBase;
Expand All @@ -13,7 +13,7 @@ class ExampleAddTwoIntsServiceClient final : public ServiceClientBehaviorBase<Ad
{
public:
ExampleAddTwoIntsServiceClient(const std::string& name, const BT::NodeConfiguration& config,
const std::shared_ptr<BehaviorContext>& shared_resources);
const std::shared_ptr<BehaviorContext>& shared_resources);

/** @brief Implementation of the required providedPorts() function for the hello_world Behavior. */
static BT::PortsList providedPorts();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#pragma once

#include <Eigen/Core>
#include <behaviortree_cpp/action_node.h>
#include <behaviortree_cpp/bt_factory.h>
#include <moveit/robot_model_loader/robot_model_loader.h>
#include <spdlog/spdlog.h>
#include <yaml-cpp/yaml.h>
#include <Eigen/Core>
#include <moveit_msgs/msg/robot_trajectory.hpp>
#include <moveit_studio_behavior/utils/trajectory_utils.hpp>
#include <moveit_studio_behavior_interface/behavior_context.hpp>
#include <moveit_studio_behavior_interface/check_for_error.hpp>
#include <moveit_studio_behavior_interface/shared_resources_node.hpp>
#include <moveit_task_constructor_msgs/msg/solution.hpp>
#include <spdlog/spdlog.h>
#include <trajectory_msgs/msg/joint_trajectory.hpp>
#include <yaml-cpp/yaml.h>

namespace example_behaviors
{
Expand All @@ -29,11 +29,13 @@ namespace example_behaviors
* | sampling_rate | Input | int |
* | joint_trajectory | Output | trajectory_msgs::msg::JointTrajectory |
*/
class ExampleConvertMtcSolutionToJointTrajectory final : public moveit_studio::behaviors::SharedResourcesNode<BT::SyncActionNode>
class ExampleConvertMtcSolutionToJointTrajectory final
: public moveit_studio::behaviors::SharedResourcesNode<BT::SyncActionNode>
{
public:
ExampleConvertMtcSolutionToJointTrajectory(const std::string& name, const BT::NodeConfiguration& config,
const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources);
ExampleConvertMtcSolutionToJointTrajectory(
const std::string& name, const BT::NodeConfiguration& config,
const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources);

static BT::PortsList providedPorts();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
namespace example_behaviors
{
/**
* @brief ExampleDelayedMessage will use FailureLoggerROS to log a "Hello World" message after the duration specified on the input port
* @brief ExampleDelayedMessage will use FailureLoggerROS to log a "Hello World" message after the duration specified on
* the input port
*/
class ExampleDelayedMessage : public moveit_studio::behaviors::SharedResourcesNode<BT::StatefulActionNode>
{
Expand All @@ -34,7 +35,7 @@ class ExampleDelayedMessage : public moveit_studio::behaviors::SharedResourcesNo
* the initialize() function is called, so these classes should not be used within the constructor.
*/
ExampleDelayedMessage(const std::string& name, const BT::NodeConfiguration& config,
const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources);
const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources);

/**
* @brief Implementation of the required providedPorts() function for the delayed_message Behavior.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <moveit_studio_behavior_interface/action_client_behavior_base.hpp>
#include <example_interfaces/action/fibonacci.hpp>
#include <moveit_studio_behavior_interface/action_client_behavior_base.hpp>

using moveit_studio::behaviors::ActionClientBehaviorBase;
using moveit_studio::behaviors::BehaviorContext;
Expand All @@ -13,7 +13,7 @@ class ExampleFibonacciActionClient final : public ActionClientBehaviorBase<Fibon
{
public:
ExampleFibonacciActionClient(const std::string& name, const BT::NodeConfiguration& config,
const std::shared_ptr<BehaviorContext>& shared_resources);
const std::shared_ptr<BehaviorContext>& shared_resources);

/** @brief Implementation of the required providedPorts() function for the hello_world Behavior. */
static BT::PortsList providedPorts();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ExampleGetStringFromTopic final : public GetMessageFromTopicBehaviorBase<s
{
public:
ExampleGetStringFromTopic(const std::string& name, const BT::NodeConfiguration& config,
const std::shared_ptr<BehaviorContext>& shared_resources);
const std::shared_ptr<BehaviorContext>& shared_resources);

/** @brief Implementation of the required providedPorts() function for the hello_world Behavior. */
static BT::PortsList providedPorts();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ExampleHelloWorld : public moveit_studio::behaviors::SharedResourcesNode<B
* the initialize() function is called, so these classes should not be used within the constructor.
*/
ExampleHelloWorld(const std::string& name, const BT::NodeConfiguration& config,
const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources);
const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources);

/**
* @brief Implementation of the required providedPorts() function for the hello_world Behavior.
Expand All @@ -48,9 +48,9 @@ class ExampleHelloWorld : public moveit_studio::behaviors::SharedResourcesNode<B
/**
* @brief Implementation of BT::SyncActionNode::tick() for ExampleHelloWorld.
* @details This function is where the Behavior performs its work when the behavior tree is being run.
* Since ExampleHelloWorld is derived from BT::SyncActionNode, it is very important that its tick() function always finishes
* very quickly. If tick() blocks before returning, it will block execution of the entire behavior tree, which may
* have undesirable consequences for other Behaviors that require a fast update rate to work correctly.
* Since ExampleHelloWorld is derived from BT::SyncActionNode, it is very important that its tick() function always
* finishes very quickly. If tick() blocks before returning, it will block execution of the entire behavior tree,
* which may have undesirable consequences for other Behaviors that require a fast update rate to work correctly.
* @return BT::NodeStatus::RUNNING, BT::NodeStatus::SUCCESS, or BT::NodeStatus::FAILURE depending on the result of the
* work done in this function.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
#include <behaviortree_cpp/action_node.h>

// This header includes the SharedResourcesNode type
#include <moveit_studio_behavior_interface/shared_resources_node.hpp>
#include <moveit_studio_behavior_interface/async_behavior_base.hpp>

#include <moveit_studio_behavior_interface/shared_resources_node.hpp>

namespace example_behaviors
{
Expand All @@ -17,17 +16,25 @@ class ExampleNDTRegistration : public moveit_studio::behaviors::AsyncBehaviorBas
public:
/**
* @brief Constructor for the behavior.
* @param name The name of a particular instance of this Behavior. This will be set by the behavior tree factory when this Behavior is created within a new behavior tree.
* @param shared_resources A shared_ptr to a BehaviorContext that is shared among all SharedResourcesNode Behaviors in the behavior tree. This BehaviorContext is owned by the Studio Agent's ObjectiveServerNode.
* @param config This contains runtime configuration info for this Behavior, such as the mapping between the Behavior's data ports on the behavior tree's blackboard. This will be set by the behavior tree factory when this Behavior is created within a new behavior tree.
* @details An important limitation is that the members of the base Behavior class are not instantiated until after the initialize() function is called, so these classes should not be used within the constructor.
* @param name The name of a particular instance of this Behavior. This will be set by the behavior tree factory when
* this Behavior is created within a new behavior tree.
* @param shared_resources A shared_ptr to a BehaviorContext that is shared among all SharedResourcesNode Behaviors in
* the behavior tree. This BehaviorContext is owned by the Studio Agent's ObjectiveServerNode.
* @param config This contains runtime configuration info for this Behavior, such as the mapping between the
* Behavior's data ports on the behavior tree's blackboard. This will be set by the behavior tree factory when this
* Behavior is created within a new behavior tree.
* @details An important limitation is that the members of the base Behavior class are not instantiated until after
* the initialize() function is called, so these classes should not be used within the constructor.
*/
ExampleNDTRegistration(const std::string& name, const BT::NodeConfiguration& config, const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources);
ExampleNDTRegistration(const std::string& name, const BT::NodeConfiguration& config,
const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources);

/**
* @brief Implementation of the required providedPorts() function for the Behavior.
* @details The BehaviorTree.CPP library requires that Behaviors must implement a static function named providedPorts() which defines their input and output ports. If the Behavior does not use any ports, this function must return an empty BT::PortsList.
* This function returns a list of ports with their names and port info, which is used internally by the behavior tree.
* @details The BehaviorTree.CPP library requires that Behaviors must implement a static function named
* providedPorts() which defines their input and output ports. If the Behavior does not use any ports, this function
* must return an empty BT::PortsList. This function returns a list of ports with their names and port info, which is
* used internally by the behavior tree.
* @return See ndt_registration.cpp for port list and description.
*/
static BT::PortsList providedPorts();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ExamplePublishColorRGBA final : public moveit_studio::behaviors::SharedRes
{
public:
ExamplePublishColorRGBA(const std::string& name, const BT::NodeConfiguration& config,
const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources);
const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources);

static BT::PortsList providedPorts();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
#include <behaviortree_cpp/action_node.h>

// This header includes the SharedResourcesNode type
#include <moveit_studio_behavior_interface/shared_resources_node.hpp>
#include <moveit_studio_behavior_interface/async_behavior_base.hpp>

#include <moveit_studio_behavior_interface/shared_resources_node.hpp>

namespace example_behaviors
{
Expand All @@ -17,17 +16,25 @@ class ExampleRANSACRegistration : public moveit_studio::behaviors::AsyncBehavior
public:
/**
* @brief Constructor for the behavior.
* @param name The name of a particular instance of this Behavior. This will be set by the behavior tree factory when this Behavior is created within a new behavior tree.
* @param shared_resources A shared_ptr to a BehaviorContext that is shared among all SharedResourcesNode Behaviors in the behavior tree. This BehaviorContext is owned by the Studio Agent's ObjectiveServerNode.
* @param config This contains runtime configuration info for this Behavior, such as the mapping between the Behavior's data ports on the behavior tree's blackboard. This will be set by the behavior tree factory when this Behavior is created within a new behavior tree.
* @details An important limitation is that the members of the base Behavior class are not instantiated until after the initialize() function is called, so these classes should not be used within the constructor.
* @param name The name of a particular instance of this Behavior. This will be set by the behavior tree factory when
* this Behavior is created within a new behavior tree.
* @param shared_resources A shared_ptr to a BehaviorContext that is shared among all SharedResourcesNode Behaviors in
* the behavior tree. This BehaviorContext is owned by the Studio Agent's ObjectiveServerNode.
* @param config This contains runtime configuration info for this Behavior, such as the mapping between the
* Behavior's data ports on the behavior tree's blackboard. This will be set by the behavior tree factory when this
* Behavior is created within a new behavior tree.
* @details An important limitation is that the members of the base Behavior class are not instantiated until after
* the initialize() function is called, so these classes should not be used within the constructor.
*/
ExampleRANSACRegistration(const std::string& name, const BT::NodeConfiguration& config, const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources);
ExampleRANSACRegistration(const std::string& name, const BT::NodeConfiguration& config,
const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources);

/**
* @brief Implementation of the required providedPorts() function for the Behavior.
* @details The BehaviorTree.CPP library requires that Behaviors must implement a static function named providedPorts() which defines their input and output ports. If the Behavior does not use any ports, this function must return an empty BT::PortsList.
* This function returns a list of ports with their names and port info, which is used internally by the behavior tree.
* @details The BehaviorTree.CPP library requires that Behaviors must implement a static function named
* providedPorts() which defines their input and output ports. If the Behavior does not use any ports, this function
* must return an empty BT::PortsList. This function returns a list of ports with their names and port info, which is
* used internally by the behavior tree.
* @return See ransac_registration.cpp for port list and description.
*/
static BT::PortsList providedPorts();
Expand Down
Loading
Loading