编译器错误消息错误:令牌之前的预期')' '*'。我的构造函数出错
Compiler error message error:expected ')' before '*' token. Error with my constructor
我一直得到以下编译错误
包含在文件中/home/armon/Development/groovy_workspace/沙盒/smart_wheelchair/箱子/smart_wheelchair/state_machine_planner/src/BasicControllerState.cpp: 1:0:/home/armon/Development/groovy_workspace/沙盒/smart_wheelchair/箱子/smart_wheelchair/state_machine_planner/include/state_machine_planner/BasicControllerState.h: 38:49:错误:期望' * '之前的')'标记
/home/armon/Development/groovy_workspace/沙盒/smart_wheelchair/箱子/smart_wheelchair/state_machine_planner/src/BasicControllerState.cpp: 44:错误:在'('之前预期的构造函数、析构函数或类型转换token包含在文件中/home/armon/Development/groovy_workspace/沙盒/smart_wheelchair/箱子/smart_wheelchair/state_machine_planner/include/state_machine_planner/StateMachinePlanner.h: 16:0,从/home/armon/Development/groovy_workspace/沙盒/smart_wheelchair/箱子/smart_wheelchair/state_machine_planner/src/ControllerNode.cpp: 4:/home/armon/Development/groovy_workspace/沙盒/smart_wheelchair/箱子/smart_wheelchair/state_machine_planner/include/state_machine_planner/BasicControllerState.h: 38:49:error: expected ') ' before ' ' token make[3]: [CMakeFiles/state_machine_planner.dir/src/BasicControllerState.cpp.o]错误1 make[3]: * Waiting for unfinished jobs....在文件包括从/home/armon/Development/groovy_workspace/沙盒/smart_wheelchair/箱子/smart_wheelchair/state_machine_planner/include/state_machine_planner/StateMachinePlanner.h: 16:0,从/home/armon/Development/groovy_workspace/沙盒/smart_wheelchair/箱子/smart_wheelchair/state_machine_planner/src/StateMachinePlanner.cpp: 1:/home/armon/Development/groovy_workspace/沙盒/smart_wheelchair/箱子/smart_wheelchair/state_machine_planner/include/state_machine_planner/BasicControllerState.h: 38:49:错误:期望' * '之前的')'标记
/home/armon/Development/groovy_workspace/沙盒/smart_wheelchair/箱子/smart_wheelchair/state_machine_planner/src/StateMachinePlanner.cpp:在构造函数"state_machine_planner:: StateMachinePlanner:: StateMachinePlanner ():
/home/armon/Development/groovy_workspace/沙盒/smart_wheelchair/箱子/smart_wheelchair/state_machine_planner/src/StateMachinePlanner.cpp:上午9:错误:没有匹配"(state_machine_planner:: BasicControllerState)(costmap_2d:: Costmap2DROS *,)的
BasicControllerState是StateMachinePlanner的成员
这里是代码,
BasicControllerState.h (relevant piece):
class BasicControllerState {
public:
BasicControllerState(){}
BasicControllerState(costmap_2d::costmap2DROS* costmap_ros);
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:
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++向导来帮我摆脱困境。我们在这个问题上花了太多时间了
costmap_2d::costmap2DROS*需要一个前向声明,或者您需要包含定义它的头文件。因为它是一个指针,所以前向声明更好。所以在类定义之前这样做:
namespace costmap_2d{
class costmap2DROS;
}
- 我的字符计数代码计算错误.为什么
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 0-1背包代码中的错误.我的代码中有什么错误
- 当我的阵列太大时出现分段错误
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 尝试链接我的着色器时,我收到错误代码"error c5145 must write to gl_position"
- 错误-我无法在VS2019中打开新的Qt项目
- 模板,函数使用错误的构造函数来复制我的对象
- 是否值得降低我的代码的可读性,以便在出现内存不足错误时提供异常安全性?
- 我的 int main() 中出现堆栈溢出错误
- 为什么我的 heap.h 文件给我一个LNK2001错误?
- 无法在我的堆排序代码中找到错误.无法正确执行.C++
- C++出现控制台错误.我无法识别源代码的问题
- 我的固定时间步长与增量时间和插值的解决方案是错误的吗?
- 我的模板类方法返回错误类型?
- 为什么在我的 main 函数中声明整数后我的整数数组中会出现错误?
- C++为什么我的编译器成功了,但我的计算机给出了调试错误?
- 为什么在尝试测量函数返回所需的时间时,我的运行时编号是错误的?
- 为什么我会得到细分错误:我的C 程序中的11个
- C++ BST 内存错误 - 我的删除有什么问题?