Package: pycreate2
pyCreate2A python library for controlling theiRobot
Create 2. This was used
in ECE 387 Introduction to Robotics class I taught at the US Air Force Academy.video: robot could only follow the black tap road and couldn't run into anything. If anything got in the way, it had to naviage around it to its final destinationvideo: robot pet, follow the pink ballvideo: robot pet, follow the pink ballInstallpipThe recommended way to install this library is:pipinstallpycreate2DevelopmentIf you wish to develop and submit git-pulls, you can do:gitclonehttps://github.com/walchko/pycreate2cdpycreate2
poetryinstall
poetryrunpytest-vUseThere are multiple ways to command the Create to move, here are some
examples:frompycreate2importCreate2importtime# Create a Create2.port="/dev/serial"# where is your serial port?bot=Create2(port)# Start the Create 2bot.start()# Put the Create2 into 'safe' mode so we can drive it# This will still provide some protectionbot.safe()# You are responsible for handling issues, no protection/safety in# this mode ... becarefulbot.full()# directly set the motor speeds ... move forwardbot.drive_direct(100,100)time.sleep(2)# turn in placebot.drive_direct(200,-200)# inputs for motors are +/- 500 maxtime.sleep(2)# Stop the botbot.drive_stop()# query some sensorssensors=bot.get_sensors()# returns all dataprint(sensors.light_bumper_left)# Close the connection# bot.close()More examples are found in theexamples
folder.DocumentsAdditional notes and documents are in thedocs
folder.ModesThe different modes (OFF, PASSIVE, SAFE, and FULL) can be switched
between by calling different commands.OFF:The robot is off and can charge, it will accept no commandsPASSIVE:The robot is in standbye and can charge. It will send
sensor packets, but will not moveSAFE:The robot will not charge, but you full control over it
with a few exceptions. If the cliff sensors or wheel drop sensors
are triggered, the robot goes back to PASSIVE mode.FULL:The robot will not charge and you have full control. You
are responsible to handle any response due to cliff, wheel drop or
any other sensors.Sensor DataSensor data is returned as anamedtuplefromcollections. The
information can be accessed as either:sensors=bot.get_sensors()sensors.wall==sensors[1]# TrueSensorRangeIndexbumps_wheeldrops[0-15]0wall[0-1]1cliff_left[0-1]2cliff_front_left[0-1]3cliff_front_right[0-1]4cliff_right[0-1]5virtual_wall[0-1]6overcurrents[0-29]7dirt_detect[0-255]8ir_opcode[0-255]9buttons[0-255]10distance[-322768-32767]11angle[-322768-32767]12charger_state[0-6]13voltage[0-65535]14current[-322768-32767]15temperature[-128-127]16battery_charge[0-65535]17battery_capacity[0-65535]18wall_signal[0-1023]19cliff_left_signal[0-4095]20cliff_front_left_signal[0-4095]21cliff_front_right_signal[0-4095]22cliff_right_signal[0-4095]23charger_available[0-3]24open_interface_mode[0-3]25song_number[0-4]26song_playing[0-1]27oi_stream_num_packets[0-108]28velocity[-500-500]29radius[-322768-32767]30velocity_right[-500-500]31velocity_left[-500-500]32encoder_counts_left[-322768-32767]33encoder_counts_right[-322768-32767]34light_bumper[0-127]35light_bumper_left[0-4095]36light_bumper_front_left[0-4095]37light_bumper_center_left[0-4095]38light_bumper_center_right[0-4095]39light_bumper_front_right[0-4095]40light_bumper_right[0-4095]41ir_opcode_left[0-255]42ir_opcode_right[0-255]43left_motor_current[-322768-32767]44right_motor_current[-322768-32767]45main_brush_current[-322768-32767]46side_brush_current[-322768-32767]47statis[0-3]48Change Log2020-02-160.8.0Simplified interface and bug fixes2020-02-160.7.7Fixed typo with poetry2020-02-160.7.6Fixed typo erro inbin2020-02-160.7.5Switched to toml and poetry2019-06-300.7.4Midi sounds working2017-08-260.7.3code clean up and doc updates2017-08-260.7.2updates and fixes2017-05-260.5.0init and published to pypiThe MIT LicenseCopyright (c) 2007 Damon KohlerCopyright (c) 2015 Jonathan Le Roux (Modifications for Create 2)Copyright (c) 2015 Brandon PomeroyCopyright (c) 2017 Kevin WalchkoPermission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.