C 或 C++对于机器人?

发布于 2024-10-17 01:54:28 字数 486 浏览 3 评论 0原文

您好,

我正在尝试为我的机器人在 C 和 C++ 之间做出选择。我是 Visual Basic.NET 的 5 年以上老手,但是我要在这个机器人上使用 Linux (Ubuntu),并且 Linux 和 .NET Framework 之间存在兼容性问题。我想坚持为所有项目选择哪种语言,因此我想确保为任务选择最合适的语言。 作为参考,我将描述我当前正在开发的机器人以及我将用它做什么。我正在建造一台全尺寸的 R4 Astromech(是的,我就是其中之一)。我的 PC 主板配备 Intel Core 2 2.1 GHz 处理器、1 GB RAM。我将使用一个临时构建的并行接口卡来控制驱动电机、头部电机,以及一个辅助并行接口卡(连接到第二个并行端口),所有传感器(红外、超声波测距、视觉识别)都通过网络摄像头等)将会去。将使用语音识别来发出命令(目前有一个 VB.NET 临时构建的识别程序,我将对其进行调整以适应新语言)。 考虑到上面列出的规范和期望目标,我使用 C 还是 C++ 会更好?我非常感谢您提出的任何建议。 谢谢! 萨斯卡拉斯

Greetings,

