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

Conversion Position to float

asked 2014-08-12 06:01:05 -0600

Moda gravatar image

updated 2014-08-12 06:49:04 -0600

I got in a variable Position (which I get from transform.getOrigin) and I want to convert it in a pair of float. How can I do that? I'm in Hydro, Ubuntu 12.04 and programming in c++

edit retag flag offensive close merge delete

Comments

2

Should we guess which programm language you use? I will never understand why people ask questions with that minimal amount of information.

BennyRe gravatar image BennyRe  ( 2014-08-12 06:15:09 -0600 )edit

How is this supposed to work? The origin has 3 degrees of freedom and you want to somehow store them in 2 floats?

dornhege gravatar image dornhege  ( 2014-08-12 06:49:39 -0600 )edit

yes this is the case

Moda gravatar image Moda  ( 2014-08-12 06:50:55 -0600 )edit
1

use typecast float posf = (float) position;

bvbdort gravatar image bvbdort  ( 2014-08-12 06:56:47 -0600 )edit

It works, thank you!!!

Moda gravatar image Moda  ( 2014-08-12 07:22:55 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-08-12 07:23:29 -0600

Moda gravatar image

updated 2014-08-12 07:23:44 -0600

The Solution is float posf = (float) position; given by @bvbdort

edit flag offensive delete link more

Comments

2

You could also use the C++ way of casting: float posf = static_cast<float>(position);

BennyRe gravatar image BennyRe  ( 2014-08-12 07:43:06 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-08-12 06:01:05 -0600

Seen: 233 times

Last updated: Aug 12 '14