Skip to content

Commit

Permalink
Switch to clang-format-14 (moveit#1877) (moveit#1880)
Browse files Browse the repository at this point in the history
* Switch to clang-format-14

* Fix clang-format-14

(cherry picked from commit 7fa5eaf)

Co-authored-by: Henning Kayser <henningkayser@picknik.ai>
  • Loading branch information
mergify[bot] and henningkayser authored Jan 20, 2023
1 parent f942252 commit b1248d1
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .docker/ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN \
# Some basic requirements
wget git sudo curl \
# Preferred build tools
clang clang-format-12 clang-tidy clang-tools \
clang clang-format-14 clang-tidy clang-tools \
ccache && \
#
# Globally disable git security
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ repos:
- id: clang-format
name: clang-format
description: Format files with ClangFormat.
entry: clang-format-12
entry: clang-format-14
language: system
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$
args: ['-fallback-style=none', '-i']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,7 @@ inline void getAverageSupport(const btConvexShape* shape, const btVector3& local
pt_sum = pt;
max_support = sup;
}
else if (sup < max_support - BULLET_EPSILON)
{
}
else if (sup < max_support - BULLET_EPSILON) {}
else
{
pt_count += 1;
Expand Down
60 changes: 30 additions & 30 deletions moveit_core/collision_detection_fcl/src/collision_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,40 +753,40 @@ FCLGeometryConstPtr createCollisionGeometry(const shapes::ShapeConstPtr& shape,
}
}
else
// world objects could have previously been attached objects; we try to move them
// from their old cache to the new one, if possible. the code is not pretty, but should help
// when we attach/detach objects that are in the world
if (std::is_same<T, World::Object>::value)
{
// get the cache that corresponds to objects; maybe this attached object used to be a world object
FCLShapeCache& othercache = GetShapeCache<BV, moveit::core::AttachedBody>();

// attached bodies could be just moved from the environment.
auto cache_it = othercache.map_.find(wptr);
if (cache_it != othercache.map_.end())
// world objects could have previously been attached objects; we try to move them
// from their old cache to the new one, if possible. the code is not pretty, but should help
// when we attach/detach objects that are in the world
if (std::is_same<T, World::Object>::value)
{
if (cache_it->second.unique())
{
// remove from old cache
FCLGeometryConstPtr obj_cache = cache_it->second;
othercache.map_.erase(cache_it);
// get the cache that corresponds to objects; maybe this attached object used to be a world object
FCLShapeCache& othercache = GetShapeCache<BV, moveit::core::AttachedBody>();

// update the CollisionGeometryData; nobody has a pointer to this, so we can safely modify it
const_cast<FCLGeometry*>(obj_cache.get())->updateCollisionGeometryData(data, shape_index, true);

// RCLCPP_DEBUG(LOGGER, "Collision data structures for world object %s retrieved
// from the cache for
// attached
// bodies.",
// obj_cache->collision_geometry_data_->getID().c_str());

// add to the new cache
cache.map_[wptr] = obj_cache;
cache.bumpUseCount();
return obj_cache;
// attached bodies could be just moved from the environment.
auto cache_it = othercache.map_.find(wptr);
if (cache_it != othercache.map_.end())
{
if (cache_it->second.unique())
{
// remove from old cache
FCLGeometryConstPtr obj_cache = cache_it->second;
othercache.map_.erase(cache_it);

// update the CollisionGeometryData; nobody has a pointer to this, so we can safely modify it
const_cast<FCLGeometry*>(obj_cache.get())->updateCollisionGeometryData(data, shape_index, true);

// RCLCPP_DEBUG(LOGGER, "Collision data structures for world object %s retrieved
// from the cache for
// attached
// bodies.",
// obj_cache->collision_geometry_data_->getID().c_str());

// add to the new cache
cache.map_[wptr] = obj_cache;
cache.bumpUseCount();
return obj_cache;
}
}
}
}

fcl::CollisionGeometryd* cg_g = nullptr;
// handle cases individually
Expand Down
24 changes: 12 additions & 12 deletions moveit_core/constraint_samplers/src/constraint_sampler_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,20 @@ ConstraintSamplerPtr ConstraintSamplerManager::selectDefaultSampler(const planni
}
}
else
// if a smaller set of joints has been specified, keep the constraint sampler around, but use it only if no IK
// sampler has been specified.
if (!jc.empty())
{
JointConstraintSamplerPtr sampler = std::make_shared<JointConstraintSampler>(scene, jmg->getName());
if (sampler->configure(jc))
// if a smaller set of joints has been specified, keep the constraint sampler around, but use it only if no IK
// sampler has been specified.
if (!jc.empty())
{
RCLCPP_DEBUG(LOGGER,
"Temporary sampler satisfying joint constraints for group '%s' allocated. "
"Looking for different types of constraints before returning though.",
jmg->getName().c_str());
joint_sampler = sampler;
JointConstraintSamplerPtr sampler = std::make_shared<JointConstraintSampler>(scene, jmg->getName());
if (sampler->configure(jc))
{
RCLCPP_DEBUG(LOGGER,
"Temporary sampler satisfying joint constraints for group '%s' allocated. "
"Looking for different types of constraints before returning though.",
jmg->getName().c_str());
joint_sampler = sampler;
}
}
}
}