I am trying to decide between C and C++ for my robot. I am a 5+ year veteran of Visual Basic.NET, however I'm going with Linux (Ubuntu) on this robot, and there is a compatibility problem between Linux and the .NET Framework. I want to stick with whichever language I choose for all of my projects, so I want to make sure that I choose the most appropriate one for the task.
For reference, I will describe my current robot in progress and what I am going to do with it. I am in the process of building a full-sized R4 Astromech (yep, I'm one of those guys). I have incorporated a PC motherboard with an Intel Core 2 2.1 GHz processor, 1 GB RAM. I will be using a scratch-built parallel interface card to control the drive motors, head motor, as well as a secondary parallel interface card (going to a second parallel port) which all of the sensors (IR, Ultrasonic Ranging, Visual Recognition via webcam, etc.) will be going to. Commands will be given using speech recognition (currently have a VB.NET scratch-built recognition program that I will be adapting to the new language).
Given the specifications and desired goals listed above, would I be better off with C or C++? I greatly appreciate any suggestions that you might have.
Thanks!
Thaskalas

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

仙女山的月亮 2024-10-24 01:54:28

你说的兼容性问题是什么意思?您看过 Mono 吗?它是 .NET 库的开源实现。它面向 C# 而不是 VB.NET,但如果您更习惯 .NET 环境,请使用它。速度在这里并不是真正的问题,因为 Core2Duo 的速度足以满足您需要做的事情。

如果 Mono 不适合你,我推荐 C++。还有更多的 C++ 库(或者至少我熟悉更多,例如 Boost) ,它也可以使用大多数 C 库。使用 C++ 并没有真正的速度损失。虽然使用 C 本身并不错,但 C++ 有一些优点并且没有缺点,因此它可能是更好的选择。

What do you mean by a compatibility problem? Have you looked at Mono? It's an open-source implementation of the .NET libraries. It's geared toward C# not VB.NET but if you're more comfortable in a .NET environment use that. Speed isn't really an issue here as a Core2Duo is plenty fast for what you need to do.

If Mono won't work for you, I'd recommend C++. There are a lot more libraries out there for C++ (or at least, I am familiar with more, e.g. Boost), which can use most C libraries too. There's no real speed penalty for using C++. While using C wouldn't be bad per-se, C++ has some benefits and no drawbacks, so it's probably the better choice.

深府石板幽径 2024-10-24 01:54:28

我建议使用 ROS。它将让您开始使用复杂的进程间通信管理器以及大型复杂的机器人代码库,其中包括 SLAM 和其他关键机器人算法的多种实现。 ROS 还允许您使用多种语言进行编程,包括 C、C++ 和 Python,这样您就不会被一种语言或另一种语言所困扰。

I would recommend using ROS. It will let you get started with a sophisticated Inter-Process Communications manager, as well as a large library of sophisticated robotics code, including multiple implementations of SLAM and other critical robotics algorithms. ROS also lets you program in multiple languages, including C, C++, and Python, so you aren't stuck with one language or another down the road.

凹づ凸ル 2024-10-24 01:54:28

我还推荐 C++ 和 ROS。在我们公司,我们正在迁移到它,因为有很多人致力于它,扩展它,并添加许多很酷的功能。

这样,您就可以忘记实现大部分基本的低级内容,并开始研究您想要研究的内容。

设置和开始开发非常容易。

I would also recommend C++ and ROS. In our company we're migrating to it, because there's so many people working on it, expanding it, and adding lots of cool features.

With this, you can forget about implementing most of the basic low-level stuff and start working on what you intend to research.

It's really easy to set up and start developing.

吐个泡泡 2024-10-24 01:54:28

由于您在其上运行 Linux,因此我建议采用拆分方法,即用 C(或 C++)执行较低级别(设备接口,您可能需要快速性能)的操作,并使用 C++ 执行较高级别的操作。现代语言,如 C#(使用 Mono)或 Java,甚至 Python。

Python 尤其具有很强的表达能力,拥有大量的库,并且有一个非常简单的 C 接口。

用 C/C++ 这样的低级语言编写高级控制内容很快就会过时(恕我直言)。机器人应该很有趣!

Since you're running Linux on it, I'd recommend a split approach, where you do the lower-level (device interface, where you may need fast performance) stuff in C (or C++), and the higher level stuff in a modern language like C# (using Mono) or Java, or even Python.

Python especially is hugely expressive, has a large set of libraries, and has a pretty straightforward C interface.

Writing your high-level control stuff in a low-level language like C/C++ will get old fast (IMHO). Robots should be fun!

躲猫猫 2024-10-24 01:54:28

您考虑过D吗?它是一种相当新的语言,被编译为本机代码,并且可以直接链接到 C。(整个 C 标准库甚至可以从 D 获得,并且到 POSIX API 的绑定包含在标准库中。)基本上您需要做的所有事情要使用 D 中的任何 C 库,请使用 C 编译器对其进行编译,并翻译头文件中的函数原型、常量声明等。

D 的级别足够低,可以在其中编写实验内核,但具有垃圾收集(尽管仍然允许手动内存管理)、内置字符串和数组以及比 C++ 更高级/更易于使用模板元编程设施等现代功能。最大的缺点是缺乏用于企业级事物的成熟工具链和库,但对于您的目的而言,这可能并不重要。顺便说一句,如果您需要进行大量矩阵操作等操作,可以使用 SciD 项目,它提供了很好的功能LAPACK 和 BLAS 上的模板化包装器。

Have you considered D? It's a fairly new language, is compiled to native code and can link directly to C. (The entire C standard library is even available from D, and bindings to the POSIX API are included in the standard library.) Basically all you need to do to use any C library from D is compile it with a C compiler and translate the function prototypes, constant declarations, etc. in the header file.

D is low-level enough that an experimental kernel is written in it, but has modern features like garbage collection (though manual memory management is still permitted), builtin strings and arrays, and more advanced/easier to use template metaprogramming facilities than C++. The biggest disadvantage is lack of a mature toolchain and libraries for enterprise-y things, but for your purposes that probably doesn't matter. BTW, if you need to do a bunch of matrix manipulation and stuff, there's the SciD project, which provides nice templated wrappers over LAPACK and BLAS.

向日葵 2024-10-24 01:54:28

使用C++。你有空间。您可以使用它“作为更好的 C”来开始。

Use C++. You have the space. You can use it "as a better C" to start with.

不必你懂 2024-10-24 01:54:28

C++是一个更大的工具包;你为什么不想要那个!?您不需要使用所有工具,但使用 C 语言您别无选择。最重要的是,对于 C++,您可以选择使用 C 和 C++ 第三方库。

C++ is a bigger tool bag; why would you not want that!? You need not use all the tools, but with C you'd have no choice. Most importantly with C++ you have the choice of using both C and C++ third-party libraries.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文