diff --git a/assignment_1/dyutimoy_print_squares/CMakeLists.txt b/assignment_1/dyutimoy_print_squares/CMakeLists.txt new file mode 100644 index 0000000..e3650f6 --- /dev/null +++ b/assignment_1/dyutimoy_print_squares/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 2.4.6) +include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) + +# Set the build type. Options are: +# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage +# Debug : w/ debug symbols, w/o optimization +# Release : w/o debug symbols, w/ optimization +# RelWithDebInfo : w/ debug symbols, w/ optimization +# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries +#set(ROS_BUILD_TYPE RelWithDebInfo) + +rosbuild_init() + +#set the default path for built executables to the "bin" directory +set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) +#set the default path for built libraries to the "lib" directory +set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) + +#uncomment if you have defined messages +rosbuild_genmsg() +#uncomment if you have defined services +rosbuild_gensrv() + +#common commands for building c++ executables and libraries +#rosbuild_add_library(${PROJECT_NAME} src/example.cpp) +#target_link_libraries(${PROJECT_NAME} another_library) +#rosbuild_add_boost_directories() +#rosbuild_link_boost(${PROJECT_NAME} thread) +#rosbuild_add_executable(example examples/example.cpp) +#target_link_libraries(example ${PROJECT_NAME}) +#rosbuild_add_executable(talker src/talker.cpp) +#rosbuild_add_executable(listener src/listener.cpp) +#rosbuild_add_executable(add_two_ints_server src/add_two_ints_server.cpp) +#rosbuild_add_executable(add_two_ints_client src/add_two_ints_client.cpp) +rosbuild_add_executable(dyutimoy_numbers src/dyutimoy_numbers.cpp) +rosbuild_add_executable(dyutimoy_squares src/dyutimoy_squares.cpp) +rosbuild_add_executable(dyutimoy_print src/dyutimoy_print.cpp) diff --git a/assignment_1/dyutimoy_print_squares/Makefile b/assignment_1/dyutimoy_print_squares/Makefile new file mode 100644 index 0000000..b75b928 --- /dev/null +++ b/assignment_1/dyutimoy_print_squares/Makefile @@ -0,0 +1 @@ +include $(shell rospack find mk)/cmake.mk \ No newline at end of file diff --git a/assignment_1/dyutimoy_print_squares/mainpage.dox b/assignment_1/dyutimoy_print_squares/mainpage.dox new file mode 100644 index 0000000..872299c --- /dev/null +++ b/assignment_1/dyutimoy_print_squares/mainpage.dox @@ -0,0 +1,14 @@ +/** +\mainpage +\htmlinclude manifest.html + +\b beginner_tutorials + + + +--> + + +*/ diff --git a/assignment_1/dyutimoy_print_squares/manifest.xml b/assignment_1/dyutimoy_print_squares/manifest.xml new file mode 100644 index 0000000..5ef3ddd --- /dev/null +++ b/assignment_1/dyutimoy_print_squares/manifest.xml @@ -0,0 +1,17 @@ + + + + beginner_tutorials + + + Dyutimoy + BSD + + http://ros.org/wiki/beginner_tutorials + + + + + + + diff --git a/assignment_1/dyutimoy_print_squares/src/dyutimoy_numbers b/assignment_1/dyutimoy_print_squares/src/dyutimoy_numbers new file mode 100644 index 0000000..6e39cd1 --- /dev/null +++ b/assignment_1/dyutimoy_print_squares/src/dyutimoy_numbers @@ -0,0 +1,39 @@ +#include "ros/ros.h" +#include "std_msgs/Int64.h" +#include + +#include + + +int main(int argc,char ** argv) +{ + ros::init(argc,argv,"dyutimoy_numbers"); + + ros::NodeHandle n; + + ros::Publisher number_pub= n.advertise("topic_number",1000); + //defining number_pub to publish the numbers + ros::Rate loop_rate(1.0); + //specifying the rate + int count = 0; + + while (ros::ok()) + { + std_msgs::Int64 num; + + num.data=count++; + + ROS_INFO("number_publish:[%ld]",num.data); + //printing the content to be published + number_pub.publish(num); + //publishing the number + ros::spinOnce(); + + loop_rate.sleep(); + + } + + return 0; + + +} diff --git a/assignment_1/dyutimoy_print_squares/src/dyutimoy_print b/assignment_1/dyutimoy_print_squares/src/dyutimoy_print new file mode 100644 index 0000000..f3b90e9 --- /dev/null +++ b/assignment_1/dyutimoy_print_squares/src/dyutimoy_print @@ -0,0 +1,28 @@ +#include "ros/ros.h" +#include "std_msgs/Int64.h" + +void numCallback(const std_msgs::Int64::ConstPtr& num) +{ + ROS_INFO("number[%ld]",num->data); + //printing the subscribered topic_numbers +} +void squaresCallback(const std_msgs::Int64::ConstPtr& squares) +{ + ROS_INFO("squares[%ld]",squares->data); + //printing the subscribed topic_squares +} + +int main(int argc,char **argv) +{ + ros::init(argc,argv,"dyutimoy_print"); + + ros::NodeHandle n; + + ros::Subscriber print_num_sub =n.subscribe("topic_number", 1000,numCallback); + //subscribing to topic_number + ros::Subscriber print_squares_sub =n.subscribe("topic_squares", 1000,squaresCallback); + //subscribing to topic_squares + ros::spin(); + + return 0; +} diff --git a/assignment_1/dyutimoy_print_squares/src/dyutimoy_squares b/assignment_1/dyutimoy_print_squares/src/dyutimoy_squares new file mode 100644 index 0000000..4331f22 --- /dev/null +++ b/assignment_1/dyutimoy_print_squares/src/dyutimoy_squares @@ -0,0 +1,47 @@ +#include "ros/ros.h" +#include "std_msgs/Int64.h" + +#include +#include + +#include + +void numCallback(const std_msgs::Int64::ConstPtr& num) +{ + std_msgs::Int64 squares; + + squares.data=num->data*num->data; + //finding squares + + ros::NodeHandle n1; + + ros::Publisher squares_pub= n1.advertise("topic_squares",1000); + // defining the publisher and the rate + ros::Rate loop_rate(1.0); + while(ros::ok()) + { + + ROS_INFO ("squares_publish:[%ld]",squares.data); + //printing the output to be published + squares_pub.publish(squares); + //publishing + ros::spin(); + loop_rate.sleep(); + } +} + +int main(int argc,char **argv) +{ + ros::init(argc,argv,"dyutimoy_squares"); + + ros::NodeHandle n; + + ros::Subscriber squares_sub= n.subscribe("topic_number", 1000, numCallback); + //susbscribing to topic_number + + + ros::spin(); + return 0; + + +}