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

Adding object/changing position in Gazebo and Rviz

asked 2020-02-10 07:38:45 -0600

Zenzu gravatar image

I am trying to add a box, with which a KUKA robot could interact (push it into the desired position). Besides being able to interact with it, I have to be able to change its position through a node. Could you point me into the right direction, what should be the right way of doing it? My ideas/attempts are:

  1. If I create a box in same urdf file as KUKA, the arm avoids the object because of the collision avoidance. I believe that if I could somehow disable this, I could push the object with arm. Will I be able to change the position of the object using tf?
  2. The second idea is to insert the object in Gazebo using the Gazebo GUI. It seems to work but I am getting an error, right after I have inserted the object:

[ERROR] [1581331637.324486823]: This robot has a joint named "joint_a1" which is not in the gazebo model.

[FATAL] [1581331637.325261818]: Could not initialize robot simulation interface

So far I have not find any impact of that error. I am able to change its position using /gazebo/set_model_state service. To visualize the object in Rviz, tf broadcaster is needed, right? I think that the actual position of the object I could get from /gazebo/get_model_state service.

3) The third idea was to create two separate robot_models (2 separate urdf files with 2 urdf_spawn nodes). But with this idea I have had no success so far.

Could you point me to the right direction? How can it be solved?

PS: for better understanding I am trying to create this environment in ROS using KUKA: https://gym.openai.com/envs/FetchPush...

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2020-02-10 08:35:56 -0600

updated 2020-02-10 08:40:42 -0600

You can create a model plugin for your gazebo model, you need insert box model into the world file and specify the name of your model plugin so that you can manipulate the states/properties of this model through the plugin. Inside The plugin you can well use ros functinoalities like subscriber and publishers, this way you Can have access to topics that you will use to change the pose of model accordingly. Have look at link below to see a gazebo plugin that I wrote for my project, It’s simply moves an object randomly Between defined boundaries, https://github.com/jediofgever/random...

note; I am not sure if this is the simplisest way to handle this but I would have done it this way, hope it helps

edit flag offensive delete link more

Comments

thank you very much. I am going to try it and later I will let you know.

Zenzu gravatar image Zenzu  ( 2020-02-10 09:05:47 -0600 )edit

It seems to work, Thank you once more

Zenzu gravatar image Zenzu  ( 2020-02-11 04:28:35 -0600 )edit

I know it's been a while since the last comment, but I'm trying to do the same.

Basically, instead of a box, I just wanna create a mark (a sphere for instance, or a circle in red) showing the target point and being able to interact with it; I mean know its position and change through a node. I am using python but I am a bit lost. Could you share the idea in more detail, please?

david_valencia gravatar image david_valencia  ( 2021-08-04 11:07:35 -0600 )edit

Please open a new question and state your problem in detail

Fetullah Atas gravatar image Fetullah Atas  ( 2021-08-04 12:05:41 -0600 )edit

Here is a link to my github with the custom plugin that I used. However, it is in C++. Hope it helps. https://github.com/TomasMerva/ROS_KUK...

Zenzu gravatar image Zenzu  ( 2021-08-04 12:11:21 -0600 )edit
0

answered 2021-09-12 11:13:13 -0600

updated 2021-09-12 11:35:20 -0600

hello there,

About the node, There is a gazebo service that allow to modify the position of an object.

Here is an example:

from gazebo_msgs.msg import ModelState 
from gazebo_msgs.srv import SetModelState

#GAZEBO SERVICE
        rospy.wait_for_service('/gazebo/set_model_state')
        try:
           self.set_state = rospy.ServiceProxy('/gazebo/set_model_state', SetModelState)
        except rospy.ServiceException :
            print("Service call failed")

        state_msg = ModelState()
        state_msg.model_name = 'the name of the model you want to move as presented by gazebo"'


            state_msg.pose.position.x =  25
            state_msg.pose.position.y = 25
            state_msg.pose.position.z =  -18.48
            state_msg.pose.orientation.w = 1
            state_msg.pose.orientation.x = 0
            state_msg.pose.orientation.y = 0
            state_msg.pose.orientation.z = 0

resp = self.set_state(state_msg)

Would this be useful?

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-02-10 07:38:45 -0600

Seen: 4,921 times

Last updated: Sep 12 '21