Skip to content

Instantly share code, notes, and snippets.

View lucascoelhof's full-sized avatar
🤖
Rebooting...

Lucas Coelho Figueiredo lucascoelhof

🤖
Rebooting...
  • Realtime Robotics
View GitHub Profile
@lucascoelhof
lucascoelhof / transform_pose.cpp
Created August 27, 2019 12:09
Transform a ROS Pose msg with another pose
geometry_msgs::Pose transformPose(geometry_msgs::Pose& _origin_to_frame, geometry_msgs::Pose& _frame_to_target)
{
geometry_msgs::Pose result;
tf::Transform origin_to_frame_transform;
origin_to_frame_transform.setOrigin(tf::Vector3(_origin_to_frame.position.x, _origin_to_frame.position.y, _origin_to_frame.position.z));
origin_to_frame_transform.setRotation(tf::Quaternion(_origin_to_frame.orientation.x, _origin_to_frame.orientation.y,
_origin_to_frame.orientation.z, _origin_to_frame.orientation.w));
tf::Transform frame_to_target_transform;
frame_to_target_transform.setOrigin(tf::Vector3(_frame_to_target.position.x, _frame_to_target.position.y, _frame_to_target.position.z));
@lucascoelhof
lucascoelhof / getKDLTransform.cpp
Last active February 16, 2018 16:53
How to get a transformation frame from KDL Tree ROS
#include <geometry_msgs/Pose.h>
#include <kdl/tree.hpp>
bool getTransformFromKDL(KDL::Tree tree, std::string root, std::string child, geometry_msgs::Pose& pose)
{
try
{
KDL::Chain chain;
tree.getChain(root, child, chain);
@lucascoelhof
lucascoelhof / unset_vars.bash
Created January 4, 2018 22:34
How to unset all bash variables that match a prefix
unset $(echo "${!PREFIX*}")
@lucascoelhof
lucascoelhof / clean_docopt_args.py
Last active January 2, 2018 12:10
If receiving a dictionary from docopt with -- and <> annoys you, this function might help
import re
def clean_arguments(args):
"""Cleans docopt arguments, removing --, - and < > from arguments
Parameters
----------
args : dict
Dictionary with arguments form docopt
@lucascoelhof
lucascoelhof / dict_regex_del.py
Last active January 25, 2023 04:04
How to delete a dictionary key that matches a regex (regular expression) in python
pattern = re.compile(regex)
matched_keys = {key for key, value in dic.iteritems() if pattern.match(key)}
for key in matched_keys:
dic.pop(key, None)