Skip to content

Instantly share code, notes, and snippets.

@rethink-imcmahon
rethink-imcmahon / ros_image_saver.py
Last active April 17, 2024 08:09
ROS Image Subscriber / JPEG Saver
#! /usr/bin/python
# Copyright (c) 2015, Rethink Robotics, Inc.
# Using this CvBridge Tutorial for converting
# ROS images to OpenCV2 images
# http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython
# Using this OpenCV2 tutorial for saving Images:
# http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_gui/py_image_display/py_image_display.html
@rethink-imcmahon
rethink-imcmahon / image_republisher.py
Created January 28, 2016 19:45
Take and Image stream and redirect it to Baxter's Display
#! /usr/bin/python
# Copyright (c) 2016 Rethink Robotics, Inc.
# rospy for the subscriber
import rospy
# ROS Image message
from sensor_msgs.msg import Image
def image_callback(msg, pub):
pub.publish(msg)
@rethink-imcmahon
rethink-imcmahon / baxter_joint_cmd.cpp
Last active December 7, 2017 07:11
Baxter Joint Command through ROS Interface example
#include "ros/ros.h"
#include "baxter_core_msgs/JointCommand.h"
int main(int argc, char **argv)
{
ros::init(argc, argv, "baxter_left_arm_joint_pub");
ros::NodeHandle n;
ros::Publisher left_cmd_pub = n.advertise<baxter_core_msgs::JointCommand>("/robot/limb/left/joint_command", 1);
// publish at at least 5 Hz, or else Baxter switches back to Position mode and holds position
ros::Rate loop_rate(100);
baxter_core_msgs::JointCommand cmd;
<?xml version="1.0" ?>
<launch>
<!-- Load the URDF into the ROS Parameter Server -->
<param name="robot_description" command="cat '$(find your_robot_description)urdf/your.urdf'" />
<node pkg="joint_state_publisher" type="joint_state_publisher" name="joint_state_publisher" output="screen" args="_use_gui:=true"/>
<!-- Publish a static transform between the world and the base of the robot -->
<node pkg="tf2_ros" type="static_transform_publisher" name="base_to_world" args="0 0 0 0 0 0 1 world base" />
@rethink-imcmahon
rethink-imcmahon / pedestal.yaml
Last active December 16, 2015 20:31
Baxter's base pedestal: rostopic pub /robot/urdf baxter_core_msgs/URDFConfiguration -f pedestal.yaml
time:
secs: 1449783752
nsecs: 232993
link: 'torso'
joint: 'pedestal_fixed'
urdf: '<?xml version="1.0" ?>
<robot name="pedestal">
<link name="pedestal">
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
@rethink-imcmahon
rethink-imcmahon / block.yaml
Last active December 10, 2015 15:51
A block to replace baxter's base: rostopic pub /robot/urdf baxter_core_msgs/URDFConfiguration -f block.yaml
time:
secs: 1449703751
nsecs: 232993
link: 'torso'
joint: 'pedestal_fixed'
urdf: '<robot name="pedestal">
<link name="block">
<inertial>
<origin xyz="0.0 0.0 0.0" />
<mass value="40" />
@rethink-imcmahon
rethink-imcmahon / bringup_test_robot.launch
Last active December 2, 2015 20:29
Launch file that I use for testing & tweaking URDFs, Meshes, and Xacros for baxter
<?xml version="1.0" ?>
<launch>
<!-- Load the URDF into the ROS Parameter Server -->
<!-- param name="robot_description" command="cat '$(find baxter_description)/urdf/baxter.urdf'" / -->
<!-- param name="robot_base_description" command="cat '/data/users/imcmahon/dev/mrsp_ws/baxter_urdf.xml'" / -->
<param name="robot_description"
command="$(find xacro)/xacro.py --inorder $(find baxter_description)/urdf/baxter.urdf.xacro" />
<!-- param name="use_sim_time" type="bool" value="true"/-->
<!-- node pkg="rosbag" type="play" name="player" output="screen" args="-i-clock -l /data/users/imcmahon/dev/mrsp_ws/joint_states_increasing_2015-06-12-14-39-06.bag"/ -->
@rethink-imcmahon
rethink-imcmahon / ros.cson
Last active September 28, 2015 08:13
ROS file type extensions - ATOM editor extension "file-types" mapping in config.cson (https://atom.io/packages/file-types)
"file-types": {
'.launch': 'text.xml'
'.world': 'text.xml'
'.xacro': 'text.xml'
'.urdf': 'text.xml'
'.msg': 'source.yaml'
'.srv': 'source.yaml'
'CMakeLists.txt': 'source.cmake'
'.rosinstall': 'source.yaml'
}
@rethink-imcmahon
rethink-imcmahon / timer_callback_broken.cpp
Created August 31, 2015 21:58
Timer Callback Execution Broken by Patch #654
Breakpoint 1 at 0x403bfb: file /data/users/imcmahon/dev/ros_core_ws/src/ros_tutorials/roscpp_tutorials/timers/timers.cpp, line 59.
(gdb) s
The program is not being run.
(gdb) run
Starting program: /data/users/imcmahon/dev/ros_core_ws/devel/lib/roscpp_tutorials/timers
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff1880700 (LWP 23552)]
[New Thread 0x7ffff107f700 (LWP 23553)]
[New Thread 0x7ffff087e700 (LWP 23554)]
@rethink-imcmahon
rethink-imcmahon / timer_callback_functioning.cpp
Created August 31, 2015 21:36
Properly Functioning Timer Callback Execution
PWD=/data/users/imcmahon/dev/ros_core_ws/devel/lib/roscpp_tutorials
---Type <return> to continue, or q <return> to quit---q
Quit
(gdb) b 55
Breakpoint 1 at 0x403aee: file /data/users/imcmahon/dev/ros_core_ws/src/ros_tutorials/roscpp_tutorials/timers/timers.cpp, line 55.
(gdb) run
Starting program: /data/users/imcmahon/dev/ros_core_ws/devel/lib/roscpp_tutorials/timers
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff1881700 (LWP 6059)]