From b2e189791dbcbf4a353f02e4520847f3d60b760f Mon Sep 17 00:00:00 2001 From: aswathselvam Date: Mon, 13 Dec 2021 10:30:04 -0500 Subject: [PATCH] 4.0 Resolve cppcheck errors --- Results/cppcheckoutput.txt | 50 ++++++++++++++++++++++++++++---------- Results/cpplintoutput.txt | 3 +++ src/agent.cpp | 2 ++ src/inverse_kinematics.cpp | 2 +- src/path_planner.cpp | 8 +++--- src/swarm_master.cpp | 2 +- 6 files changed, 49 insertions(+), 18 deletions(-) diff --git a/Results/cppcheckoutput.txt b/Results/cppcheckoutput.txt index 4d0e51d..bd52d54 100644 --- a/Results/cppcheckoutput.txt +++ b/Results/cppcheckoutput.txt @@ -1,27 +1,51 @@ +Checking include/swarm_robots/agent.hpp ... +1/25 files checked 4% done +Checking include/swarm_robots/agent_node.hpp ... +2/25 files checked 11% done +Checking include/swarm_robots/arena.hpp ... +3/25 files checked 14% done +Checking include/swarm_robots/forward_kinematics.hpp ... +4/25 files checked 18% done +Checking include/swarm_robots/inverse_kinematics.hpp ... +5/25 files checked 22% done +Checking include/swarm_robots/obstacle.hpp ... +6/25 files checked 25% done +Checking include/swarm_robots/path_planner.hpp ... +7/25 files checked 31% done +Checking include/swarm_robots/safety_check.hpp ... +8/25 files checked 35% done +Checking include/swarm_robots/state.hpp ... +9/25 files checked 38% done +Checking include/swarm_robots/swarm_master.hpp ... +10/25 files checked 40% done +Checking src/action_client.cpp ... +11/25 files checked 41% done +Checking src/action_server.cpp ... +12/25 files checked 43% done Checking src/agent.cpp ... -1/13 files checked 8% done +13/25 files checked 47% done Checking src/agent_node.cpp ... -2/13 files checked 21% done +14/25 files checked 54% done Checking src/arena.cpp ... -3/13 files checked 24% done +15/25 files checked 56% done Checking src/forward_kinematics.cpp ... -4/13 files checked 31% done +16/25 files checked 59% done Checking src/inverse_kinematics.cpp ... -5/13 files checked 39% done +17/25 files checked 64% done Checking src/main.cpp ... -6/13 files checked 40% done +18/25 files checked 65% done Checking src/obstacle.cpp ... -7/13 files checked 42% done +19/25 files checked 66% done Checking src/path_planner.cpp ... Checking src/path_planner.cpp: DEBUG... -8/13 files checked 80% done +20/25 files checked 85% done Checking src/safety_check.cpp ... -9/13 files checked 87% done +21/25 files checked 88% done Checking src/state.cpp ... -10/13 files checked 90% done +22/25 files checked 90% done Checking src/swarm_master.cpp ... -11/13 files checked 94% done +23/25 files checked 92% done Checking test/main.cpp ... -12/13 files checked 96% done +24/25 files checked 93% done Checking test/testswarm.cpp ... -13/13 files checked 100% done +25/25 files checked 100% done diff --git a/Results/cpplintoutput.txt b/Results/cpplintoutput.txt index e00836f..39b8ff2 100644 --- a/Results/cpplintoutput.txt +++ b/Results/cpplintoutput.txt @@ -8,6 +8,8 @@ Done processing ./include/swarm_robots/path_planner.hpp Done processing ./include/swarm_robots/safety_check.hpp Done processing ./include/swarm_robots/state.hpp Done processing ./include/swarm_robots/swarm_master.hpp +Done processing ./src/action_client.cpp +Done processing ./src/action_server.cpp Done processing ./src/agent.cpp Done processing ./src/agent_node.cpp Done processing ./src/arena.cpp @@ -21,3 +23,4 @@ Done processing ./src/state.cpp Done processing ./src/swarm_master.cpp Done processing ./test/main.cpp Done processing ./test/testswarm.cpp +Total errors found: 55 diff --git a/src/agent.cpp b/src/agent.cpp index 165c2e7..921c261 100644 --- a/src/agent.cpp +++ b/src/agent.cpp @@ -34,6 +34,8 @@ Agent::Agent(string agent_id) { this->velocity_.y_ = 0; this->velocity_.yaw_ = 0; this->heading_angle_ = 180; + this->forward_kinematics_= NULL; + this->inverse_kinematics_ = NULL; } void Agent::PlanPath() { diff --git a/src/inverse_kinematics.cpp b/src/inverse_kinematics.cpp index a5fc392..615287c 100644 --- a/src/inverse_kinematics.cpp +++ b/src/inverse_kinematics.cpp @@ -43,7 +43,7 @@ void InverseKinematics::execute(const swarm_robots::swarmACTGoalConstPtr& goal, } -State InverseKinematics::PerformIK(State start, State goal) { +State InverseKinematics::PerformIK(const State& start, const State& goal) { this->current_location_ = start; this->goal_location_ = goal; State vel = PerformModelIK(); diff --git a/src/path_planner.cpp b/src/path_planner.cpp index 291769a..bba90b8 100644 --- a/src/path_planner.cpp +++ b/src/path_planner.cpp @@ -53,16 +53,18 @@ using std::string; } while (false) #endif -PathPlanner::PathPlanner(std::string ns, ros::NodeHandlePtr nh) { +PathPlanner::PathPlanner(const std::string ns, ros::NodeHandlePtr nh) { this->ns = "_jackal_" + ns; this->fixed_frame = "map"; this->nh_ = nh; + this->success_ = false; + this->oct_tree_ = NULL; // ros::Subscriber octree_sub = // n.subscribe("/octomap_binary", 1, octomapCallback); this->vis_pub_ = nh_->advertise("visualization_marker" + this->ns, 0); // NOLINT DEBUG_MSG("OMPL version: " << OMPL_VERSION << std::endl); - + CreateEmptyMap(); // space = ob::StateSpacePtr(new ob::SE2StateSpace()); } @@ -86,7 +88,7 @@ bool PathPlanner::IsStateValid(const ob::State *state) { } } -bool PathPlanner::Plan(State start, State goal) { +bool PathPlanner::Plan(const State &start, State &goal) { /* // construct the state space we are planning in diff --git a/src/swarm_master.cpp b/src/swarm_master.cpp index 8b375f8..91ee910 100644 --- a/src/swarm_master.cpp +++ b/src/swarm_master.cpp @@ -20,8 +20,8 @@ int main(int argc, char** argv) { ros::init(argc, argv, "swarm_master"); ROS_INFO_STREAM("Initialized node swarm_master."); vector agent_nodes; - int n = 20; try { + int n = 20; for (int i = 0; i < n; i++) { AgentNode* agent_node = new AgentNode(std::to_string(i)); agent_nodes.push_back(agent_node);