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

How to assign geometry_msgs / Pose of ROS under arduino circumstances

asked 2015-12-09 06:36:52 -0500

hua gravatar image

updated 2015-12-10 02:09:33 -0500

gvdhoorn gravatar image
#include <ros.h>
#include <geometry_msgs/Pose.h>

ros::NodeHandle nh;

geometry_msgs::Pose pose_msgs;
ros::Publisher pose("pose",&pose_msgs);

void setup(){
  // put your setup code here, to run once:
  //Serial.begin(9600);
  nh.initNode();
  nh.advertise(pose);
}

void loop() {
  // put your main code here, to run repeatedly:
  pose_msgs = {[1,2,3],[4,5,6,7]};
  pose.publish(&pose_msgs);
  nh.spinOnce();
  delay(1000);
}

My answer:How to assign geometry_msgs / Pose of ROS under arduino circumstances?


Edit: How to assign geometry_msgs / Pose of ROS under arduino circumstances?

edit retag flag offensive close merge delete

Comments

Please add a question...

mgruhler gravatar image mgruhler  ( 2015-12-09 12:37:42 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-12-10 04:27:35 -0500

mgruhler gravatar image

Check out the message doc here

Afaik, there is no difference between arduino or regular C++ in this case. Do something along the lines of

pose_msg.position.x = 1.0
pose_msg.position.y = 2.0
pose_msg.position.z = 3.0
pose_msg.orientation.x = 4.0
pose_msg.orientation.y = 5.0
pose_msg.orientation.z = 6.0
pose_msg.orientation.w = 7.0

But make sure, that your quaternion is normalized, which it isn't in the example above! Also, check again the documentation of how to set up your publishers). What you have there is not correct....

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-12-09 06:36:52 -0500

Seen: 3,208 times

Last updated: Dec 10 '15