ROS程序设计:向前推进
ROS programming: move forward turtlebot
我想移动这个turtlebot。
首先,我在catkin_ws 中创建了包
$ catkin_create_pkg /..package_name../ std_msgs rospy roscpp actionlib tf geometry_msgs move_base_msgs
然后我编辑CMakeList
add_executable(myProgram src/main.cpp) and target_link_libraries(<executabletargetname>, ${catkin_LIBRARIES})
第三,我运行这个命令:
catkin_make
编译后:
[100%]构建CXX对象ileri/CMakeFiles/gg.dir/src/gg.cpp.o/home/turtlebot/catkin_ws/src/ileri/src/gg.cpp:18:2:错误:'p'确实不命名一个类型/home/turtlebot/catkin_ws/src/ileri/src/gg.cpp:28:2:错误:在"try"之前需要不合格的id/home/turtlebot/catkin_ws/src/ileri/src/gg.cpp:31:3:错误:预期'catch'make[2]之前的不合格id:*[ileri/CMakeFiles/gg.dir/src/gg.cpp.o]错误1 make[1]:*[ileri/CMakeFiles/gg.dir/all]错误2
.cpp:
`geometry_msgs::PointStamped p;
geometry_msgs::PointStamped p1;
p.header.stamp = ros::Time();
std::string frame1 = "/camera_depth_optical_frame";
p.header.frame_id = frame1.c_str();
p.point.x = 0;
p.point.y = 0;
p.point.z = 1; // 1 meter
std::string frame = "map";
try
{
listener.transformPoint(frame,p,p1);
}catch(tf::TransformException& ex) { ROS_ERROR("exception while transforming..."); }
// create message for move_base_simple/goal
geometry_msgs::PoseStamped msg;
msg.header.stamp = ros::Time();
std::string frame = "/map";
msg.header.frame_id = frame.c_str();
msg.pose.position = p1.point;
msg.pose.orientation = tf::createQuaternionMsgFromYaw(0.0);
publisher.publish(msg);`
- 你对这些错误怎么看
- include是否存在问题?如果你认为是这样的话,我应该添加这个代码的哪些内容
在C++中,语句进入函数内部。您的语句p.header.stamp = ros::Time();
似乎出现在函数外部。
您的程序还应该包含一个int main() { }
函数。尝试在{ }
中移动语句。
相关文章:
- 桌面计算器出现问题.C++程序设计语言
- C++Qt程序设计问题
- 嵌入式设备中传感器应用程序设计体系结构
- 关于多态性和资源管理的程序设计
- 视图状态和应用程序设计
- C++面向对象的客户端套接字应用程序设计
- 程序设计方法
- 关于异常规范和应用程序设计的问题
- 为什么我的程序设计为用完 RAM 和 CPU 不使用所有 RAM 和 CPU?
- 具有多态性和不同数据结构的程序设计
- ROS程序设计:向前推进
- C++网络程序设计:Boost Asio、Serialization和OStream
- 良好的程序设计/避免多重冗余检查的最佳实践(例如在C++中)
- 在不影响现有C或c++应用程序设计的情况下添加新的职责
- Windows Mobile c++ -应用程序设计类问题
- (程序设计语言C/C++)中的格式值类型float
- C/ c++程序设计中的一个问题
- 美国计算机协会国际大学程序设计竞赛亚洲地区D亨利
- C++如何加快我的程序设计
- 在c++windows中进行客户端-服务器程序设计的多线程