Implementation of an Onshape digital twin for the Arduino Braccio++ robot arm. We can use the Onshape interface to place checkpoints that define the path of the end effector as well as the gripper configuration allowing pick and place operations. Accompanying Onshape document: Click here to follow
The code works by making https GET requests to the onshape API to fetch information about each checkpoint position and configuration. It calculates the angles required to get to that position and then sets the robot arm to those joint angles. If monitoring is enabled it makes POST requests to set mate values for the onshape model to represent the physical state.
This code requires the following arduino libraries to be installed:
ArduinoJson and Braccio++ can be installed from the arduino library manager whereas BraccioIK and Braccio++ can be installed from the linked github repositories. They can be downloaded as a .zip file and use Arduino IDE to select the option "Add .zip libary" under sketch - include library.
Open the linked onshape document for this assembly and make a copy to edit. Then obtain your key to the onshape API here (write this down for later).
once assembled, connect your Arduino Braccio++ robot arm to your computer and run the ObtainMinMax code in main. Open the serial monitor and you will see the value of each joint (the arm should be disengaged and free to move around). We need to get the physical min and max angle possible at each joint so move the joint to its minimum and maximum position repeating this for each joint.Write it down for later. This will look something like this:
float motorMin[4] = {0, 84, 55, 38.19};
float motorMax[4] = {360, 225, 256, 251.76};
These are the angles for base, shoulder, elbow, and wrist respectively. We also need to find the home position of each joint this is the position where the Braccio is point straight up with the gripper open. (The original home position considers a closed gripper but we define the homed gripper as open).
float homePos[6] = {230.92, 159.63, 147.26, 152.15, 150.81, 180.42};
Open the BraccioOnshape code in ArduinoIDE which is the main code. We need to change these fields to reflect your settings at the top of the code:
Follow the instructions on the arduino website to add Onshape's SSL certificate to your Braccio's nano RP2040.
We can now upload the code to the Arduino and run it. By default, the code waits for you to connect to the serial monitor so you must be open the serial monitor to run it. This can be changed in the code if not required but it provides useful information while sending the requests.
We can insert upto 10 checkpoints, while inserting the checkpoint you can set the following configuration parameters:
- configuration: The number for which order the checkpoint appears in the sequence
- gripper configuration: Whether the gripper is closed or open
- gripper delay: Time(in seconds) to wait at each checkpoint
Click generate when done.The checkpoint can be moved around and arranged as required within the green dome representing the range of motion.
Once the path is set, the enter button on the Braccio board can be pressed to execute the path.
To better help guide the placement of checkpoints in space, we can use the onshape mobile app to perform a LIDAR scan from supported devices and import into the onshape document. Manually line it up using the robot as a reference.
This program was part of a submission for Onshape undergraduate poster competition in 2022