Ros: output in console - c++

I'm a beginner in ROS and started to learn the basics. So I have installed ROS and I am going through some tutorials. I have created two nodes (publisher and subscriber). Actually I was doing this ROS.org tutorial
1: At Step 3. Building your nodes, I get an error if I type catkin_make. Everything is setup like in the tutorial but its not working.
The error is:
add_message_files() directory not found
And
Makefile:710: recipe for target 'cmake_check_build_system' failed
I don't know what to do here.
2: Is there a possibility to make an output without using launchfiles? I have looked it up and I noticed that you have to use launchfiles only if you want to run more than one node.
In this Youtube tutorial
6:06 min the guy is using a cout in his callback function. I have also tried it like him and I changed my cmakelists equally like his but I don't get an output in my terminal. He does. In the next part the guy is changing some parts in his cmakelists but it doesn't help to get an output in the terminal.
So my question summarized is: How do I use cout and ROS_INFO or ROS_DEBUG correctly?

Your CMakeLists.txt file contains add_message_files that has no
a path to .msg file (or wrong syntax)
Post your CMakeLists.txt if you want further help on that.
Launch files are merely .xml files that tells ROS system to run
specific node and make it easier to pass params or env
variables to nodes. you can run single node with rosrun command
or even finding its binary file (wherever u compiled or installed
it)
And of course you can cout it's C++ after all.
Also if you need help on ROS_<log_level> you can take a look at rosccp logging overview

Related

Xcode writing to file issue

I'm trying to help my son with a Programming C++ for Engineers course. I got him set up with Xcode 13.1 on his iMac but I've never used it myself. That was working great until his first assignment that required writing output to a file. We created a new Command Line Tool project and then used the File->New->File... option to create an Empty file. After doing so, selecting that file and looking at the info on the right side of the window shows that the Full Path is pointing to the directory where his main.cpp file is. Yet, when running his code nothing was being written to the file. I had assumed that just referencing the file name in his code would cause it to use a local reference and look in the same directory as main.cpp. After much Googling I found a reference that said to go to Product->Scheme->Edit Scheme... then select the Options tab in the window that opens and change the Working Directory from "$(BUILT_PRODUCTS_DIR)" to the directory containing the main.cpp file. That got the programming working correctly. My questions are:
Is there a preference setting that would tell it to always use the current project directory so that we don't have to change this every time?
Where does "$(BUILT_PRODUCTS_DIR)" point to?
What should we be doing differently?

Running exe code from Matlab. The exact same instruction that works in cmd (dos) fails from Matlab

This is driving me crazy, I must admit. After finally being able to successfully compile two functions I need to process voice files, from C/C++ code that I downloaded from a trustworthy online repository (code that had been thoroughly tested in Linux), I am now struggling to launch those files from Matlab...
When I type the following command in cmd (dos)
Analysis b2.wav config_default
it works, no problem (see here Works).
Then, I build the exact same command into a string and feed it to the "system" Matlab function. Then the code crashes... (see here Fails) I've tried with full paths (c:\b2.wav, etc) but still does not work...
Any ideas as to why this might be happening?
Your image shows that the program Analysis stopped unexpectedly.
It might be a lot of reasons why, so let's go step by step:
1) Try executing Analysis from Terminal and passing wrong parameters (a file that doesn't exist, only one param (missing the config_defalut), no parameters at all, three parameters, etc...)
Can you make the program crash from terminal by passing wrong params?
2) Try creating the command first, checking that it's correct (\b is actually \b instead of a string modifier)
command_to_be_run = 'C:\Analysis C:\b2.wav C:\config_default'
disp(command_to_be_run) % is it showing exacly what you want?
system(command_to_be_run); % if so, run it.
3) Try creating a dummy executable dummy.exe in C that accepts two parameters and prints the received parameters (keep it super simple, just printing). Call it from Terminal. Does it work? Call it from Matlba. Does it Work?
With this 3 tests you can considerably narrow down where your error comes from.
By the way, is "config_default" a file or just a string that tells analysis how to behave? In some examples you treat it as a file, in others as a parameter without path.
Based on what's been tried so far and the outputs, here's my theory:
Premise: Analysis.exe came from code that's well tested in Linux. It works in Windows command line when run from the same directory where both it and the target file reside. But it stops working from Matlab console.
Assertion 1: Matlab console does not operate within the context of the directory where the binary is but rather within the Matlab directory. As such, Analysis.exe will try to find the target from the Matlab directory.
Validation for Assertion 1: Try putting the binary and the target wav in the Matlab directory. Then run system with the binary and target specified just by name (no path).
Assertion 2: If the file's full path is specified to address this issue, it still doesn't work. This may be because the code assumed a Linux file system where the delimiter is "/" rather than "\".
Validation for Assertion 2: Run with paths specified from the command line while in a diferent directory to see if it fails or not.
Possible Solution 1: Add the directory where both Analysis.exe and the target are into the Matlab path: (1) On the Home tab, in the Environment section, click Set Path. Add the path there. (2) addpath (folderName1,...,folderNameN) adds the specified folders to the top of the search path for the current MATLAB session. -> Then run the system command without the full paths.
Possible Solution 2: Add the directory where both Analysis.exe and the target are into the Windows environment path. Then run the system command without the full paths.
EDIT: Possible hackish solution - Create a batch file where: (1) you would cd to the directory where Analysis.exe and the target wav are; and (2) do a Matlab system call to the batch file.
EDIT 2: Possible experiment to validate assertion 2.

