Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
5CCE2EMP Writing a Model-based Control Library
1 Introduction
As a C programmer (and an engineer), you will frequently be asked to use your specialist skills to contribute functional code as a smaller part of a larger project. In this assignment, you will write code to implement components and functions of a larger C program that models a variable impedance actuator (a kind of robotic actuator) for model predictive control.
Note that, you do not need any in-depth knowledge of variable impedance actuation technologies to complete this assignment.
2 Background
A conceptual diagram of the MACCEPA is shown in Fig. 1.
The MACCEPA works through the action of two servomotors, one adjusts the pretension of a spring thereby adjusting the stiffness and the other adjusts the position of a lever-arm, thereby adjusting the torque (or, equivalently, the equilibrium position). The position of servomotor 1 is denoted by u1 and that of servomotor 2 is denoted by u2. The angle of the output link is given by q. Sensors in the arm allow u1, u2 and q to be measured by the robot controller.
Using this model, quanitites needed for the control of the device can be computed. For instance, the joint torque is given by
Your task in this assignment is to implement functions that would allow these quantities to be computed on a custom control chip that does not support standard C maths libraries: specifically, you cannot use math.h.
3 Preparation
Download these from KEATS and save them to your computer.
Use the following commands to compile the program:
1 $ gcc libcw2 . c cw2 . c maincw2 . c -o cw2
You should find that it compiles without errors.1
Important In the following, you will be asked to implement functions in cw2.c. When completing the tasks, be sure to only implement code at the locations indicated in the tasks. Do not change the number or type of parameters used in the functions nor the type of their return values. Do not modify any file, other than cw2.c. You are encouraged to comment your code to aid understanding for the markers.
4 Tasks
To complete this part of the assignment, find and modify the following lines in the template file:
2. The next task is to write a function to compute the factorial of an integer.
To complete this part of the assignment, find and modify the following lines in the template file:
3. The next task is to write a function to compute the cosine of an angle using the series expansion (2).
To complete this part of the assignment, find and modify the following lines in the template file:
The function should take a floating point number as an argument and return its cosine. You should design your function appropriately so that it computes the cosine to an accuracy of at least 1e-3. [17 marks]
To complete this part of the assignment, find and modify the following lines in the template file:
The function should take the floating point value of B, C, u1 and q as arguments and return the length A if successful, or -1 if an error occurs. Implement all parts of the calculation needed to compute this quantity.
Debug your code and make sure that it compiles and runs without errors or warnings. [53 marks]
5 Submission
Important The code you submit will be assessed based on its functionality. If the marking team are unable to make your code compile or run, it may be awarded zero marks.
This assignment is worth 30% of the module mark.
References
Systems 55.10, pp. 761–768. issn: 09218890. doi: 10.1016/j.robot.2007.03.001.
Wu, Fan and M. Howard (2018). “A Hybrid Dynamic-regenerative Damping Scheme for Energy Regeneration in Variable Impedance Actuators”. In: IEEE Int. Conf. Robotics & Automation.