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 / dummy_client.py
Last active July 3, 2019 09:59
A dummy client through which you can send and receive data. Built using socket programming in Python 3.5.
import socket
IP_ADDR = "127.0.0.1"
SOCKET_PORT = 5000
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as skt:
skt.connect((IP_ADDR, SOCKET_PORT))
while True:
usr_ch = input("Send or receive [s/r]? (0 to exit): ")
if usr_ch == 's':
@TheProjectsGuy
TheProjectsGuy / dummy_server.py
Last active July 3, 2019 09:59
A dummy socket that acts as a server through which you can send and receive data. Built using socket programming in Python 3.5.
import socket
IP_ADDR = "127.0.0.1"
SOCKET_PORT = 5000
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as skt:
skt.bind((IP_ADDR, SOCKET_PORT))
skt.listen(1)
(conn_skt, conn_addr) = skt.accept()
with conn_skt:
@TheProjectsGuy
TheProjectsGuy / SocketClientSpeaker.py
Created July 1, 2019 12:18
A simple socket client that will connect to a server, send "Hello World" and then end connection and terminate.
import socket
# IP address and port of connection
IP_ADDR = "127.0.0.1"
PORT = 50001
with socket.socket(
socket.AF_INET, socket.SOCK_STREAM
) as skt:
# Connect to the IP_ADDR and PORT (server address)
@TheProjectsGuy
TheProjectsGuy / SocketServerListener.py
Created July 1, 2019 12:11
A listener node which is a server. It simply connects, receives a message, prints it out, ends.
import socket
# An IP address for communication
IP_ADDR = "127.0.0.1" # Internal loop back
# Port to connect to
PORT_NO = 50001
with socket.socket(
socket.AF_INET, socket.SOCK_STREAM
) as skt:
@TheProjectsGuy
TheProjectsGuy / JointController.cpp
Created December 18, 2018 17:01
Joint controllers made using C++ and Python for RViZ (ROS)
#include "ros/ros.h"
#include "math.h"
#include "ros/time.h"
#include "sensor_msgs/JointState.h"
int main(int argv, char **argc) {
// Initialize node
ros::init(argv, argc, "CPP_Joint_State_Controller");
// Node handler
ros::NodeHandle nodeHandler;
@TheProjectsGuy
TheProjectsGuy / first_xacro.xacro
Created December 17, 2018 06:29
XACRO file code for XACRO tutorial in ROS
<?xml version="1.0"?>
<robot name="xacro_bot1" xmlns:xacro="http://www.ros.org/wiki/xacro">
<!-- Parameters -->
<xacro:property name="a" value="0.2" />
<!-- Links to be added -->
<!-- Add a link -->
<xacro:macro name="add_link" params="length name parent axis *origin">
<!-- Physical link -->
<link name="${name}_link">
@TheProjectsGuy
TheProjectsGuy / XACROLauncher.launch
Last active December 17, 2018 06:28
XACRO Launch file code
<launch>
<!-- Arguments -->
<arg name="model" default="first_xacro" doc="Model name (name of the XACRO file without extension)" />
<arg name="rviz_config" default="RobotViewer" doc="Name (withoug extension) of RViZ configuration file in 'rviz' folder" />
<arg name="use_gui" default="true" doc="true or false, if you want GUI" />
<!-- Parameters on the ROS parameter server -->
<param name="robot_description" command="xacro $(find intro_robot_description)/urdf/$(arg model).xacro" />
<param name="use_gui" value="$(arg use_gui)" />
@TheProjectsGuy
TheProjectsGuy / TempSensor.cpp
Created December 13, 2018 17:00
RViZ Tutorial 1 using sensor_msgs/Temperature in ROS
#include "ros/ros.h"
#include "std_msgs/Header.h"
#include "sensor_msgs/Temperature.h"
int main(int argc, char **argv) {
// Initialize the ROS node
ros::init(argc, argv, "TemperatureSensor", ros::init_options::AnonymousName);
// Node handler
ros::NodeHandle nodeHandler;
// Publisher object
@TheProjectsGuy
TheProjectsGuy / LaunchFile.launch
Created December 12, 2018 12:43
Launch file by setting the environment for log config in C++ and Python in ROS
<launch>
<!-- Environment using config -->
<env name="ROSCONSOLE_CONFIG_FILE" value="$(find intro_pkg1)/config/rosconsole_cpp.conf" />
<env name="ROS_PYTHON_LOG_CONFIG_FILE" value="$(find intro_pkg1)/config/rosconsole_python.conf" />
<!-- Argument parser made using C++ -->
<node name="Debugger1" pkg="intro_pkg1" type="AllLevelDebugger" launch-prefix="gnome-terminal --tab -e "/>
<node name="Debugger2" pkg="intro_pkg1" type="DebuggerAll.py" launch-prefix="gnome-terminal --tab -e" />
</launch>
@TheProjectsGuy
TheProjectsGuy / rosconsole_cpp.conf
Created December 12, 2018 12:41
Configuration files to change the debugger priority level in ROS using rosout for Python and roscpp for C++
# Override the rosconsole logger
# output level for this package ONLY
log4j.logger.ros.intro_pkg1=DEBUG