简体   繁体   English

编译器错误消息错误:'*'标记之前的预期')'。 我的构造函数出错

[英]Compiler error message error:expected ')' before '*' token. Error with my constructor

I keep getting the following compiler error 我不断收到以下编译器错误

In file included from /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: error: expected ')' before '*' token 在/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: error: expected constructor, destructor, or type conversion before '(' token In file included from /home/armon/Development/groovy_workspace/sandbox/smart_wheelchair/trunk/smart_wheelchair/state_machine_planner/include/state_machine_planner/StateMachinePlanner.h:16:0, from /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: error: expected ')' before ' ' token make[3]: /home/armon/Development/groovy_workspace/sandbox/smart_wheelchair/trunk/smart_wheelchair/state_machine_planner/src/BasicControllerState.cpp:4:44:错误:预期的构造函数,析构函数或类型转换,之前/包含在(()令牌中/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_wheelner /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:错误:预期的')'在' '令牌制作[ 3]: [CMakeFiles/state_machine_planner.dir/src/BasicControllerState.cpp.o] Error 1 make[3]: * Waiting for unfinished jobs.... In file included from /home/armon/Development/groovy_workspace/sandbox/smart_wheelchair/trunk/smart_wheelchair/state_machine_planner/include/state_machine_planner/StateMachinePlanner.h:16:0, from /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: error: expected ')' before '*' token [CMakeFiles / state_machine_planner.dir / src / BasicControllerState.cpp.o]错误1 make [3]:*等待未完成的作业。...在/ home / armon / Development / groovy_workspace / sandbox / smartbox / smartbox / 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:Develop:1:/ home / armon / ment /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: In constructor 'state_machine_planner::StateMachinePlanner::StateMachinePlanner()': /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: error: no match for call to '(state_machine_planner::BasicControllerState) (costmap_2d::Costmap2DROS*&)' /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 *& )'

BasicControllerState is a member of StateMachinePlanner BasicControllerState是StateMachinePlanner的成员

here is the code, 这是代码,

BasicControllerState.h (relevant piece): BasicControllerState.h(相关部分):

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

BasicControllerState.cpp: BasicControllerState.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: 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 (where I instantiate it): 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_);
        }

Forgive me, I know it may seem trivial, but I was hoping to find some c++ wizard to bail me out. 原谅我,我知道这似乎微不足道,但是我希望找到一些c ++向导来帮助我。 Have spent far too long on this one problem. 在这个问题上花费了太长时间。

costmap_2d::costmap2DROS* needs a forward declaration or you need to include the header file where it is defined. costmap_2d :: costmap2DROS *需要一个前向声明,或者您需要在定义它的位置包括头文件。 Because it is a pointer, a forward declarion is better. 因为它是指针,所以前向声明更好。 So before the class definition do this: 因此,在类定义之前执行以下操作:

namespace costmap_2d{
  class costmap2DROS;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:预期的构造函数,析构函数或&#39;(&#39;标记之前的类型转换。即使我有构造函数? - error: expected constructor, destructor, or type conversion before ‘(’ token. Even though I have a constructor? Arduino 语句错误。 &#39;;&#39; 前应为 &#39;)&#39; 令牌。 如何解决这个问题? - Arduino for statement error. Expected ')' before ';' token. How to fix this? 错误:&#39;:&#39;标记之前的预期初始化程序,gcc编译器 - Error: expected initializer before ': ' token , gcc compiler C ++构造函数错误-预期在标记&#39;&lt;&#39;之前的&#39;)&#39; - C++ Constructor error - Expected ')' before token '<' 我为什么会收到“错误:&#39;&lt;&lt;&#39;标记之前的预期主表达式。” - Why am I getting “Error: expected primary-expression before '<<' token.” 错误:“]”标记之前的预期主表达式。 需要帮助 function 定义和调用 - Error: expected primary-expression before ']' token. Need assitance with function definition and calling 错误:在&#39;*&#39;标记之前预期&#39;)&#39; - error: expected ')' before '*' token 错误:在&#39;=&#39;标记之前应为&#39;;&#39;,&#39;,&#39;或&#39;)&#39; - error: expected ';', ',' or ')' before '=' token 错误:预期的 &#39;,&#39; 或 &#39;;&#39; 在“{”标记之前 - error: expected ‘,’ or ‘;’ before ‘{’ token 错误:预期在&#39;。&#39;之前的&#39;,&#39;或&#39;...&#39;。 代币 - error: expected `,' or `…' before '.' token
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM