bhuman / BHumanCodeRelease

The official B-Human code releases
Other
194 stars 129 forks source link

How to add a new card into bhuman? #45

Closed TimePrinciple closed 2 years ago

TimePrinciple commented 2 years ago

I created a newcard.cpp under the directory "Src/Modules/BehaviorControl/BehaviorControl/Cards/Defender/" and added the card into gameplayCard.cfg and remove the "theActivitySkill" but it won't complie, can I be told what I need to do to add a new card into bhuman and get it to work, please.

chenqiao637 commented 2 years ago

邮件已收到,谢谢

ahasselbring commented 2 years ago

Is the problem that (1) the card is not compiled at all and thus there is a runtime error, or (2) are there errors when the card is compiled?

If (1), there are different steps required depending on the platform for the new file to be registered by the build system. On Linux, you must touch Make/Common/CMakeLists.txt. On Windows/Visual Studio, you must call the script Make/VS2019/generate.cmd. On macOS/Xcode, you must call the script Make/macOS/generate (or select the correct targets when the file is created).

If (2), I would need the compiler's error message and parts of the source code to help effectively.

TimePrinciple commented 2 years ago

Is the problem that (1) the card is not compiled at all and thus there is a runtime error, or (2) are there errors when the card is compiled?

If (1), there are different steps required depending on the platform for the new file to be registered by the build system. On Linux, you must touch Make/Common/CMakeLists.txt. On Windows/Visual Studio, you must call the script Make/VS2019/generate.cmd. On macOS/Xcode, you must call the script Make/macOS/generate (or select the correct targets when the file is created).

If (2), I would need the compiler's error message and parts of the source code to help effectively.

Sorry I forgot to mention the system I built Bhuman is Ubuntu 20.04LTS, and I compiled the project via Clion. Everything is perfectly working before I added the newcard.cpp into "Src/Modules/BehaviorControl/BehaviorControl/Cards/". The error message indicate that this newly added cpp file is not compiled probably. (I also noticed when I was editing the newly added cpp file, the #include preprocessor can not find headers, not even "Representations/BehaviorControl/FieldBall.h" Now if I want to add a card and get it to work, what should I do with the Make/Common/CMakeLists.txt. Can I get an example? Thanks for your generous help.

ahasselbring commented 2 years ago

Running the shell command touch Make/Common/CMakeLists.txt in the B-Human directory updates the timestamp of the file and makes CMake notice that a file has changed on the next build. In CLion, you can also trigger a reload of the CMake project, which should make CLion recognize the new file: https://www.jetbrains.com/help/clion/reloading-project.html#reload-on-demand

TimePrinciple commented 2 years ago

Running the shell command touch Make/Common/CMakeLists.txt in the B-Human directory updates the timestamp of the file and makes CMake notice that a file has changed on the next build. In CLion, you can also trigger a reload of the CMake project, which should make CLion recognize the new file: https://www.jetbrains.com/help/clion/reloading-project.html#reload-on-demand

You've been very helpful, thank you.