ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

lgeorge's profile - activity

2020-05-19 05:08:02 -0500 edited answer transform pose in tf2

In my understanding the tf2_geometry_msgs are not build for python (the binding) in ros eloquent, you need this pullrequ

2020-05-19 05:08:02 -0500 received badge  Editor (source)
2020-05-19 05:07:40 -0500 answered a question transform pose in tf2

In my understanding the tf2_geometry_msgs are not build (the binding) in ros eloquent, you need this pullrequest, and th

2019-10-04 19:08:59 -0500 received badge  Enlightened (source)
2019-10-04 19:08:59 -0500 received badge  Good Answer (source)
2018-10-18 06:33:19 -0500 received badge  Nice Question (source)
2018-02-23 08:03:40 -0500 received badge  Good Answer (source)
2017-09-13 06:25:13 -0500 received badge  Nice Answer (source)
2017-04-28 05:42:59 -0500 received badge  Nice Answer (source)
2017-02-22 16:06:11 -0500 received badge  Student (source)
2016-11-26 08:38:43 -0500 received badge  Necromancer (source)
2016-06-17 12:42:17 -0500 received badge  Famous Question (source)
2016-04-17 10:11:53 -0500 received badge  Notable Question (source)
2016-03-30 08:30:10 -0500 received badge  Scholar (source)
2016-03-30 08:28:51 -0500 received badge  Popular Question (source)
2016-03-17 05:53:53 -0500 asked a question what is the right way to inverse a transform in python

I am wondering if you know a better way (less boiler code) that will allow me to inverse a transform msg, in Python. For now I use the following code:

from geometry_msgs.msg import PoseStamped, TransformStamped
from tf import TransformerROS

res = TransformStamped()  # creating new transform msg
res.header.stamp = input_transform.header.stamp  # same timestamp
res.header.frame_id = input_transform.child_frame_id  # inverting frame_id and child_frame_id manualy
res.child_frame_id = input_transform.header.frame_id
transformer = TransformerROS()  # using a transformer in order to compute inverse transform
transformer.setTransform(input_transform)  # using the input_transform
translation, rotation = transformer.lookupTransform(res.header.frame_id, res.child_frame_id, rospy.Time(0))  # using lookup in order to get the inverse of input transform (here I use input_transform.child_frame_id to input_transform_frame_id
for attr_name, val in zip(['x', 'y', 'z'], translation):
    res.transform.translation.__setattr__(attr_name, val)
for attr_name, val in zip(['x', 'y', 'z', 'w'], rotation):
    res.transform.rotation.__setattr__(attr_name, val)

what do you think ?

2016-03-08 01:28:55 -0500 received badge  Teacher (source)
2016-03-08 01:28:55 -0500 received badge  Necromancer (source)
2016-01-07 05:27:46 -0500 answered a question start and stop rosbag within a python script

Similar to sergey_alexandrov answer, but using psutils python module as highlight on stackoverflow : http://stackoverflow.com/questions/33...

def terminate_process_and_children(p):
  import psutil
  process = psutil.Process(p.pid)
  for sub_process in process.get_children(recursive=True):
      sub_process.send_signal(signal.SIGINT)
  p.wait()  # we wait for children to terminate
  p.terminate()

def main():
  dir_save_bagfile = '/tmp/'
  rosbag_process = subprocess.Popen('rosbag record -a -j -o {}'.format("my_rosbag_prefis"), stdin=subprocess.PIPE, shell=True, cwd=dir_save_bagfile)
  terminate_process_and_children(rosbag_process)
2015-12-30 16:15:47 -0500 answered a question How can I run roscore from python ?

I don't know the ros way to do it, and personally I use python subbprocess to run the roscore first:

import subprocess
roscore = subprocess.Popen('roscore')
time.sleep(1)  # wait a bit to be sure the roscore is really launched

then your code:

unittest.main()  # for instance in my case I need a roscore to run some node tests
2015-12-10 03:56:35 -0500 received badge  Enthusiast
2015-12-01 05:02:56 -0500 received badge  Supporter (source)