Sunday, August 5, 2018

VSCode tips for ROS

Tip1 - Adding a file extension to a language

You can add new file extensions to an existing language with the files.associations setting, for example assign gazebo .world file to XML

"files.associations":{
 ".world": "xml"
}


Tip2 - use code runner to check urdf files

code runner:  Run code snippet or code file for multiple languages
  • install 'Code runner' extension into vscode 
  • install check_urdf (apt-get install liburdfdom-tools)
  • from settings append file extension into code runner mapping
"code-runner.executorMapByFileExtension": { 
".urdf": "check_urdf"

Tip3 - use code runner to check xacro files

ROS node xacro in package xacro convert xacro  file to urdf

rosrun xacro xacro <file_name.xacro>

The idea is to run the above command redirect the output to tmp file and then run check_urdf on it.

"files.associations":{
".xacro": "rosrun xacro xacro --inorder $fullFileName > /tmp/tmp.urdf && check_urdf /tmp/tmp.urdf"
}


code runner supported parameters
  • $workspaceRoot: The path of the folder opened in VS Code
  • $dir: The directory of the code file being run
  • $dirWithoutTrailingSlash: The directory of the code file being run without a trailing slash
  • $fullFileName: The full name of the code file being run
  • $fileName: The base name of the code file being run, that is the file without the directory
  • $fileNameWithoutExt: The base name of the code file being run without its extension

1 comment:

Vitaly Bezuglyj said...

Talking about first tip, not "file.associations" but "fileS.associations"