Collision not working as intended
When I am spawning 2 models in Gazebo using a launch file everything works as intended, but when I try to spawn the same 2 models in the same way, they behave differently. Do you have any idea what could cause that?
From the launch file:
<group ns="$(arg robot_name)">
<!-- load robot_description -->
<include file="$(find ballbot_description)/launch/bb_description.launch">
<arg name="robot_name" value="$(arg robot_name)" />
<arg name="ground_truth" value="$(arg ground_truth)" />
<arg name="motors_controller_type" value="$(arg motors_controller_type)" />
<arg name="wheel_type_single" value="$(arg wheel_type_single)" />
<arg name="imu_update_rate" value="$(arg imu_update_rate)"/>
<arg name="control_period" value="$(arg control_period)"/>
<arg name="use_realsense" value="$(arg use_realsense)"/>
<arg name="use_laser" value="$(arg use_laser)"/>
</include>
<!-- robot spawner -->
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-urdf -model $(arg robot_name) -param robot_description -x $(arg robot_x_pos) -y $(arg robot_y_pos) -z $(arg robot_z_pos)" />
for the first model and
<!-- load ball description: -->
<group ns="$(arg ball_name)" if="$(arg use_the_ball)">
<include file="$(find ballbot_description)/launch/ball_description.launch">
<arg name="ball_name" value="$(arg ball_name)" />
<arg name="wheel_type_single" value="$(arg wheel_type_single)"/>
</include>
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-urdf -model $(arg ball_name) -param robot_description -x $(arg ball_x_pos) -y $(arg ball_y_pos) -z $(arg ball_z_pos)" />
</group>
for the second model. This works for me (I didn't create this file, it's off GitHub)
Now in the python script I am using frobs_rl which has load and spawn functions which uses
def gazebo_spawn_urdf_path( model_path, model_name="robot1", robot_namespace="/", reference_frame="world",
pos_x=0.0, pos_y=0.0, pos_z=0.0,
ori_x=0.0, ori_y=0.0, ori_z=0.0, ori_w=1.0) -> bool:
rospy.wait_for_service("/gazebo/spawn_urdf_model")
client_srv = rospy.ServiceProxy("/gazebo/spawn_urdf_model", SpawnModel)
if os.path.exists(model_path) is False:
print("Error: model path does not exist")
return False
model = xacro.process_file(model_path)
encoding = {}
model_string = model.toprettyxml(indent=' ', **encoding)
srv_model = SpawnModelRequest( model_name=model_name,
model_xml=model_string,
robot_namespace=robot_namespace,
initial_pose=Pose( position=Point(x=pos_x, y=pos_y, z=pos_z),
orientation=Quaternion(x=ori_x, y=ori_y, z=ori_z, w=ori_w)),
reference_frame=reference_frame)
try:
result = client_srv(srv_model)
return result.success, result.status_message
except ServiceException:
print("Error: Package used in model was not found, source the workspace in all terminals.")
return False
which I set up using
spawn_robot=True
model_name_in_gazebo="ballbot"
namespace="/ballbot/joints"
pkg_name="ballbot_description"
urdf_file="bb.xacro"
urdf_folder="/urdf"
controller_file="wheel_effort_controllers.yaml"
controller_list=["wheel1_effort_controller", "wheel2_effort_controller", "wheel3_effort_controller"]
urdf_xacro_args=[ "robot_name:=ballbot",
"ground_truth:=True",
"motors_controller_type:=EffortJointInterface",
"wheel_type_single:=False",
"imu_update_rate:=200",
"control_period:=0.01",
"use_laser:=True",
"use_realsense:=True",
"ball_name:=ball"]
rob_state_publisher_max_freq=100
model_pos_x=0.0; model_pos_y=0.0; model_pos_z=0.0
model_ori_x=0.0; model_ori_y=0.0; model_ori_z=0.0; model_ori_w=0.0
ros_urdf.urdf_load_from_pkg(pkg_name=pkg_name, model_name=urdf_file, folder=urdf_folder, param_name="robot_description", ns="/ballbot", args_xacro=urdf_xacro_args)
reset_mode=2
step_mode=1
num_gazebo_steps = 2
reset_controllers=True
super(BallbotEnv, self).__init__( spawn_robot=spawn_robot, model_name_in_gazebo=model_name_in_gazebo, namespace=namespace, pkg_name=pkg_name,
urdf_file=urdf_file, urdf_folder=urdf_folder, controller_file=controller_file, controller_list=controller_list,
urdf_xacro_args=urdf_xacro_args, rob_state_publisher_max_freq= rob_state_publisher_max_freq, rob_st_term=False,
model_pos_x=model_pos_x, model_pos_y=model_pos_y, model_pos_z=model_pos_z,
model_ori_x=model_ori_x, model_ori_y=model_ori_y, model_ori_z=model_ori_z, model_ori_w=model_ori_w,
reset_mode=reset_mode, step_mode=step_mode, reset_controllers=reset_controllers, num_gazebo_steps=num_gazebo_steps)
and for the second model:
model_name_in_gazebo="ball"
namespace="/ball"
pkg_name="ballbot_description"
urdf_file="ball.xacro"
urdf_folder="/urdf"
controller_file=None
controller_list=[]
urdf_xacro_args=["ball_name:=ball",
"wheel_type_single:=False"]
rob_state_publisher_max_freq=100
model_pos_x=0.0; model_pos_y=0.0; model_pos_z=0.0
model_ori_x=0.0; model_ori_y=0.0; model_ori_z=0.0; model_ori_w=0.0
ros_spawn.spawn_model_in_gazebo(pkg_name=pkg_name, model_urdf_file=urdf_file, controllers_file=controller_file, controllers_list=controller_list,
model_urdf_folder=urdf_folder, ns=namespace, args_xacro=urdf_xacro_args, max_pub_freq=rob_state_publisher_max_freq,
rob_st_term=False, gazebo_name="ball", gaz_ref_frame="world", pos_x=model_pos_x, pos_y=model_pos_y, pos_z=model_pos_z,
ori_w=model_ori_w, ori_x=model_ori_x, ori_y=model_ori_y, ori_z=model_ori_z)
When I spawn the 2 models using python, the wheels of my robot pass straight through the ball, whereas they stay on top of it when I use the launch file.
Asked by marb on 2022-12-15 15:38:14 UTC
Comments