5CCE2EMP Writing a Model-based Control Library


Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due


5CCE2EMP Writing a Model-based Control Library

Wednesday 9th October 2024

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

Variable impedance actuators are kind of actuator used to achieve compliance and energy efficiency in robotic devices. They work in a similar way to human muscles, whereby they can adjust their precision and stiffness depending on the demands of the task. There are many different mechanical designs to achieve this. This assignment focuses on the MACCEPA (Van Ham et al. 2007) one of the first mechanisms designed for this, and that has been used for tasks demanding high-efficiency energy management, such as throwing or running (Wu and Howard 2018).

A conceptual diagram of the MACCEPA is shown in Fig. 1.

Figure 1: Model of the MACCEPA (left) and physical mechanism (right).

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


where A, B and C are the lengths shown in Fig. 1, r is the radius of the winding drum used to adjust the spring pre-tension, and κ is the linear spring constant. Note that, as the spring can be streched, the length A has to be computed using the angle θ = u1 − q via the cosine rule.

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

To complete the assignment, you will need the following files:
• maincw2.c
• libcw2.h
• libcw2.c
• cw2.c

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

Complete the following tasks.
1. To compute A through the cosine rule, a function to compute the cosine of θ is needed. The series expansion

can be used to compute an approximation. It is convenient to break the computation into subfunctions to compute each of the component terms, so the first task is to write a function to compute the nth power of a number.

To complete this part of the assignment, find and modify the following lines in the template file:

1 /* --------------- Begin Answer to Task 1 Here ------------ */
2
3 /* --------------- End Answer to Task 1 Here -------------- */

The function should take a floating point number as an argument and return its nth power. [13 marks]

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:

1 /* --------------- Begin Answer to Task 2 Here ------------ */
2
3 /* --------------- End Answer to Task 2 Here -------------- */
The function should take the integer as an argument and return its factorial if successful, or -1 if a negative integer is passed. [17 marks]

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:

1 /* --------------- Begin Answer to Task 3 Here ------------ */
2
3 /* --------------- End Answer to Task 3 Here -------------- */

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]

4. The final task is to write a function that computes A using the cosine rule, the current angle of the joint and servo motor and length information.

To complete this part of the assignment, find and modify the following lines in the template file:

1 /* --------------- Begin Answer to Task 4 Here ------------ */
2
3 /* --------------- End Answer to Task 4 Here -------------- */

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

To submit your assignment, you need to upload your code to KEATS. To do this, simply upload the file cw2.c at the submission link. The submission should be a single, plain text file, with the extension ‘.c’ (files submitted in any other format, including zip files, may be awarded zero marks).

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.

Completed assignments should be submitted to KEATS by 10am Wednesday 16th October 2024 (UK time).

This assignment is worth 30% of the module mark.

References

Van Ham, Ronald et al. (2007). “MACCEPA, the mechanically adjustable compliance and controllable equi librium position actuator: Design and implementation in a biped robot”. In: Robotics and Autonomous

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.

发表评论

电子邮件地址不会被公开。 必填项已用*标注