Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 348

Xacro convert property to integer

$
0
0
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: In the myrobot.urdf.xacro I then create the properties for a 4:3 aspect ratio: Later I pass the values into the field:10.0${M_PI/2}${cam_width}${cam_height}R8G8B8 ... ... 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

Viewing all articles
Browse latest Browse all 348

Trending Articles