0

我不断收到以下编译器错误

在 /home/armon/Development/groovy_workspace/sandbox/smart_wheelchair/trunk/smart_wheelchair/state_machine_planner/src/BasicControllerState.cpp:1:0: /home/armon/Development/groovy_workspace/sandbox/smart_wheelchair/trunk/smart_wheelchair/ 的文件中state_machine_planner/include/state_machine_planner/BasicControllerState.h:38:49: 错误: '*' 标记之前的预期')'
/home/armon/Development/groovy_workspace/sandbox/smart_wheelchair/trunk/smart_wheelchair/state_machine_planner/src/BasicControllerState.cpp:4:44:错误:预期的构造函数、析构函数或类型转换之前的“(”标记在来自/home的文件中/armon/Development/groovy_workspace/sandbox/smart_wheelchair/trunk/smart_wheelchair/state_machine_planner/include/state_machine_planner/StateMachinePlanner.h:16:0,来自/home/armon/Development/groovy_workspace/sandbox/smart_wheelchair/trunk/smart_wheelchair/state_machine_planner/src /ControllerNode.cpp:4: /home/armon/Development/groovy_workspace/sandbox/smart_wheelchair/trunk/smart_wheelchair/state_machine_planner/include/state_machine_planner/BasicControllerState.h:38:49: 错误: '<em>'之前的预期')'令牌制作[3]: [CMakeFiles/state_machine_planner.dir/src/BasicControllerState.cpp.o] 错误 1 ​​make[3]: * Waiting for unfinished jobs.... 在 /home/armon/Development/groovy_workspace/sandbox/smart_wheelchair/trunk/ 包含的文件中smart_wheelchair/state_machine_planner/include/state_machine_planner/StateMachinePlanner.h:16:0,来自/home/armon/Development/groovy_workspace/sandbox/smart_wheelchair/trunk/smart_wheelchair/state_machine_planner/src/StateMachinePlanner.cpp:1:/home/armon/Development /groovy_workspace/sandbox/smart_wheelchair/trunk/smart_wheelchair/state_machine_planner/include/state_machine_planner/BasicControllerState.h:38:49: 错误:在'*'标记之前预期')'
/home/armon/Development/groovy_workspace/sandbox/smart_wheelchair/trunk/smart_wheelchair/state_machine_planner/src/StateMachinePlanner.cpp:在构造函数'state_machine_planner::StateMachinePlanner::StateMachinePlanner()'中:
/home/armon/Development/groovy_workspace/sandbox/ smart_wheelchair/trunk/smart_wheelchair/state_machine_planner/src/StateMachinePlanner.cpp:9:30:错误:不匹配调用'(state_machine_planner::BasicControllerState) (costmap_2d::Costmap2DROS*&)'</p>

BasicControllerState 是 StateMachinePlanner 的成员

这是代码,

BasicControllerState.h(相关部分):

class BasicControllerState {
                public:
                        BasicControllerState(){}
                        BasicControllerState(costmap_2d::costmap2DROS* costmap_ros);

基本控制器状态.cpp:

#include <state_machine_planner/BasicControllerState.h>

namespace state_machine_planner {
        BasicControllerState::BasicControllerState(costmap_2d::costmap2DROS* costmap_ros) {
                //init trajectory parameters specific to what state the child class     represents  

                //init sim_time_ and sim_granularity_
                //init sample space limits
                //init best_score_thresh_

                obstacle_dist_cost_gain_ = 0.1;
                heading_diff_cost_gain_ = 0.0;
                linear_vel_cost_gain_ = 0.0;
                omega_cost_gain_ = 0.0;

                num_of_linvel_samples_ = 20;
                num_of_angvel_smaples_ = 40;

                costmap_ros_ = costmap_ros;
                costmap_ros_->getCostmapCopy(costmap_);
                robot_footprint_ = costmap_ros_->getRobotFootprint();
                world_model_ = new base_local_planner::CostmapModel(costmap_);
        }

StateMachinePlanner.h:

class StateMachinePlanner
        {
                public:
                        StateMachinePlanner();
                        void init(int latency_command_queue_size, vel_params_struct vps, time_params_struct tps);
                        void setKey(key_command_t key);
                        geometry_msgs::Twist computeVelocityCommands();
                private:
                        std::deque<Eigen::Vector2f> latency_command_queue_;
                        int latency_command_queue_size_;
                        vel_params_struct velocity_parameters_;
                        time_params_struct time_parameters_;
                        navigation_state_t current_state_;
                        key_command_t key_command_;
                        tf::TransformListener* tf_;
                        costmap_2d::Costmap2DROS* costmap_ros_;
                        costmap_2d::Costmap2D costmap_;

                        BasicControllerState forward_state_;

StateMachinePlanner.cpp(我在其中实例化它):

namespace state_machine_planner {

        StateMachinePlanner::StateMachinePlanner() : tf_(NULL), costmap_ros_(NULL) {
                tf_ = new tf::TransformListener(ros::Duration(10));
                costmap_ros_ = new costmap_2d::Costmap2DROS("costmap",*tf_);
                costmap_ros_->getCostmapCopy(costmap_);
                forward_state_(costmap_ros_);
        }

原谅我,我知道这可能看起来微不足道,但我希望能找到一些 c++ 向导来拯救我。在这一问题上花费了太长时间。

4

1 回答 1

0

costmap_2d::costmap2DROS* 需要前向声明,或者您需要在定义它的位置包含头文件。因为它是一个指针,所以前向声明更好。所以在类定义之前这样做:

namespace costmap_2d{
  class costmap2DROS;
}
于 2013-06-14T20:22:45.017 回答