std::vector<ConstraintSamplerPtr> samplers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ class ChompParameters
int max_iterations_after_collision_free_; /*!< maximum iterations to be performed after a collision free path is found. */
double smoothness_cost_weight_; /*!< smoothness_cost_weight parameters controls its weight in the final cost that
CHOMP is actually optimizing over */
double obstacle_cost_weight_; /*!< controls the weight to be given to obstacles towards the final cost CHOMP optimizes over */
double
obstacle_cost_weight_; /*!< controls the weight to be given to obstacles towards the final cost CHOMP optimizes over */
double learning_rate_; /*!< learning rate used by the optimizer to find the local / global minima while reducing the total cost */
learning_rate_; /*!< learning rate used by the optimizer to find the local / global minima while reducing the total cost */
double smoothness_cost_velocity_; /*!< variables associated with the cost in velocity */
double smoothness_cost_acceleration_; /*!< variables associated with the cost in acceleration */
double smoothness_cost_jerk_; /*!< variables associated with the cost in jerk */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@ class OccupancyMapMonitorMiddlewareHandle : public OccupancyMapMonitor::Middlewa
void createLoadMapService(OccupancyMapMonitor::MiddlewareHandle::LoadMapServiceCallback callback) override;

private:
rclcpp::Node::SharedPtr node_; /*!< ROS node */
rclcpp::Service<moveit_msgs::srv::SaveMap>::SharedPtr
save_map_srv_; /*!< ROS service created by createSaveMapService */
rclcpp::Service<moveit_msgs::srv::LoadMap>::SharedPtr
load_map_srv_; /*!< ROS service created by createLoadMapService */
rclcpp::Node::SharedPtr node_; /*!< ROS node */
rclcpp::Service<moveit_msgs::srv::SaveMap>::SharedPtr save_map_srv_; /*!< ROS service created by createSaveMapService */
rclcpp::Service<moveit_msgs::srv::LoadMap>::SharedPtr load_map_srv_; /*!< ROS service created by createLoadMapService */
std::unique_ptr<pluginlib::ClassLoader<OccupancyMapUpdater>>
updater_plugin_loader_; /*!< Pluginlib loader for OccupancyMapUpdater */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,29 @@ class FixStartStateBounds : public planning_request_adapter::PlanningRequestAdap
}
}
else
// Normalize yaw; no offset needs to be remembered
if (jm->getType() == moveit::core::JointModel::PLANAR)
{
const double* p = start_state.getJointPositions(jm);
double copy[3] = { p[0], p[1], p[2] };
if (static_cast<const moveit::core::PlanarJointModel*>(jm)->normalizeRotation(copy))
// Normalize yaw; no offset needs to be remembered
if (jm->getType() == moveit::core::JointModel::PLANAR)
{
start_state.setJointPositions(jm, copy);
change_req = true;
const double* p = start_state.getJointPositions(jm);
double copy[3] = { p[0], p[1], p[2] };
if (static_cast<const moveit::core::PlanarJointModel*>(jm)->normalizeRotation(copy))
{
start_state.setJointPositions(jm, copy);
change_req = true;
}
}
}
else
else
// Normalize quaternions
if (jm->getType() == moveit::core::JointModel::FLOATING)
{
const double* p = start_state.getJointPositions(jm);
double copy[7] = { p[0], p[1], p[2], p[3], p[4], p[5], p[6] };
if (static_cast<const moveit::core::FloatingJointModel*>(jm)->normalizeRotation(copy))
{
start_state.setJointPositions(jm, copy);
change_req = true;
}
}
{
const double* p = start_state.getJointPositions(jm);
double copy[7] = { p[0], p[1], p[2], p[3], p[4], p[5], p[6] };
if (static_cast<const moveit::core::FloatingJointModel*>(jm)->normalizeRotation(copy))
{
start_state.setJointPositions(jm, copy);
change_req = true;
}
}
}

// pointer to a prefix state we could possibly add, if we detect we have to make changes
Expand Down

0 comments on commit b1248d1

Please sign in to comment.