![]() I’ve also added a bit of line magic to display the methods defined on a robot model class: Print('Methods available in '.format(robotclass._name_, '\n\t'.join(methods))) #Execute the cell code - define robot commands as calls on: robot #Set the robot variable to an instance of the desired robot class #The try/except block exits form a keyboard interrupt cleanly Port = _ns if 'vrep_port' in _ns else 19997 #Handle default IP address and port settings grab from globals if set LoadSceneRelativeToClient(shlex.split(line)) #Use shlex.split to handle quoted strings containing a space character # The class MUST call this class decorator at creation vrepsim(self, line, cell): So here’s a first attempt at some IPython cell magic to do that:įrom import (Magics, magics_class, line_magic, With nnect("127.0.0.1", 19997) as api:īut it struck me that it would be much nicer to be able to use some magic along the lines of the following, in which we set up the simulator with a scene, identify the robot we want to control, automatically connect to the simulator and then just run the robot control program: We can defend against the KeyboardInterrupt by wrapping the code execution in a try/except block: Setting up the connection to the simulator is a bit of a faff, and when code cell execution is stopped we can get an annoying KeyboardInterrupt report: The robot class should contain the definitions required to control the robot model in the loaded in scene. Once the connection to the simulator is made, a robot object can be instantiated using the connection details. Note that this scene should contain a robot model. The loadSceneRelativeToClient() function loads the specified scene into the simulator. Whilst this requires an extension to be installed to implement the read-only behaviour, the intention is that we distribute a customised Jupyter notebook environment to students.) ![]() (To try to minimise the risk of students introducing breaking changes into the imported notebooks, we could also lock the cells as read-only in the notebooks. The %run cell magic loads and runs the referenced notebooks, which can also be inspected (and modified) by students. ![]() My first approach to trying to simplify presentation was to create some “self-documenting” notebooks that could be used to set-up necessary environmental variables and import default classes and functions: Whilst exploring how we might be able to use Jupyter notebooks hooked up to the Coppelia Robotics V-REP robot simulator, it struck me that we needed a fair amount of boilerplate stuff to get the simulator loaded with an appropriate scene file and the a connection made to the simulator from the notebook so we could script the robot actions from the notebooks.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |