A beginner ROS package that implements simple publisher-subscriber nodes in ROS. Additionally implements ROSbag, tf, and Rostest/gtest
To install ROS refer this link.
Project requires and evironment with Ubuntu 18.04, ROS Melodic
git clone --recursive https://github.com/kavyadevd/beginner_tutorials.git
cp <repository_path> <catkin_workspace_path/src/>
cd <catkin_workspace>
source ./devel/setup.bash
catkin_make
roscore
rosrun beginner_tutorials talker
rosrun beginner_tutorials listener
roslaunch beginner_tutorials LaunchTalkerListener.launch frequency:=<desired-frequency>
This command will launch published and subscriber.
rosservice call /ServiceFile "<desired-custom-message>"
rosrun rqt_console rqt_console
rosrun rqt_logger_level rqt_logger_level
rosrun tf tf_echo /world /talk
rosrun rqt_tf_tree rqt_tf_tree
To make the test files execute the following commands successively
catkin_make tests
catkin_make test
Launch the testcases launch by executing the following command
rostest beginner_tutorials TalkerListenerTest.launch frequency:=5
Output will be similiar to :
... logging to /home/kavya/.ros/log/rostest-Matrix-27255.log
[ROSUNIT] Outputting test results to /home/kavya/.ros/test_results/beginner_tutorials/rostest-test_TalkerListenerTest.xml
[ WARN] [1636828912.923804367]: Publisher message will be changed.
[Testcase: testTalkerListenerTest] ... ok
[ROSTEST]-----------------------------------------------------------------------
[beginner_tutorials.rosunit-TalkerListenerTest/TestPublisherExists][passed]
[beginner_tutorials.rosunit-TalkerListenerTest/TestMessageChangeService][passed]
SUMMARY
* RESULT: SUCCESS
* TESTS: 2
* ERRORS: 0
* FAILURES: 0
rostest log file is in /home/kavya/.ros/log/rostest-Matrix-27255.log
rosbag is a set of tools for recording from and playing back to ROS topics. It is intended to be high performance and avoids deserialization and reserialization of the messages. Read more
To record a bagfile run following commands: Terminal 1
rosrun beginner_tutorials talker
Terminal 2
mkdir ~/bagfiles
cd ~/bagfiles
rosbag record -a
This will record till you stop it by typing Ctrl+C
Check recorded bag file info using the command:
rosbag info <bag-file-name>
To check the validity of bag file we will start listener node and check if the recorded messages are heard by listener.
Terminal 1:
rosrun beginner_tutorials listener
Terminal 2:
rosbag play <rosbag-file-path>/<rosbag-file>.bag
roslaunch beginner_tutorials LaunchTalkerListener.launch rosbag_flag:=true
An active operation running on a terminal can be terminated by giving a Ctrl+C input from keyboard at any time.
-
CppCheckEclipse
To install and run cppcheck in Eclipse
-
In Eclipse, go to Window -> Preferences -> C/C++ -> cppcheclipse. Set cppcheck binary path to "/usr/bin/cppcheck".
-
To run CPPCheck on a project, right-click on the project name in the Project Explorer and choose cppcheck -> Run cppcheck.
-
To run on terminal
cppcheck --enable=all --std=c++11 -I include/ --suppress=missingIncludeSystem $( find . -name *.cpp -or -name *.h | grep -vE -e "^./build/" -e "^./vendor/") > Results/cppcheckoutput.txt
Results are present at Results/cppcheckoutput.txt
-
-
Cpplint
- To run cpplint on terminal
cpplint $( find . -name *.cpp | grep -vE -e "^./build/" -e "^./vendor/") $( find . -name *.hpp | grep -vE -e "^./build/" -e "^./vendor/") > Results/cpplintoutput.txt
Results are present at Results/cpplintoutput.xml
-
Google C++ Style
To include and use Google C++ Style formatter in Eclipse
-
In Eclipse, go to Window -> Preferences -> C/C++ -> Code Style -> Formatter. Import eclipse-cpp-google-style and apply.
-
To use Google C++ style formatter, right-click on the source code or folder in Project Explorer and choose Source -> Format
-
-
Doxygen
The HTML page for project outlines can be generated using the following commands
doxygen -g doxygen Doxyfile
The project is licensed under MIT License. Click here to know more