Skip to content

Commit

Permalink
add simple subscriber
Browse files Browse the repository at this point in the history
  • Loading branch information
gunarp committed Nov 12, 2020
1 parent eb80a1a commit f04aad1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/wb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ include_directories(
${roscpp_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${GAZEBO_INCLUDE_DIRS}
src
)

# Compile plugin
Expand All @@ -57,3 +58,7 @@ catkin_install_python(PROGRAMS scripts/key_in.py
catkin_install_python(PROGRAMS scripts/cam_control.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

# Compile the simple subscriber
add_executable(simp src/simple_sub.cc)
target_link_libraries(simp ${catkin_LIBRARIES} ${roscpp_LIBRARIES})
25 changes: 25 additions & 0 deletions src/wb/src/simple_sub.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
#include <string>
#include "./simple_sub.h"

int main(int argc, char **argv) {
// Step 1: Set up the node

// Set up subscriber
std::string subName = "/wheely_boi/wheely_boi/cmd";
// Step 2: Attach a subscriber to this node and point to chatterCallback

// Don't go past this point so long as ros node is alive
// Uncommnet this line when you're done
// ros::spin();


// Return success
return 0;
}

void chatterCallback(const geometry_msgs::Twist& t) {
ROS_INFO("Linear: (%f, %f)", t.linear.x, t.linear.z);
ROS_INFO("Angular: (%f, %f)\n", t.angular.x, t.angular.z);
}
11 changes: 11 additions & 0 deletions src/wb/src/simple_sub.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef SIMPLE_SUB_H_
#define SIMPLE_SUB_H_

#include <ros/ros.h>
#include <geometry_msgs/Twist.h>

// Target function our subscriber will use to
// process information gathered from topic
void chatterCallback(const geometry_msgs::Twist&);

#endif //SIMPLE_SUB_H_

0 comments on commit f04aad1

Please sign in to comment.