-
Notifications
You must be signed in to change notification settings - Fork 0
Home
The main purposes of this system are:
- Run the same robot with different implementations simultaneously (hard, simulation, kinematics model)
- Open-loop synchronization between robots
- Separates robot definitions and implementation
- Generalized the implementation so it can be adapted to a different robot
You can add as many robots you like to run simultaneously as you want. For example, you can have two hardware robots, two simulations, and two kinematics models.
Each robot has drive(input), sense(), and observe_state() functions and they are called at every timestep. Inputs come from whatever is associated with the system or robot itself, such as files, keyboards, and joysticks. If two or more robots share the same inputs, they'll run synchronously in an open loop.
Each robot can have associated output systems, and the default is to save all timestamps, inputs, states, and outputs to a file.
You can reproduce the robot behaviors by using this file as a file input, which is useful if you have recorded the motions of a joystick-controlled robot.
Run Code
o = Operator() # Create instance of Robot testing system
# Create an instance of the input system.
# You can only have one type of input per test
i = KeyboardInput() # use keyboard inputs
i = JoystickInput() # use joystick
i = FileInput('trajectory/r2k/ref_robot.csv', loop=False) # use trajectory in a file
o.set_input(i) # specify inputs to use
# Create instances of robots and corresponding output methods.
# each robot can have multiple output system
# specify an output file
hardware_csv = FileOutput('outputs.csv') # save to test.csv at the same dir as the
# add robots to the system
# Robot definition + implementation + arguments
s.add_robot(Manipulator, (Dynamixel, '/dev/ttyUSB0'), (hardware_csv,))
# add 10 of the same robot in simulation (using same inputs, and default file outputs)
N = 10
for n in range(N):
o.add_robot(bind_robot(Manipulator, Simulation))
# add process, for example, a planner
o.add_process(some_process)
# run the robots
o.run(SimConfig(max_duration=100, dt=0.02, realtime=True, start_time=0, run_speed=1))
# run 100sec, with 0.02s timestep at realtime and initial time is 0. runspeed change the speed to like 2x or 0.5x or so. too fast or too slow would not work well