pointing to a ray sensor
(New to gazebo)
Hi, I'm trying to access the ray sensor part of the hoyuko sensor in c++:
<sensor name="laser" type="ray">
<pose>0.01 0 0.0175 0 -0 0</pose>
<ray>
<scan>
<horizontal>
<samples>640</samples>
<resolution>1</resolution>
<min_angle>-2.26889</min_angle>
<max_angle>2.268899</max_angle>
</horizontal>
</scan>
<range>
<min>0.08</min>
<max>10</max>
<resolution>0.01</resolution>
</range>
</ray>
<plugin name="laser" filename="libRayPlugin.so" />
<always_on>1</always_on>
<update_rate>30</update_rate>
<visualize>true</visualize>
</sensor>
But I can't find or figure out the code required anywhere. I've looked through the other questions on this site, the tutorials and the API. The main thing I've figured out is that to use the functions in RaySensor you need a reference object. But I don't want to create a new object as it already exists in my model. instead I made a RaySensorPtr but have been unable to point to the RaySensor.
Before showing the code I should note that the Hoyuko model is a sub-model of my model (i.e. this->model does not reference the hoyuko model)
public: void OnUpdate(const common::UpdateInfo & /*_info*/)
{
// Apply a small linear velocity to the model.
this->model->SetLinearVel(math::Vector3(.3, 0, 0));
int sensor_num = this->model->GetSensorCount();
sensors::SensorPtr model_sensor = sensors::get_sensor("laser"); //points to sensor
//RayShapePtr MultiRayShape::Ray(const unsigned int 0) const //DOESN'T WORK
gazebo::sensors::RaySensorPtr model_ray_sensor;
//double testNum = model_sensor->ray->AngleMax(); DOESN'T WORK
//double testNum = this->model->sensor->ray->AngleMax(); DOESN'T WORK
//model_ray_sensor = sensors::RaySensor::GetLaserShape(); DOESN'T WORK
//physics::MultiRayShapePtr multi_ray_sensor = sensors::RaySensor::GetLaserShape(); DOESN'T WORK
//model_ray_sensor = sensors::RaySensor::get_sensor("laser"); DOESN'T WORK
double sensor_update_rate = model_sensor->GetUpdateRate(); //from generic sensor class
printf("Sensor name: %f \n", sensor_update_rate); //%f NOT %d!!!!
//printf("Sensor resolution: %f \n", sensor_angle_resolution); //%f NOT %d!!!!
//printf("Sensors: %u \n", sensorNum);
}
TLDR; I can point to the sensor class and print it's update rate. But I can't figure out how to point to the raysensor class.