Changing name of application file (.C file)

I changed the name of an modified application to seperate it from the basic application. Lets say the .C file of the old application is "OldApplication.C" and of the new modified one is "NewApplication.C" Unfortunately, when trying to start the new modified application in terminal by typing "NewApplication" I get:
NewApplication: command not found
Two Question:
How can I make my new application executeable?
Can someone give me a brief overview about the files of a project/application and their functions?
greetings, streight
The mistake of this kind
make: * No rule to make target OldApplication.dep', needed byMake/linuxGccDPOpt/dependencies'. Stop.
often occurs in situation when the Makefile ceases to comply with the structure of the whole project.
In your case make script obviously trying to find the file that was renamed by you and therefore it fails with en error. I think that you should explore the structure of your Makefile and replace all the changed file names with its new versions.
Also you say the you are refused to launch your new executable, but what else could be expected since the project was not compiled?

c++ boost library cannot open file

I tried to work with the boost library to read/write configuration files but I just don't get it.
I even can't run the example code from boost.org (5 Minute Tutorial)
http://www.boost.org/doc/libs/1_49_0/libs/property_tree/examples/debug_settings.cpp
I've downloaded the boost_1_49_0.zip package and unzipped it to my c++ program folder. The code compiles (TheIDE - U++) but it always says "Error: debug_settings.xml: cannot open file" which basically means that the program works, but runs into the exception.
I didn't change the code, I just copy and pasted it to get a working example which I could try to understand then. But I don't even get this one to work. (Since it's exactly the same as in the link, I don't paste the code here... unless you think it's better.)
Please help me... or point to a different way to store variables in a file with some kind of structure (I wan't to learn a way that works for windows and linux, because some of my apps are cross-platform.)
Thanks.
EDIT: debug_settings.xml is in the same folder as the .cpp file
EDIT2: Working now, the debug_settings.xml is now in the folder where the executable is stored. (in my case, U++/TheIDE it's C:\upp\out\MyApps\MINGW.Debug.Debug_Full.Sse2 for debugging)
The configuration file would need to be in the working directory of the executable when it's running.

Problem related to dll

Can anyone guide me what could be the problem in the mentioned below:-
alt text http://lh5.ggpht.com/_D1MfgvBDtsU/S5iLmYivj1I/AAAAAAAAABU/8Mquam_XxZ4/s912/dll%20issue.PNG
This PP folder is present in the following path at my desk "E:\WINCE600\PLATFORM\COMMON\SRC\SOC\COMMON_FSL_V2_PDK1_7\IPUV3"
In this IPUV3 folder, PP folder is present which does the resize,rotation & conversion task of an image. This PP folder consists of PDK & SDK . Inside PDK folder there is a file called Ppclass.cpp which i have modified.
After modifying the Ppclass.cpp i have
rebuild the PP folder to check whether
in my project the modification is
reflected or not. But later i found
that the problem is of pp.dll which
even after the rebuild of PP folder
the new pp.dll is not highlighted.
Also the path for iMX51-EVK-PDK1_7 is as follows:
"E:\WINCE600\PLATFORM\iMX51-EVK-PDK1_7\target"
So now i want advice that how to sort this problem. I am sure that this problem is related to pp.dll
Please guide me to follow the correct step. I will be very thankful to u all.
Thanks in Advance
Was everything working as expected before the code change?
Are you getting any build errors?
Do you have a DIRS file in the IPUV3 directory that specifies the two subdirectories?
What is the problem? State what you did, what you expect and what was the outcome. It is not clear right now.
Update:
According to the comment below it seems that the build process is having trouble parsing one of your SOURCES files. From the error my guess is you have someting similar to:
SOURCELIBS=E:\...
Try:
SOURCELIBS=\
E:\...
The \ symbol tells the tool that there is are more values on the next line.
By the way, I don't know who wrote this on the SOURCES file, but I think it is bad practice to use absolute paths. You should use the macro for your platform path _TARGETPLATROOT. Use it like this: $(_TARGETPLATROOT)\...