Complete the code to specify the physics engine in a Gazebo world file.
<physics name="default_physics" type="[1]"> <max_step_size>0.001</max_step_size> <real_time_factor>1</real_time_factor> </physics>
The type attribute defines the physics engine Gazebo uses. 'ode' is the default physics engine.
Complete the SDF snippet to enable collision detection for a link.
<link name="wheel_link"> <collision name="wheel_collision"> <geometry> <cylinder> <radius>0.1</radius> <length>0.05</length> </cylinder> </geometry> <[1]> <surface> <contact> <collide_without_contact>true</collide_without_contact> </contact> </surface> </[1]> </collision> </link>
The contact tag inside surface defines collision contact properties.
Fix the error in the Gazebo plugin snippet to correctly subscribe to contact sensor messages.
#include <gazebo/gazebo.hh> #include <gazebo/sensors/sensors.hh> void OnContact(const gazebo::msgs::Contacts &contacts) { // Process contacts } void Load() { auto sensor = gazebo::sensors::SensorManager::Instance()->GetSensor("contact_sensor"); sensor->[1](std::bind(&OnContact, std::placeholders::_1)); }
The ConnectNewMessage method subscribes to new sensor messages in Gazebo plugins.
Fill both blanks to create a Gazebo model plugin that disables gravity and sets friction parameters.
#include <gazebo/gazebo.hh> class [1] : public gazebo::ModelPlugin { public: void Load(gazebo::physics::ModelPtr model, sdf::ElementPtr sdf) override { model->SetGravityMode([2]); auto link = model->GetLink("base_link"); if (link) { auto surface = link->GetCollision(0)->GetSurface(); surface->FrictionPyramid()->SetMuPrimary(1.0); surface->FrictionPyramid()->SetMuSecondary(1.0); } } };
The plugin class name can be anything descriptive. To disable gravity, SetGravityMode(false) is used.
Fill all three blanks to define a Gazebo SDF collision element with a box geometry and set its friction coefficients.
<collision name="box_collision"> <geometry> <box> <size>[1] [2] [3]</size> </box> </geometry> <surface> <friction> <ode> <mu>0.8</mu> <mu2>0.6</mu2> </ode> </friction> </surface> </collision>
The size tag requires three dimensions: length, width, and height. Here, 2.0, 0.5, and 0.3 are valid sizes in meters.
