Xacro convert property to integer
I'm using ROS Indigo and I want to create a robot with parametrizable camera resolution using just one urdf.xacro file. The camera width gets passed into the myrobot.urdf.xacro file via the prefix parameter when I spawn the robot:
<param name="robot_description" command="$(find xacro)/xacro.py '$(find simulator)/urdf/myrobot.urdf.xacro' prefix:=$(arg camera_resolution)" />
In the myrobot.urdf.xacro I then create the properties for a 4:3 aspect ratio:
<xacro:property name="cam_width" value="${arg prefix}" />
<xacro:property name="cam_height" value="${cam_width * 0.75}" />
Later I pass the values into the <sensor> field:
<sensor type="camera" name="camera_link_sensor">
<update_rate>10.0</update_rate>
<camera name="head">
<horizontal_fov>${M_PI/2}</horizontal_fov>
<image>
<width>${cam_width}</width>
<height>${cam_height}</height>
<format>R8G8B8</format>
</image>
...
</camera>
<plugin name="gazebo_ros_prosilica" filename="libgazebo_ros_camera.so">
...
</plugin>
</sensor>
So far so good.
Now when I input a camera_resolution parameter of 1024, the cam_width
get's correctly set to 1024, but for the height I just get the default value with an error:
Error [Param.cc:181] Unable to set value [768.0] for key[height]
I investigated the error and it seems, the sensor field can't handle float values, but xacro automatically creates cam_height
as float. If I manually insert the value 768.0
the same error message appears, but if I manually insert 768
, the parameter get's set correctly.
Now to my question: is there a way to manually convert the cam_height
property to an integer? I know with ROS Jade arbitrary python expressions will get supported by xacro, so I could use the floor() function, but is there any other way apart from switching to ROS Jade? I already tried stuff like cam_height / 1
without success.
Alternatively, maybe someone has a better idea how I could realize the parametrizable camera resolution.
Best regards, Malefitz
All I can see so far is http://wiki.ros.org/urdf/Tutorials/Us... which says 'All of the math is done using floats'. Also tried this in rrbot.gazebo and Indigo and gazebo 2.2.5 and got same error message.
The error is coming from https://bitbucket.org/osrf/sdformat (hg up sdf_1.5) https://bitbucket.org/osrf/sdformat/s...
I found that "All of the math is done using floats" statement, too. Seems there is no way to reconvert the floats to integers pre-Jade...thanks anyway!