First, be sure you have a robot installed on your computer. If not, you can install it with pip by running in a shell :
> pip install roboticia-quattro
Second create your robot :
from roboticia_quattro import RoboticiaQuattro
robot = RoboticiaQuattro(simulator = 'vrep', host = '127.0.0.1')
Your robot have sensors and motors attach to it :
robot.motors
[<DxlMotor name=m11 id=11 pos=-0.0>, <DxlMotor name=m12 id=12 pos=-20.0>, <DxlMotor name=m13 id=13 pos=20.0>, <DxlMotor name=m21 id=21 pos=-0.0>, <DxlMotor name=m22 id=22 pos=-20.0>, <DxlMotor name=m23 id=23 pos=20.0>, <DxlMotor name=m31 id=31 pos=0.1>, <DxlMotor name=m32 id=32 pos=20.1>, <DxlMotor name=m33 id=33 pos=-20.0>, <DxlMotor name=m41 id=41 pos=0.0>, <DxlMotor name=m42 id=42 pos=20.0>, <DxlMotor name=m43 id=43 pos=-20.0>]
robot.sensors
[<ForceSensor name=f1 force = 6.06322586536>]
Motors and sensors are updated by a controller. You are not supposed to access the controller to manage your robot but you can see the controllers :
robot._controllers
[<pypot.vrep.controller.VrepController at 0x421cbd0>, <roboticia_quattro.roboticia_quattro.VrepForceController at 0x11e3bf70>]
Notice that each controller have an io. The io is the classe used to communicate with the real robot. The io is used to synchronize the software robot class with the real robot :
robot._controllers[1].io
<pypot.vrep.io.VrepIO at 0x11e22af0>
The synchronization made by the controllers can be stopped and start :
robot.stop_sync()
robot.start_sync()
And you can manage all motors and sensors very easily :
For example if you want to retrieve the value of the force sensor f1 :
robot.f1.force
9.143142402172089
If you want to know the position of the motor m12 :
robot.m12.present_position
-20.0
The simulation in vrep can be stop, start or reset :
robot.stop_simulation()
robot.start_simulation()
robot.reset_simulation()
Don't forget to close your robot if you want to release the io and the real bus or socket used for that :
robot.close()