-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_math_node.cpp
More file actions
43 lines (35 loc) · 1.15 KB
/
basic_math_node.cpp
File metadata and controls
43 lines (35 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @file basic_math_node.cpp
* @author Avneesh Mishra (123avneesh@gmail.com)
* @brief
* A basic C++ node written to demonstrate the use of `basic_math` library
* @version 0.1
* @date 2021-04-13
*
* @copyright Copyright (c) 2021
*
*/
// Basic header files
#include <ros/ros.h>
// Include the library
#include "basic_math/basic_math.hpp"
// Use the std namespace
using namespace std;
int main(int argc, char **argv)
{
// Initialize the node
ros::init(argc, argv, "basic_math_node");
// Use the factorial function
long int fact_val = basic_math::factorial(5);
ROS_INFO_STREAM("Factorial of 5 is: " << fact_val);
// Use RealNumbers
basic_math::RealNumber<double> num1(10);
basic_math::RealNumber<double> num2(15.5);
ROS_INFO_STREAM("Number 1 = " << num1 << " and Number 2 = " << num2);
ROS_INFO_STREAM("Value for sum: " << (num1 + num2).to_string());
ROS_INFO_STREAM("Value for subtraction: " << (num1 - num2).to_string());
ROS_INFO_STREAM("Value for multiplication: " << (num1 * num2).to_string());
ROS_INFO_STREAM("Value for division: " << (num1 / num2).to_string());
// Exit
return 0;
}