I am trying to get the position of Aruco Marker in the gazebo and publish it on the topic so that I can use it for different processes. Can anyone help me to sort out the solution? I found a similar question in the links below
But I can not apply the solution given in the link above. Maybe the answers are ambiguous or it’s me who couldn’t get it? Can someone guide me on how can I get the position and publish it on a topic so I can use it outside the gazebo e.g., PX4 or ROS?
There isn’t any issue, i didn’t knew how could I get the position of Aruco marker from Gazebo world in a ROS node which is communicating with PX4. I have found a way to get it done.
I have done a few steps to get the position of the drone in the gazebo world with respect to the origin and then get that position into my ROS node (C++).
Create a service in my case the code is “ros::ServiceClient aruco_position_client = nh.serviceClient<gazebo_msgs::GetModelState>
(”/gazebo/get_model_state");"
Create object of type GetModelState “gazebo_msgs::GetModelState objstate;”
use the service “objstate.request.model_name = (std::string) (“put your model name here”)”;
4.Now you can extract the position of the marker and publish it.
In response to @fulano, I have written steps to get position w.r.t origin but now i want to get position of camera w.r.t marker.
Now I am working on extracting the position of marker w.r.t camera. I have found some solution in python. But I couldn’t implement it in C++ till now. As for python I just need to add the name of both models and that’s it. But it’s not working in C++.
Can you tell me more detail about your objective & constraints?
Because there are various ways to achieve relative position between camera and Aruco markers.
One of the easiest ways is using fiducials package as I mentioned. It will directly publish you the information you want in ROS envrionment.
For getting the relative position without ROS, it’s implemented in OpenCV library. You can simply use it.
I got the position of aruco marker with respect to iris drone. I can share my code where I am getting the position of aruco and iris with respect to the origin and also w.r.t to eachother. See the code below:
while(ros::ok()){
objstate.request.model_name = “iris”;
objstate.request.relative_entity_name = “aruco_visual_marker_7”; //Add this line in order to have a relative position ,so here we are getting position of iris w.r.t marker.Ignore it to get position w.r.origin
if ((aruco_position_client.call(objstate) && objstate.response.success)){
//ROS_INFO("This is position of Aruco Marker");
aruco_pose = objstate.response.pose;
std::cout<<"The Position of aruco marker is : "<<aruco_pose<<"\n";
ros::spinOnce();
rate.sleep();
}
}
indent preformatted text by 4 spaces
Now just create a topic of type geometry_msgs::Pose and publish the aruco_pose value on it .