Ask Your Question
0

How to assign Vector3 value to Float64

asked 2016-10-26 23:28:48 -0500

ZainMehdi gravatar image

I am trying to assign vector3 value to a Float64 variable as my function accepts Float64 arguments. It gives following error

no match for ‘operator=’ (operand types are ‘std_msgs::Float64’ and ‘geometry_msgs::Vector3_<std::allocator<void> >::_z_type {aka double}’)

My function is of the following form

void calc_cartezian_trajectory(double CT[3][N] , Float64 desX , Float64 desY , Float64 desZ , double initial_pose_end_effector[3])

How can I do that ? Is there anyway I can pass vector3 values as vector3.x as parameters to my function ?

edit retag flag offensive close merge delete

Comments

I figured another way out. I passed Vector3 to my function instead of Float64 and it worked. But still a way for type conversion might be helpful.

ZainMehdi gravatar image ZainMehdi  ( 2016-10-26 23:45:01 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2016-10-27 01:37:09 -0500

gvdhoorn gravatar image

updated 2016-10-27 01:37:49 -0500

I figured another way out. I passed Vector3 to my function instead of Float64 and it worked. But still a way for type conversion might be helpful.

There is no conversion defined for Vector3 to Float64 (or really double, as the error message tells you). I'm also dubious as to how that would work: C++ type conversions are from one value to another, while Vector3 packs three values, so a conversion should return another container-like type (a tuple, vector or something like that) in order to work. That wouldn't really help that much I believe.

Is there anyway I can pass vector3 values as vector3.x as parameters to my function ?

Well, yes: geometry_msgs/Vector3 contains x, y and z members, didn't the following work for you?

calc_cartezian_trajectory(..., vector3.x, vector3.y, vector3.z, ...)

If that is really a problem, you could perhaps create an overloaded version of calc_cartezian_trajectory(..) that does take a geometry_msgs::Vector3 instance, and then calls the one you have now.

PS: slightly off-topic, but cartezian -> cartesian.

edit flag offensive delete link more

Comments

thnx alot for the answer and spelling correction :p.. cheers !!!

ZainMehdi gravatar image ZainMehdi  ( 2016-10-27 19:37:05 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-10-26 23:28:48 -0500

Seen: 494 times

Last updated: Oct 27 '16