This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ros/ros.h> | |
int main(int argc, char** argv) { | |
ros::init(argc, argv, "Hello, World"); | |
ros::NodeHandle nh; ROS_INFO("Hello, World!"); | |
ros::spinOnce(); return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<launch> | |
<!-- ~/catkin_ws/src/my_package/launch/minimal.launch --> | |
<node pkg="my_package" type="simple" name="HelloWorld" output="screen"></node> | |
</launch> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ros/ros.h> | |
int main(int argc, char** argv) { | |
ros::init(argc, argv, "ObiWan"); | |
ros::NodeHandle nh; | |
ros::Rate loop_rate(2); // We create a Rate object of 2Hz | |
while (ros::ok()) { // Endless loop until Ctrl + C | |
ROS_INFO("Hello, World!"); | |
ros::spinOnce(); | |
loop_rate.sleep(); // We sleep the needed time to maintain the Rate fixed above | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ros/ros.h> | |
#include <std_msgs/Int32.h> | |
int main(int argc, char** argv) { | |
ros::init(argc, argv, "topic_publisher"); | |
ros::NodeHandle nh; | |
ros::Publisher pub = nh.advertise<std_msgs::Int32>("counter", 1000); | |
ros::Rate loop_rate(2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ros/ros.h> | |
#include <geometry_msgs/Twist.h> | |
int main(int argc, char** argv) { | |
ros::init(argc, argv, "topic_publisher"); ros::NodeHandle nh; | |
ros::Publisher pub = nh.advertise("cmd_vel",1000); | |
ros::Rate loop_rate(2); | |
geometry_msgs::Twist twist; | |
twist.linear.x=0.5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ros/ros.h> | |
#include <std_msgs/Int32> | |
void counterCallback(const std_msgs::Int32::ConstPtr& msg) | |
{ | |
ROS_INFO("%d", msg->data); | |
} | |
int main(int argc, char** argv) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ros/ros.h> | |
#include <sensor_msgs/LaserScan.h> | |
void counterCallback(const sensor_msgs::LaserScan::ConstPtr& msg){ | |
ROS_INFO("LaserScan (val,angle)=(%f,%f", msg->range_min,msg->angle_min); | |
} | |
int main(int argc, char** argv) { | |
ros::init(argc, argv, "topic_subscriber"); | |
ros::NodeHandle nh; | |
ros::Subscriber sub = nh.subscribe("/kobuki/laser/scan", 1000, counterCallback); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ros/ros.h" | |
#include "gazebo_msgs/DeleteModel.h" | |
int main(int argc, char **argv){ | |
ros::init(argc, argv, "service_client"); // Initialise a ROS node with the name service_client | |
ros::NodeHandle nh; | |
// Create the connection to the service /gazebo/delete_model | |
ros::ServiceClient delete_model_service = nh.serviceClient<gazebo_msgs::DeleteModel>("/gazebo/delete_model"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ros/ros.h" #include "std_srvs/Empty.h" // Import the service message header file generated from the Empty.srv message | |
bool my_callback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res){ | |
//process some action | |
ROS_INFO("My_callback has been called"); | |
return true; | |
} | |
int main(int argc, char **argv){ | |
ros::init(argc, argv, "service_server"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find_package(catkin REQUIRED COMPONENTS roscpp std_msgs message_generation ) | |
... | |
add_service_files( | |
FILES | |
MyCustomServiceMessage.srv | |
) | |
... |
OlderNewer