Skip to content

Instantly share code, notes, and snippets.

View TheProjectsGuy's full-sized avatar
🎯
Focusing

Avneesh Mishra TheProjectsGuy

🎯
Focusing
View GitHub Profile
@TheProjectsGuy
TheProjectsGuy / ArgumentParser.cpp
Last active December 8, 2018 06:06
CPP Argument parser using ROS
// Include the main header file
#include "ros/ros.h"
int main(int argc, char **argv) {
// Initialize the node
ros::init(argc, argv, "ArgumentParser");
// Print information about the arguments passed
std::cout<<argc<<" arguments"<<std::endl;
for (int i = 0; i < argc; i++) {
std::cout<<"Argument "<<i<<": "<<argv[i]<<std::endl;
@TheProjectsGuy
TheProjectsGuy / ArgsParser.py
Created December 8, 2018 06:07
Argument parser made using python for ROS
#!/usr/bin/env python
# Import files
import rospy
import sys
# Only if the script is directly run
if __name__ == "__main__":
# Initialize node
rospy.init_node('ArgumentParser_Python', anonymous=True)
@TheProjectsGuy
TheProjectsGuy / DebuggerAll.py
Created December 8, 2018 13:37
Debugger node made using Python which prints all message levels
#!/usr/bin/env python
import rospy
if __name__ == "__main__":
# Initialize the node
rospy.init_node("Debugger_Python", anonymous=True)
# Rate of 2 times a second (2 Hz)
rateHandler = rospy.Rate(2)
while (not rospy.is_shutdown()):
@TheProjectsGuy
TheProjectsGuy / DebuggerAll.cpp
Created December 8, 2018 13:38
Debugger node created using C++ in ROS
#include "ros/ros.h"
#include "stdlib.h"
int main(int argc, char **argv) {
// Initialize ROS node
ros::init(argc, argv, "DebuggerCheck");
// Node handler
ros::NodeHandle nodeHandler;
@TheProjectsGuy
TheProjectsGuy / NumberPublisher.cpp
Created December 9, 2018 13:30
Simple Publisher made using C++ in ROS
// Header file for ROS
#include "ros/ros.h"
// Header file for messages
#include "std_msgs/Float64.h"
int main(int argc, char **argv)
{
// Initialize the node, name it NumberPublisher
ros::init(argc, argv, "NumberPublisher");
// Create a node handler
@TheProjectsGuy
TheProjectsGuy / NumberSubscriber.cpp
Created December 9, 2018 13:32
Simple Subscriber made using C++ in ROS
// Include the ROS header file
#include "ros/ros.h"
// Message data type
#include "std_msgs/Float64.h"
// Caller function
void receivedMessage(const std_msgs::Float64::ConstPtr &msg) {
ROS_INFO("Number received: %f", msg->data);
}
@TheProjectsGuy
TheProjectsGuy / NumberPublisher.py
Created December 9, 2018 13:36
Simple Publisher made using Python in ROS
#!/usr/bin/env python
import rospy
# Message class
from std_msgs.msg import Float64
# Main function
def main():
# Initialize node
rospy.init_node('NumberPublisher', anonymous= True)
# Publisher object
@TheProjectsGuy
TheProjectsGuy / NumberSubscriber.py
Created December 9, 2018 13:39
Simple Subscriber made using Python in ROS
#!/usr/bin/env python
import rospy
from std_msgs.msg import Float64
# Function callback
def msgReceived(msg):
# Parse the received message as Float 64 type
message = Float64(msg)
# Log that as INFO
rospy.loginfo("Received: {0}".format(message.data))
@TheProjectsGuy
TheProjectsGuy / Equ.msg
Created December 9, 2018 18:29
Simple message create using MDL on ROS
# Information
string info
# Floating point value
float64 value
@TheProjectsGuy
TheProjectsGuy / Equ.msg
Created December 9, 2018 18:29
Simple message create using MDL on ROS
# Information
string info
# Floating point value
float64 value